opentok / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
MIT License
30 stars 80 forks source link

App crash on Android sessionDisconnected #211

Open asaf-interator opened 2 years ago

asaf-interator commented 2 years ago

Bug Report

Current behavior App crash on Android sessionDisconnected

Steps to reproduce

Create a video call between two devices and after it's initiates one device terminates the call

What is the current bug behavior? We're able to have a video call between two devices and when one of the devices ends the call the app crash sometimes on Android devices

What is the expected correct behavior? Call is disconnected and app continue to work normally

Relevant logs and/or screenshots 2021-12-22 13:23:17.683 15462-18346/? E/AndroidRuntime: FATAL EXCEPTION: JavaBridge Process: PID: 15462 android.view.ViewRootImpl$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views. at android.view.ViewRootImpl.checkThread(ViewRootImpl.java:9425) at android.view.ViewRootImpl.requestLayout(ViewRootImpl.java:1769) at android.view.View.requestLayout(View.java:25595) at android.view.View.requestLayout(View.java:25595) at android.view.View.requestLayout(View.java:25595) at android.view.View.requestLayout(View.java:25595) at android.view.View.requestLayout(View.java:25595) at android.view.ViewGroup.removeView(ViewGroup.java:5488) at com.tokbox.cordova.OpenTokAndroidPlugin$RunnablePublisher.destroyPublisher(OpenTokAndroidPlugin.java:262) at com.tokbox.cordova.OpenTokAndroidPlugin.onDisconnected(OpenTokAndroidPlugin.java:746) at com.opentok.android.Session.e(Unknown Source:4) at com.opentok.android.Session.lambda$_BO8aFRZOCxxkew6Gy77xEyyaHo(Unknown Source:0) at com.opentok.android.-$$Lambda$Session$_BO8aFRZOCxxkew6Gy77xEyyaHo.run(Unknown Source:2) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:233) at android.os.HandlerThread.run(HandlerThread.java:67)

mishraabinash729 commented 2 years ago

I also got the same above error

Solution

Try to use below plugin

cordova plugin remove cordova-plugin-opentok

cordova plugin add napa-cordova-plugin-opentok

It'll resolve the issue

asaf-interator commented 2 years ago

@mishraabinash729 Hi, thanks, but I still have the issue after installing napa-cordova-plugin-opentok

maxwell09 commented 1 year ago

Hi, a bit late but this is solved in talkspiritlab/cordova-plugin-opentok, checkOpenTokAndroidPlugin.java

Basically, they added this function in RunnableUpdateViews:

public void removeView() { cordova.getActivity().runOnUiThread(new Runnable() { @Override public void run() { ViewGroup parent = (ViewGroup) webView.getView().getParent(); parent.removeView(mView); } }); }

And replaced these:

ViewGroup parent = (ViewGroup) webView.getView().getParent(); parent.removeView(this.mView);

With this:

this.removeView();