atyenoria / react-native-webrtc-janus-gateway

Video conference system for mobile application. Base technology is react-native-webrtc + Janus Webrtc Gateway
https://github.com/atyenoria/react-native-janus-gateway-webrtc-video-chat
194 stars 77 forks source link

WebRTCModule/GetUserMediaImpl.java videoConstraintsMandatory : Null pointer exception #3

Closed saket424 closed 6 years ago

saket424 commented 6 years ago

@atyenoria , I encountered a null pointer exception when I tried to run the Android sample with videoConstraintsMandatory in react-native-janus-gateway-webrtc-video-chat/node_modules/react-native-webrtc/android/src/main/java/com/oney/WebRTCModule/GetUserMediaImpl.java

When I changed the code from

        // Fall back to defaults if keys are missing.
        int width
                = videoConstraintsMandatory.hasKey("minWidth")
                ? videoConstraintsMandatory.getInt("minWidth")
                : DEFAULT_WIDTH;
        int height
                = videoConstraintsMandatory.hasKey("minHeight")
                ? videoConstraintsMandatory.getInt("minHeight")
                : DEFAULT_HEIGHT;
        int fps
                = videoConstraintsMandatory.hasKey("minFrameRate")
                ? videoConstraintsMandatory.getInt("minFrameRate")
                : DEFAULT_FPS;

to this instead

    int width, height, fps;
    // Fall back to defaults if keys are missing.
    if (videoConstraintsMandatory != null) {
         width
                = videoConstraintsMandatory.hasKey("minWidth")
                ? videoConstraintsMandatory.getInt("minWidth")
                : DEFAULT_WIDTH;
        height
                = videoConstraintsMandatory.hasKey("minHeight")
                ? videoConstraintsMandatory.getInt("minHeight")
                : DEFAULT_HEIGHT;
        fps
                = videoConstraintsMandatory.hasKey("minFrameRate")
                ? videoConstraintsMandatory.getInt("minFrameRate")
                : DEFAULT_FPS;
    } else {
        width = DEFAULT_WIDTH;
        height = DEFAULT_HEIGHT;
        fps = DEFAULT_FPS;
    }

then the react-native-janus-gateway-webrtc-video-chat VideoRoom sample worked. Did you encounter a similar issue and if yes, what is the proposed work around? I know you state that android is still a work in progress but I was impatient and wanted to give it a whirl

Thanks

atyenoria commented 6 years ago

Thanks for creating the issue. @saket424 I could't start InCallManager.start({ media: 'audio' }) with react-native-incall manager. Other part works. But, I am not familiar with the error you raised above. Are you trying this in real Android device? I used the Android Studio emulator when I came across the problem.

saket424 commented 6 years ago

Yes I tried on a real Android device

reedspool commented 6 years ago

+1 Had same issue (though it occurred for me on Android Studio emulator), @saket424's solution worked for me as well

atyenoria commented 6 years ago

@caseygbigelow Nice! That patch seems to prevent app from crashing!!