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

Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference

Open ayush-shta opened this issue 3 years ago • 3 comments

Steps to reproduce

  1. Add twilioRef.current.disconnect(); function in component unmount
  2. 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 Screenshot_1629472730
  • 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();
    };
  }, []);

ayush-shta avatar Aug 20 '21 15:08 ayush-shta

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.

slycoder avatar Aug 21 '21 15:08 slycoder

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?.();
      };
    }, []),
);

bdtren avatar Nov 10 '22 13:11 bdtren

@ayush-shta I am facing the same issue, Did you find solution?

deepanshucse avatar Aug 30 '23 13:08 deepanshucse