react-native-twilio-video-webrtc
react-native-twilio-video-webrtc copied to clipboard
Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference
Steps to reproduce
- Add
twilioRef.current.disconnect();
function in component unmount - Navigate back to unmount the component
Expected behaviour
Disconnect function should work properly
Actual behaviour
- Call is not disconnected and app crashes with following message in android
- App does not crash in iOS but the call is not disconnected
Environment
- React Native version: 0.64.1
- React Native platform: Android and iOS
react-native-twilio-video-webrtc
Version: "master"
Sample code:
React.useEffect(() => {
const twilioVideoCurrentRef = twilioVideo.current;
return () => {
twilioVideoCurrentRef?.disconnect();
};
}, []);
That's a really odd error! I have two guesses:
1.) The only place we use doubles are in the stats callback. Is it possible that there are outstanding calls to getStats that return after the component has been unmounted?
2.) Is it possible that during the cleanup phase, the component has already been unmounted? (I noticed that you saved the ref above so that it would disappear under you during the cleanup). I had always implemented disconnect by having a dedicated button which when pressed, calls the disconnect
function explicitly and then navigates away.
For who replicated this issue and do use react-navigation in the project, you can set the code like this:
import { useFocusEffect } from '@react-navigation/native';
//...
useFocusEffect(
React.useCallback(() => {
return () => {
twilioVideo.current?.disconnect?.();
};
}, []),
);
@ayush-shta I am facing the same issue, Did you find solution?