blackuy / react-native-twilio-video-webrtc

Twilio Video (WebRTC) for React Native
https://www.twilio.com/docs/video
MIT License
608 stars 404 forks source link

Connect not working on Android #599

Closed vikrambombhi closed 2 years ago

vikrambombhi commented 2 years ago

Steps to reproduce

  1. Follow installation steps from README
  2. Copy paste example
  3. Call twilioRef.current.connect using a valid auth token
  4. Notice nothing happens...

Expected behaviour

Expect to see onRoomDidConnect, onRoomDidDisconnect, or onRoomDidFailToConnect get called

Actual behaviour

Seems like nothing happens. The connect either fail silently or doesn't even try to connect for some reason.

Extra information

Everything works on iOS. Seems like this might be a permissions issue as stated in #575 but not sure what the missing permission is.

Environment

react-native-twilio-video-webrtc

Version: master

vikrambombhi commented 2 years ago

Doing my debugging and I noticed this exception when trying to connect

03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue: Unhandled SoftException
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue: com.facebook.react.bridge.NoSuchKeyException: enableH264Codec
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:110)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.bridge.ReadableNativeMap.getValue(ReadableNativeMap.java:114)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.bridge.ReadableNativeMap.getBoolean(ReadableNativeMap.java:146)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.twiliorn.library.CustomTwilioVideoViewManager.receiveCommand(CustomTwilioVideoViewManager.java:88)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.twiliorn.library.CustomTwilioVideoViewManager.receiveCommand(CustomTwilioVideoViewManager.java:46)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.uimanager.NativeViewHierarchyManager.dispatchCommand(NativeViewHierarchyManager.java:839)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.uimanager.UIViewOperationQueue$DispatchCommandOperation.executeWithExceptions(UIViewOperationQueue.java:317)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.uimanager.UIViewOperationQueue$1.run(UIViewOperationQueue.java:873)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.uimanager.UIViewOperationQueue.flushPendingBatches(UIViewOperationQueue.java:1019)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.uimanager.UIViewOperationQueue.access$2600(UIViewOperationQueue.java:47)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.uimanager.UIViewOperationQueue$DispatchUIFrameCallback.doFrameGuarded(UIViewOperationQueue.java:1079)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.uimanager.GuardedFrameCallback.doFrame(GuardedFrameCallback.java:29)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.modules.core.ReactChoreographer$ReactChoreographerDispatcher.doFrame(ReactChoreographer.java:175)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.facebook.react.modules.core.ChoreographerCompat$FrameCallback$1.doFrame(ChoreographerCompat.java:85)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1350)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at android.view.Choreographer.doCallbacks(Choreographer.java:1149)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at android.view.Choreographer.doFrame(Choreographer.java:1040)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:1333)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at android.os.Handler.handleCallback(Handler.java:938)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at android.os.Handler.dispatchMessage(Handler.java:99)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at android.os.Looper.loop(Looper.java:233)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at android.app.ActivityThread.main(ActivityThread.java:8010)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at java.lang.reflect.Method.invoke(Native Method)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
03-17 13:32:52.171  8626  8626 E unknown:UIViewOperationQueue:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
brycnguyen commented 2 years ago

This might be my fault in: https://github.com/blackuy/react-native-twilio-video-webrtc/commit/052e4ae25efe28dd0705021856e999850ba00a62#diff-a456c988491149502324a709b0c4bbe9b279a5c97c61793482c643238d26825fR88.

It's probably trying to get enableH264Codec in the Map but it does not exist. Let me see if I can get a fix going.

brycnguyen commented 2 years ago

@vikrambombhi, I've made a fix that works in my testing, and also noted a workaround that might work in the PR linked: https://github.com/blackuy/react-native-twilio-video-webrtc/pull/601

vikrambombhi commented 2 years ago

Passing enableH264Codec worked for me!

vikrambombhi commented 2 years ago

Going to close this issue now but I'm curious if there is any reason to enable or disable h246? I can see in your PR #601 that you are defaulting to disabling it

brycnguyen commented 2 years ago

@vikrambombhi, enabling H264* does not work on all devices which do not have hardware support. By default, twilio recommends using VP8 which is supported on all android devices. If you do intend to enable it, I would make sure to handle it properly by ensuring all participants connecting share the same codec, or you could end up in a case where a user cannot subscribe to the video tracks of the other participants.

brycnguyen commented 2 years ago

More information on codec negotiation here: https://www.twilio.com/docs/video/managing-codecs

Sort of disappointing that twilio doesn't handle codec negotiation per the SFU in a group set up if one user does not have support. It just seems to take the codec used by the first user connected to the room.

I imagine most of the issues reported in this library regarding video of other participants not showing up are all related to codec negotiation.

slycoder commented 2 years ago

Thanks for the explanation @brycnguyen . Your PR is now on master.