Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ios): ensure onBandwidthUpdate is reported only when value change #4149

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions examples/basic/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ PODS:
- FBLazyVector (0.74.5)
- fmt (9.1.0)
- glog (0.3.5)
- hermes-engine (0.74.3):
- hermes-engine/Pre-built (= 0.74.3)
- hermes-engine/Pre-built (0.74.3)
- hermes-engine (0.74.5):
- hermes-engine/Pre-built (= 0.74.5)
- hermes-engine/Pre-built (0.74.5)
- libavif/core (0.11.1)
- libavif/libdav1d (0.11.1):
- libavif/core
Expand Down Expand Up @@ -994,7 +994,7 @@ PODS:
- React-Mapbuffer (0.74.5):
- glog
- React-debug
- react-native-video (6.4.5):
- react-native-video (6.5.0):
- DoubleConversion
- glog
- hermes-engine
Expand All @@ -1008,7 +1008,7 @@ PODS:
- React-featureflags
- React-graphics
- React-ImageManager
- react-native-video/Video (= 6.4.5)
- react-native-video/Video (= 6.5.0)
- React-NativeModulesApple
- React-RCTFabric
- React-rendererdebug
Expand Down Expand Up @@ -1038,7 +1038,7 @@ PODS:
- ReactCommon/turbomodule/bridging
- ReactCommon/turbomodule/core
- Yoga
- react-native-video/Video (6.4.5):
- react-native-video/Video (6.5.0):
- DoubleConversion
- glog
- hermes-engine
Expand Down Expand Up @@ -1290,9 +1290,9 @@ PODS:
- React-utils (= 0.74.5)
- RNCPicker (2.7.5):
- React-Core
- SDWebImage (5.19.2):
- SDWebImage/Core (= 5.19.2)
- SDWebImage/Core (5.19.2)
- SDWebImage (5.19.7):
- SDWebImage/Core (= 5.19.7)
- SDWebImage/Core (5.19.7)
- SDWebImageAVIFCoder (0.11.0):
- libavif/core (>= 0.11.0)
- SDWebImage (~> 5.10)
Expand Down Expand Up @@ -1531,7 +1531,7 @@ SPEC CHECKSUMS:
FBLazyVector: ac12dc084d1c8ec4cc4d7b3cf1b0ebda6dab85af
fmt: 4c2741a687cc09f0634a2e2c72a838b99f1ff120
glog: fdfdfe5479092de0c4bdbebedd9056951f092c4f
hermes-engine: 1f547997900dd0752dc0cc0ae6dd16173c49e09b
hermes-engine: 8c1577f3fdb849cbe7729c2e7b5abc4b845e88f8
libavif: 84bbb62fb232c3018d6f1bab79beea87e35de7b7
libdav1d: 23581a4d8ec811ff171ed5e2e05cd27bad64c39f
libwebp: 1786c9f4ff8a279e4dac1e8f385004d5fc253009
Expand Down Expand Up @@ -1559,7 +1559,7 @@ SPEC CHECKSUMS:
React-jsitracing: c83efb63c8e9e1dff72a3c56e88ae1c530a87795
React-logger: 257858bd55f3a4e1bc0cf07ddc8fb9faba6f8c7c
React-Mapbuffer: dce508662b995ffefd29e278a16b78217039d43d
react-native-video: c5cd8b71116762c5a4ceee7f7961587d99aae8e3
react-native-video: 9f0b3c888537f9ded698f762f541b13573dd3686
react-native-video-plugin-sample: d3a93b7ad777cad7fa2c30473de75a2635ce5feb
React-nativeconfig: f326487bc61eba3f0e328da6efb2711533dcac46
React-NativeModulesApple: d89733f5baed8b9249ca5a8e497d63c550097312
Expand All @@ -1585,7 +1585,7 @@ SPEC CHECKSUMS:
React-utils: 3f1fcffc14893afb9a7e5b7c736353873cc5fc95
ReactCommon: f79ae672224dc1e6c2d932062176883c98eebd57
RNCPicker: 3e2c37a8328f368ce14da050cdc8231deb5fc9f9
SDWebImage: dfe95b2466a9823cf9f0c6d01217c06550d7b29a
SDWebImage: 8a6b7b160b4d710e2a22b6900e25301075c34cb3
SDWebImageAVIFCoder: 00310d246aab3232ce77f1d8f0076f8c4b021d90
SDWebImageSVGCoder: 15a300a97ec1c8ac958f009c02220ac0402e936c
SDWebImageWebPCoder: e38c0a70396191361d60c092933e22c20d5b1380
Expand Down
8 changes: 6 additions & 2 deletions ios/Video/RCTVideo.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
private var _presentingViewController: UIViewController?
private var _startPosition: Float64 = -1
private var _showNotificationControls = false
// Buffer last bitrate value received. Initialized to -2 to ensure -1 (sometimes reported by AVPlayer) is not missed
private var _lastBitrate = -2.0
freeboub marked this conversation as resolved.
Show resolved Hide resolved
freeboub marked this conversation as resolved.
Show resolved Hide resolved
private var _pictureInPictureEnabled = false {
didSet {
#if os(iOS)
Expand Down Expand Up @@ -1662,9 +1664,11 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
guard let accessLog = (notification.object as? AVPlayerItem)?.accessLog() else {
return
}

guard let lastEvent = accessLog.events.last else { return }
onVideoBandwidthUpdate?(["bitrate": lastEvent.indicatedBitrate, "target": reactTag])
if lastEvent.indicatedBitrate != _lastBitrate {
_lastBitrate = lastEvent.indicatedBitrate
onVideoBandwidthUpdate?(["bitrate": _lastBitrate, "target": reactTag])
}
}

func handleTracksChange(playerItem _: AVPlayerItem, change _: NSKeyValueObservedChange<[AVPlayerItemTrack]>) {
Expand Down
Loading