react-native-twilio-video-webrtc
react-native-twilio-video-webrtc copied to clipboard
Video freeze after come back from background
Steps to reproduce
- connect to room
- one participant in the room
- local video ON for a while (around 5-10 min ??)
- Go background, foreground, background, lock the device and come back to foreground
- after that got this error:
ERROR:Twilio:[Platform](0x16b593000): Camera capture has been stopped. You should callstopCapturebefore 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.
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];
}
@slycoder Please look into this.
Can you submit a PR?
Sure. Will test and raise a PR.
Cool, thanks for the contribution!
how do you generate the access tokens
@Balasnest Was the PR merged? I have the same issue.
@slycoder @nvme978 Please review this PR and merge.
@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.
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",