react-native-twilio-video-webrtc icon indicating copy to clipboard operation
react-native-twilio-video-webrtc copied to clipboard

Video freeze after come back from background

Open Balasnest opened this issue 5 years ago • 10 comments

Steps to reproduce

  1. connect to room
  2. one participant in the room
  3. local video ON for a while (around 5-10 min ??)
  4. Go background, foreground, background, lock the device and come back to foreground
  5. after that got this error: ERROR:Twilio:[Platform](0x16b593000): Camera capture has been stopped. You should call stopCapture before cleaning up TVICameraSource resources to avoid seeing this error message in the future.

Expected behaviour

Local Camera should work still.

Actual behaviour

Local Camera failed to stream.

Balasnest avatar May 13 '20 20:05 Balasnest

I think, this should help for this fix.

- (void)dealloc {
  // We are done with camera
  if (self.camera) {
      [self.camera stopCapture];
      self.camera = nil;
  }
  
  // We are done with AVAudioSession
 //  [self stopAudioDevice];
}

Balasnest avatar May 13 '20 20:05 Balasnest

@slycoder Please look into this.

Balasnest avatar May 13 '20 20:05 Balasnest

Can you submit a PR?

slycoder avatar May 13 '20 20:05 slycoder

Sure. Will test and raise a PR.

Balasnest avatar May 13 '20 20:05 Balasnest

Cool, thanks for the contribution!

slycoder avatar May 13 '20 20:05 slycoder

how do you generate the access tokens

LiatheHNaj avatar May 21 '20 23:05 LiatheHNaj

@Balasnest Was the PR merged? I have the same issue.

nimeetshah0 avatar Jun 02 '20 09:06 nimeetshah0

@slycoder @nvme978 Please review this PR and merge.

Balasnest avatar Jun 07 '20 14:06 Balasnest

@Balasnest Thanks for the link. I managed to fix it by enabling/disabling the local video feed based on the app state. Used the setLocalVideoEnabled method.

nimeetshah0 avatar Jun 08 '20 04:06 nimeetshah0

I am facing same issue and after using the setLocalVideoEnabled it is working in Android but in iOS still not working. Local video view not showing after app coming from background to foreground. Below is the code sample.

React.useEffect(() => { if (!callEnded && twilioVideo) { const activeListener = appState.onActive(() => { twilioVideo.toggleLocalVideo(true); });

  const inactiveListener = appState.onInActive(() => {
    twilioVideo.toggleLocalVideo(false);
  });

  return () =>
    [activeListener, inactiveListener].forEach(unsubscribe =>
      unsubscribe(),
    );
}

}, [callEnded, twilioVideo]);

const toggleLocalVideo = React.useCallback( (nextState = !state.localVideoEnabled) => { return ref.current .setLocalVideoEnabled(nextState) .then(() => { dispatch({type: actionTypes.toggleLocalVideo}); }) .catch(error => { dispatch({type: actionTypes.toggleLocalVideoError, error}); }); }, [dispatch, state.localVideoEnabled], );

Package.json file

"react-native-twilio-video-webrtc": "https://github.com/blackuy/react-native-twilio-video-webrtc",

anjan-daffo88 avatar Jan 03 '24 11:01 anjan-daffo88