-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[BUG]: Ios single video making or repeating multiple sound #3567
Comments
I am also experiencing this issue. I suspect it is caused by rerenders creating new native instances of the video which are not being destroyed properly. I also have audio that is continuing to play after my component has been unmounted. I am working around this by just having the video muted on render and being manually unmuted and also checking focus to stop videos playing and muting them also. I think there must be memory leaking as a result of all this |
@KidsOnShred Please where u able to fix this at your end ? |
Can you please clarify which beta version you use? And can you please try on the last one please ? (Beta.6) |
I worked around it by auto muting the video in the start then manually unmute the one video which stops the sound duplicating but I suspect that multiple videos are playing in the background if the component ever rerenders. I am using 5.2.1 |
this is an issue on |
Facing same issue still on IOS on changing url. |
Can you please provide a sample? I don't think this is reproduced with the sample included in this repo ? |
Facing same issue here too. |
@mk0116 @freeboub Its concerning now since I am unable to move to latest (6.1.2) package in my project. Seems I'll have to wait before more stable version is out. |
I agree this is critical, but are you able to reproduce it with a sample ? Last time I tried, I was not able to reproduce with the sample included in the repo. I don't really know ho to progress... |
Ok, I am able to reproduce the issue with following patch in the sample: diff --git a/examples/basic/src/VideoPlayer.tsx b/examples/basic/src/VideoPlayer.tsx
index f712e013..4d720221 100644
--- a/examples/basic/src/VideoPlayer.tsx
+++ b/examples/basic/src/VideoPlayer.tsx
@@ -89,6 +89,7 @@ interface StateType {
poster?: string;
showNotificationControls: boolean;
isSeeking: boolean;
+ _key: number;
}
class VideoPlayer extends Component {
@@ -120,6 +121,7 @@ class VideoPlayer extends Component {
poster: undefined,
showNotificationControls: false,
isSeeking: false,
+ _key: 0,
};
// internal usage change to index if you want to select tracks by index instead of lang
@@ -557,6 +560,13 @@ class VideoPlayer extends Component {
}
};
+ componentDidMount(): void {
+ this.setState({_key: this.state._key + 1})
+ setTimeout(()=> {
+ this.setState({_key: this.state._key + 1})
+ })
+ }
+
onSelectedTextTrackChange = (itemValue: string) => {
console.log('on value change ' + itemValue);
this.setState({
@@ -762,6 +772,7 @@ class VideoPlayer extends Component {
return (
<TouchableOpacity style={viewStyle}>
<Video
+ key={this.state._key}
showNotificationControls={this.state.showNotificationControls}
ref={(ref: VideoRef) => {
this.video = ref; |
@freeboub I found a related code error while debugging the issue. Player objects are not popping properly from the observers. So that it keeps adding player in the observers object. - if let observer = observers[players.hashValue] {
+ if let observer = observers[player.hashValue] {
observer.invalidate()
}
- observers.removeValue(forKey: players.hashValue)
+ observers.removeValue(forKey: player.hashValue)
players.remove(player)
But this is just a piece. I found a main problem of the issue. The views do init -> registerPlayer -> deinit first time but second time, it does init the RCTPlayer view and registerPlayer twice and deinit just once. init -> registerPlayer -> init -> registerPlayer -> deinit. For me I was able to resolve the issue by patching the package with the code above and memo the react view so that view renders not too many times and ensured it does not detach and attach in a short time. |
@mk0116 on my side, I also see that we don't stop the player in |
ping @KrzysztofMoch can you confirm it makes sense for you ? |
Here is an aditionnal patch which make sense I think. @@ -1239,21 +1239,31 @@ class RCTVideo: UIView, RCTVideoPlayerViewControllerDelegate, RCTPlayerObserverH
}
// MARK: - Lifecycle
override func removeFromSuperview() {
+ self._player?.replaceCurrentItem(with: nil)
if let player = _player {
player.pause()
NowPlayingInfoCenterManager.shared.removePlayer(player: player)
}
+ _playerItem = nil
+ _source = nil
+ _chapters = nil
+ _drm = nil
+ _textTracks = nil
+ _selectedTextTrackCriteria = nil
+ _selectedAudioTrackCriteria = nil
+ _presentingViewController = nil
_player = nil
_resouceLoaderDelegate = nil
_playerObserver.clearPlayer()
#if USE_GOOGLE_IMA
_imaAdsManager.releaseAds()
+ _imaAdsManager = nil
#endif
self.removePlayerLayer()
if let _playerViewController { |
BTW, I reproduce similar issue on android also :'( |
Will be integrated in 6.2.0 |
Thank you for your effort @freeboub I will test it soon and let you know. |
@freeboub I have encounter this issue when url for video changes the video plays two audios. version(6.2.0 & 6.3.0) |
@MTPL0005-AbhishekDube @freeboub I am still facing this issue. Applied the above patch as well. |
Can you provide a sample please ? |
@freeboub I use similar code as video example |
We need a sample in a dedicated repository! Stop copy pasting extract of code please... |
@freeboub Try this snippet. I am able to reproduce this issue 100% times in ios. //App.js import React, { useState ,useEffect} from "react"; const App = () => { return ( In my case,I prevented instant mount/unmounting of player and issue is resolved for me for the time being. |
@rajgupta027 on 6.5.0 ? |
![]() Normal Case: Video Playback works fine. WhatsApp.Video.2024-09-06.at.3.49.21.PM.mp4Instant Mount/Unmount Case: Audio Leak is observed. WhatsApp.Video.2024-09-06.at.3.49.14.PM.mp4 |
This issue is stale because it has been open for 30 days with no activity. If there won't be any activity in the next 14 days, this issue will be closed automatically. |
Version
v6 (Beta)
What platforms are you having the problem on?
iOS
Architecture
Old architecture
What happened?
whenever I play the video after changing the template then it will play normally but most of the time it play multiple sounds of single video(like reverb)
Reproduction
Steps to reproduce this bug are:
listen whole video.
WhatsApp.Video.2024-03-04.at.4.49.19.PM.mp4
The text was updated successfully, but these errors were encountered: