videosdk-live / videosdk-rtc-flutter-sdk-example

WebRTC based video conferencing SDK for Flutter (Android / iOS)
https://docs.videosdk.live/flutter/guide/video-and-audio-calling-api-sdk/getting-started
82 stars 30 forks source link

[Android] NullPointerException when initializing VideoCapturer on Xiaomi/Redmi devices running Android < 9.0 #46

Closed huantd0111 closed 1 year ago

huantd0111 commented 1 year ago

Description: I've been working on integrating the Video SDK into a Flutter project, and overall, the implementation works fine on most devices. However, I encountered an exception specifically on Xiaomi/Redmi devices running Android versions earlier than 9.0. The exception trace is as follows:

E/AndroidRuntime(30301): java.lang.NullPointerException: Attempt to invoke interface method 'void org.webrtc.VideoCapturer.initialize(org.webrtc.SurfaceTextureHelper, android.content.Context, org.webrtc.CapturerObserver)' on a null object reference E/AndroidRuntime(30301): at com.cloudwebrtc.webrtc.GetUserMediaImpl.getUserVideo(GetUserMediaImpl.java:730) E/AndroidRuntime(30301): at com.cloudwebrtc.webrtc.GetUserMediaImpl.getUserMedia(GetUserMediaImpl.java:597) E/AndroidRuntime(30301): at com.cloudwebrtc.webrtc.GetUserMediaImpl.access$000(GetUserMediaImpl.java:84) E/AndroidRuntime(30301): at com.cloudwebrtc.webrtc.GetUserMediaImpl$1.invoke(GetUserMediaImpl.java:456) E/AndroidRuntime(30301): at com.cloudwebrtc.webrtc.GetUserMediaImpl.lambda$requestPermissions$1(GetUserMediaImpl.java:849) E/AndroidRuntime(30301): at com.cloudwebrtc.webrtc.GetUserMediaImpl$$ExternalSyntheticLambda0.invoke(Unknown Source:6) E/AndroidRuntime(30301): at com.cloudwebrtc.webrtc.utils.PermissionUtils$1.onReceiveResult(PermissionUtils.java:115) E/AndroidRuntime(30301): at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:50) E/AndroidRuntime(30301): at android.os.Handler.handleCallback(Handler.java:873) E/AndroidRuntime(30301): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime(30301): at android.os.Looper.loop(Looper.java:201) E/AndroidRuntime(30301): at android.app.ActivityThread.main(ActivityThread.java:6810) E/AndroidRuntime(30301): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime(30301): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) E/AndroidRuntime(30301): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873) I/Process (30301): Sending signal. PID: 30301 SIG: 9

Additional Observations: The issue seems to be specific to Xiaomi/Redmi devices running Android versions earlier than 9.0. I have followed the instructions in this link to address the problem, but the error still persists on other devices. Additionally, on Xiaomi devices, switching the camera also does not function as expected.

Devices Affected:

Expected Behavior: The Video SDK should work consistently across various Android devices, including Xiaomi/Redmi models with Android versions earlier than 9.0. Switching the camera should also function properly on all supported devices.

Steps to Reproduce:

  1. Install the app on Xiaomi/Redmi devices with Android < 9.0.
  2. Attempt to use the Video SDK functionalities, such as starting a video call or switching the camera.

Possible Solution: As I investigated further, it appears that the issue might be related to how the VideoCapturer is initialized on these specific devices. I would appreciate any guidance, insights, or potential fixes from the community to resolve this problem.

Thank you for your assistance!

ishabodiwala commented 1 year ago

Hey @huantd0111, we resolve this issue in latest version. Please update SDK version to 1.1.4