videosdk-live / quickstart

A short and sweet tutorial for getting up to speed with VideoSDK in less than 10 minutes
https://docs.videosdk.live/
12 stars 3 forks source link

FATAL EXCEPTION: main #131

Closed chrome1235 closed 1 year ago

chrome1235 commented 1 year ago

I created this project, but I am getting this exception on a Android Phone. How can I solve this problem? Thanks for your help.

D/FlutterWebRTCPlugin( 6143): Create front camera Camera 1, Facing front, Orientation 270 succeeded I/org.webrtc.Logging( 6143): EglBase14Impl: Using OpenGL ES version 2 D/AndroidRuntime( 6143): Shutting down VM E/AndroidRuntime( 6143): FATAL EXCEPTION: main E/AndroidRuntime( 6143): Process: com.example.videosdk_flutter_quickstart, PID: 6143 E/AndroidRuntime( 6143): 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( 6143): at com.cloudwebrtc.webrtc.GetUserMediaImpl.getUserVideo(GetUserMediaImpl.java:730) E/AndroidRuntime( 6143): at com.cloudwebrtc.webrtc.GetUserMediaImpl.getUserMedia(GetUserMediaImpl.java:597) E/AndroidRuntime( 6143): at com.cloudwebrtc.webrtc.GetUserMediaImpl.access$000(GetUserMediaImpl.java:84) E/AndroidRuntime( 6143): at com.cloudwebrtc.webrtc.GetUserMediaImpl$1.invoke(GetUserMediaImpl.java:456) E/AndroidRuntime( 6143): at com.cloudwebrtc.webrtc.GetUserMediaImpl.lambda$requestPermissions$1(GetUserMediaImpl.java:849) E/AndroidRuntime( 6143): at com.cloudwebrtc.webrtc.GetUserMediaImpl$$ExternalSyntheticLambda0.invoke(Unknown Source:6) E/AndroidRuntime( 6143): at com.cloudwebrtc.webrtc.utils.PermissionUtils$1.onReceiveResult(PermissionUtils.java:115) E/AndroidRuntime( 6143): at android.os.ResultReceiver$MyRunnable.run(ResultReceiver.java:50) E/AndroidRuntime( 6143): at android.os.Handler.handleCallback(Handler.java:873) E/AndroidRuntime( 6143): at android.os.Handler.dispatchMessage(Handler.java:99) E/AndroidRuntime( 6143): at android.os.Looper.loop(Looper.java:207) E/AndroidRuntime( 6143): at android.app.ActivityThread.main(ActivityThread.java:6878) E/AndroidRuntime( 6143): at java.lang.reflect.Method.invoke(Native Method) E/AndroidRuntime( 6143): at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547) E/AndroidRuntime( 6143): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:876) I/Process ( 6143): Sending signal. PID: 6143 SIG: 9 Lost connection to device.

ishabodiwala commented 1 year ago

Hey @chrome1235, When you get this error ? Can you share re-producible steps for the same ?

chrome1235 commented 1 year ago

Thank you for your reply. Steps are: 1- Cloned from https://github.com/videosdk-live/quickstart/tree/main/flutter-rtc 2- flutter pub get 3- replaced token in api_call.dart with my token. // const token = ''; const token = "eyJhbGciOiJ.........."; 4- on main screen create meeting button. IMAGE 2023-06-30 18:13:38

5- On Last screen, about 3-4 seconds app is halted. IMAGE 2023-06-30 18:14:42

It gives that error.

Meanwhile I can see the the sessions in the dashboard (https://app.videosdk.live/meetings/sessions).

image

ishabodiwala commented 1 year ago

@chrome1235 , On which device are you testing? Can you also try using another Android device with android version 10 or higher?

chrome1235 commented 1 year ago

@chrome1235 , On which device are you testing? Can you also try using another Android device with android version 10 or higher? xiaomi, android version 9. i will try version 10. thanks for your information.

IMG_20230701_193554

chrome1235 commented 1 year ago

Hi ishabodiwala After your message, I deployed to another Xiomi phone (android version was 12). It worked without any problem. Is there any solution for android 9 version?

ishabodiwala commented 1 year ago

@chrome1235 , I am able to reproduce this error, and its look like it is related to specific android version. We will fixed that very soon, till then you can pass customTrack in VideoSDK.createRoom() and _room.enableCam() method to resolve this issue. like this :

 CustomTrack videoTrack = await VideoSDK.createCameraVideoTrack(
      encoderConfig: CustomVideoTrackConfig.h720p_w1280p,
      multiStream: false,
    );

VideoSDK.createRoom(
    //...
   customCameraVideoTrack: videoTrack, 
);
CustomTrack videoTrack = await VideoSDK.createCameraVideoTrack(
      encoderConfig: CustomVideoTrackConfig.h720p_w1280p,
      multiStream: false,
    );

_room.enableCam(videoTrack);

You can change value of encoderConfig and multiStream accroding to your requirement. Please refer followed documentation to know more about customTrack : https://docs.videosdk.live/flutter/guide/video-and-audio-calling-api-sdk/render-media/optimize-video-track

chrome1235 commented 1 year ago

@ishabodiwala It worked! Thanks for your support. I changed, meeting_screen.dart like this.

1)

  late final CustomTrack videoTrack;
  @override
  void initState() {
    // create room
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      videoTrack = await VideoSDK.createCameraVideoTrack(
        encoderConfig: CustomVideoTrackConfig.h720p_w1280p,
        multiStream: false,
      );
      _room = VideoSDK.createRoom(
        roomId: widget.meetingId,
        token: widget.token,
        displayName: "John Doe",
        micEnabled: micEnabled,
        camEnabled: camEnabled,
        defaultCameraIndex:
        1, // Index of MediaDevices will be used to set default camera
        customCameraVideoTrack: videoTrack,
      );
      setMeetingEventListener();
      // Join room
      _room.join();

    });
    super.initState();
  }

2)

      onToggleCameraButtonPressed: () {
        camEnabled ? _room.disableCam() : _room.enableCam(videoTrack);
        camEnabled = !camEnabled;
      },