blackuy / react-native-twilio-video-webrtc

Twilio Video (WebRTC) for React Native
https://www.twilio.com/docs/video
MIT License
609 stars 404 forks source link

Video Freeze on iOS 15 after come back from Background #589

Open hendrytb opened 2 years ago

hendrytb commented 2 years ago

Steps to reproduce

  1. Follow the installation steps that mentioned here => https://github.com/blackuy/react-native-twilio-video-webrtc
  2. Create sample App (follow the Usage sample code mentioned here => https://github.com/blackuy/react-native-twilio-video-webrtc
  3. Initiate the call on iOS
  4. While the App is still opened, put it to the Background, or you can press the power button to put the App to the Background
  5. Go back to the app

Expected behaviour

The local video should start & continue to stream.

Actual behaviour

The local video is freeze and failed to stream, this is an intermittent problem, but happens frequently.

Here are the error logs from my XCode:

ERROR:Twilio:Platform: Fatal runtime capture error: Error Domain=com.twilio.video.capturer.camera Code=1000 "Capture session already setup." UserInfo={NSLocalizedFailureReason=Capture session already setup.}, code 1000

AVAudioSession setAggregatedIOPreference:error: Error Domain=NSOSStatusErrorDomain Code=560030580 "(null)"

AVAudioSession_iOS.mm:1243 Deactivating an audio session that has running I/O. All I/O should be stopped or paused prior to deactivating the audio session.

Environment

react-native-twilio-video-webrtc

Version: yarn version (react-native-twilio-video-webrtc 2.1.0)

brycnguyen commented 2 years ago

I'm facing this same issue.

slycoder commented 2 years ago

That's weird. Do you happen to know if any of the components are being unmounted/mounted or any other lifecycle events?

brycnguyen commented 2 years ago

@slycoder Let me check this. Our app does switch the current screen because we display a privacy screen when the app is backgrounded.

brycnguyen commented 2 years ago

Odd, I was able to resolve my camera issue because I was using more than one camera. After removing the first camera (we use this as a preview camera before joining the room), the video restarts again with no issues. The audio does not come back however. I'm also using this in conjunction with react-native-callkeep to display the UI at the top, not sure if that's the reason why it also works.

brycnguyen commented 2 years ago

Looks like I figured out the audio issue as well. I have a video player that uses audio that probably causes an issue when coming back to the app.

anjan-daffo88 commented 11 months ago

I am also facing same issue, I have tried to call the setLocalVideoEnabled(true) when app coming in foreground and setLocalVideoEnabled(false) when going to background. This changes worked in Android but not working in iOS.

Please help anyone have any solution. Our production app release getting delay due to this.