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

Stream freezes on mobile after disconnecting and connecting back again #135

Open mmubasher opened 5 years ago

mmubasher commented 5 years ago

Bug Report

Current behavior Upon disconnection of any of the clients ( Browser and Mobile) in a 1-to-1 call, when the session is re-established, video call freezes while audio from both sides can be heard. Moreover, the native view of video streams gets stuck and stays on screen unless app is killed. On some occasions, app crashed itself too after a few seconds

Steps to reproduce Setup a call between two parties ( Web and Mobile preferred ) then disconnect from web application i.e. close the browser tab or window. Reopen and connect using the same Session Id and wait for connection to establish. If video freeze does not happens in first go you can test it with multiple

Example Project A sample project that uses the same code has been setup here opentok_ionic

Relevant bug reported earlier

Cannot read property 'connectionId' of undefined #221

What is the current bug behavior?

Upon disconnection of any of the clients in a 1-to-1 call, when the session is re-established, video call freezes while audio from both sides can be heard. Moreover, native view of video stays on screen unless app is killed

What is the expected correct behavior?

After disconnection from any of the sides, connecting again should work

Relevant logs and/or screenshots

Chrome adb Inspect tool logs from console (Note: This log is from 3 trials of connection and disconnection)
domId exists but properties width or height is not specified
opentok.js:520  width: 320 and height: 0 for domId publisher, and top: 149, left: 20
opentok.js:317 JS Lib: creating publisher -  {}
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:518 domId exists but properties width or height is not specified
opentok.js:520  width: 264 and height: 198 for domId publisher, and top: 149, left: 20
opentok.js:317 JS Lib: creating publisher -  {}
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:317 JS Lib: Session is already publishing -  {}
opentok.js:621 stream, domId, props
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:621 stream, domId, props
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:621 stream, domId, props
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: F586B052-E9F1-4AEB-BBA7-166782EF0696
cordova.b8b05ba265b9ff1d69c8.js:1 Error in Success callbackId: OpenTokPlugin1018099018 : TypeError: Cannot read property 'sessionConnected' of undefined
cordova.b8b05ba265b9ff1d69c8.js:1 Uncaught TypeError: Cannot read property 'sessionConnected' of undefined
    at TBPublisher.streamCreated (opentok.js:401)
    at TBPublisher.streamCreated (opentok.js:942)
    at TBPublisher.eventReceived (opentok.js:396)
    at opentok.js:942
    at Object.callbackFromNative (cordova.b8b05ba265b9ff1d69c8.js:1)
    at <anonymous>:1:9
TBPublisher.streamCreated @ opentok.js:401
(anonymous) @ opentok.js:942
TBPublisher.eventReceived @ opentok.js:396
(anonymous) @ opentok.js:942
callbackFromNative @ cordova.b8b05ba265b9ff1d69c8.js:1
(anonymous) @ VM761:1
cordova.b8b05ba265b9ff1d69c8.js:1 Error in Success callbackId: OpenTokPlugin1018099029 : TypeError: this[response.eventType] is not a function
cordova.b8b05ba265b9ff1d69c8.js:1 Uncaught TypeError: this[response.eventType] is not a function
    at TBSubscriber.eventReceived (opentok.js:1062)
    at opentok.js:942
    at Object.callbackFromNative (cordova.b8b05ba265b9ff1d69c8.js:1)
    at <anonymous>:1:9
TBSubscriber.eventReceived @ opentok.js:1062
(anonymous) @ opentok.js:942
callbackFromNative @ cordova.b8b05ba265b9ff1d69c8.js:1
(anonymous) @ VM1283:1
cordova.b8b05ba265b9ff1d69c8.js:1 Error in Success callbackId: OpenTokPlugin1018099029 : TypeError: this[response.eventType] is not a function
cordova.b8b05ba265b9ff1d69c8.js:1 Uncaught TypeError: this[response.eventType] is not a function
    at TBSubscriber.eventReceived (opentok.js:1062)
    at opentok.js:942
    at Object.callbackFromNative (cordova.b8b05ba265b9ff1d69c8.js:1)
    at <anonymous>:1:9
TBSubscriber.eventReceived @ opentok.js:1062
(anonymous) @ opentok.js:942
callbackFromNative @ cordova.b8b05ba265b9ff1d69c8.js:1
(anonymous) @ VM1674:1
169.778c078f33008a7fc063.js:1 Call has ended
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: F586B052-E9F1-4AEB-BBA7-166782EF0696
opentok.js:671 JS: Unpublish
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: F586B052-E9F1-4AEB-BBA7-166782EF0696
opentok.js:682 JS: Unsubscribe
opentok.js:685 JS: Unsubscribing
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
main.e79d1417918fdbd98d9b.js:1 User left:  {hostId: "http://localhost:8080", userId: "PERSONNEL--d011d36a-3555-4972-a944-ae2b9bfcc567", clinicalExchangeId: "CLINICAL_EXCHANGE--5894b762-f5c2-4a3e-81e0-e6bbb14ba00a"}
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
2opentok.js:230 Error:  Only the original thread that created a view hierarchy can touch its views.
cordova.b8b05ba265b9ff1d69c8.js:1 Error in Success callbackId: OpenTokPlugin1018099009 : TypeError: Cannot read property 'connectionId' of undefined
cordova.b8b05ba265b9ff1d69c8.js:1 Uncaught TypeError: Cannot read property 'connectionId' of undefined
    at TBSession.connectionDestroyed (opentok.js:779)
    at TBSession.connectionDestroyed (opentok.js:942)
    at TBSession.eventReceived (opentok.js:759)
    at opentok.js:942
    at Object.callbackFromNative (cordova.b8b05ba265b9ff1d69c8.js:1)
    at <anonymous>:1:9
TBSession.connectionDestroyed @ opentok.js:779
(anonymous) @ opentok.js:942
TBSession.eventReceived @ opentok.js:759
(anonymous) @ opentok.js:942
callbackFromNative @ cordova.b8b05ba265b9ff1d69c8.js:1
(anonymous) @ VM1999:1
169.778c078f33008a7fc063.js:1 Stream  ended because clientDisconnected
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
169.778c078f33008a7fc063.js:1 Uncaught TypeError: Cannot read property 'name' of undefined
    at streamDestroyed (169.778c078f33008a7fc063.js:1)
    at opentok.js:2273
    at handleMessage (opentok.js:2166)
streamDestroyed @ 169.778c078f33008a7fc063.js:1
(anonymous) @ opentok.js:2273
handleMessage @ opentok.js:2166
postMessage (async)
OTHelpers.callAsync @ opentok.js:2191
(anonymous) @ opentok.js:2269
OTHelpers.forEach @ opentok.js:1207
executeListenersAsyncronously @ opentok.js:2262
self.dispatchEvent @ opentok.js:2395
TBSession.streamDestroyed @ opentok.js:831
(anonymous) @ opentok.js:942
TBSession.eventReceived @ opentok.js:759
(anonymous) @ opentok.js:942
callbackFromNative @ cordova.b8b05ba265b9ff1d69c8.js:1
processMessage @ cordova.b8b05ba265b9ff1d69c8.js:1
processMessages @ cordova.b8b05ba265b9ff1d69c8.js:1
e.invoke @ polyfills.74b0d4fa927f69a53a28.js:1
onInvoke @ main.e79d1417918fdbd98d9b.js:1
e.invoke @ polyfills.74b0d4fa927f69a53a28.js:1
t.run @ polyfills.74b0d4fa927f69a53a28.js:1
(anonymous) @ polyfills.74b0d4fa927f69a53a28.js:1
e.invokeTask @ polyfills.74b0d4fa927f69a53a28.js:1
onInvokeTask @ main.e79d1417918fdbd98d9b.js:1
e.invokeTask @ polyfills.74b0d4fa927f69a53a28.js:1
t.runTask @ polyfills.74b0d4fa927f69a53a28.js:1
d @ polyfills.74b0d4fa927f69a53a28.js:1
t.invokeTask @ polyfills.74b0d4fa927f69a53a28.js:1
_ @ polyfills.74b0d4fa927f69a53a28.js:1
m @ polyfills.74b0d4fa927f69a53a28.js:1
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: f7088a33-a0cc-4f4a-85e8-607b7d640762
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:248 JS: Objects being updated in TBUpdateObjects
169.778c078f33008a7fc063.js:1 Stream  ended because clientDisconnected
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:248 JS: Objects being updated in TBUpdateObjects
169.778c078f33008a7fc063.js:1 Call has started
main.e79d1417918fdbd98d9b.js:1 User joined:  {hostId: "http://localhost:8080", userId: "PERSONNEL--d011d36a-3555-4972-a944-ae2b9bfcc567", sessionId: "1_MX40NjA5OTM5Mn5-MTU0NDM3MTY5Mjk4NX5EZmNxWU9UV1lDdUNEUWdPSEk4ZDJNRFJ-fg", clinicalExchangeId: "CLINICAL_EXCHANGE--5894b762-f5c2-4a3e-81e0-e6bbb14ba00a"}
169.778c078f33008a7fc063.js:1 Call has started
main.e79d1417918fdbd98d9b.js:1 Session status update:  {status: "INITIALIZING", hostId: "http://localhost:8080", clinicalExchangeId: "CLINICAL_EXCHANGE--5894b762-f5c2-4a3e-81e0-e6bbb14ba00a"}
main.e79d1417918fdbd98d9b.js:1 Session status update:  {status: "IN_PROGRESS", hostId: "http://localhost:8080", clinicalExchangeId: "CLINICAL_EXCHANGE--5894b762-f5c2-4a3e-81e0-e6bbb14ba00a"}
opentok.js:518 domId exists but properties width or height is not specified
opentok.js:520  width: 320 and height: 328 for domId publisher, and top: 149, left: 20
opentok.js:317 JS Lib: creating publisher -  {}
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:518 domId exists but properties width or height is not specified
opentok.js:520  width: 320 and height: 328 for domId publisher, and top: 149, left: 20
opentok.js:317 JS Lib: creating publisher -  {}
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:317 JS Lib: Session is already publishing -  {}
opentok.js:621 stream, domId, props
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
opentok.js:621 stream, domId, props
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
cordova.b8b05ba265b9ff1d69c8.js:1 Error in Success callbackId: OpenTokPlugin1018099054 : TypeError: Cannot read property 'connectionId' of undefined
polyfills.74b0d4fa927f69a53a28.js:1 Unhandled Promise rejection: Cannot read property 'connectionId' of undefined ; Zone: <root> ; Task: Promise.then ; Value: TypeError: Cannot read property 'connectionId' of undefined
    at TBSession.connectionDestroyed (opentok.js:779)
    at TBSession.connectionDestroyed (opentok.js:942)
    at TBSession.eventReceived (opentok.js:759)
    at opentok.js:942
    at Object.callbackFromNative (cordova.b8b05ba265b9ff1d69c8.js:1)
    at processMessage (cordova.b8b05ba265b9ff1d69c8.js:1)
    at processMessages (cordova.b8b05ba265b9ff1d69c8.js:1)
    at e.invoke (polyfills.74b0d4fa927f69a53a28.js:1)
    at t.run (polyfills.74b0d4fa927f69a53a28.js:1)
    at polyfills.74b0d4fa927f69a53a28.js:1 TypeError: Cannot read property 'connectionId' of undefined
    at TBSession.connectionDestroyed (http://localhost:8080/opentok.js:779:40)
    at TBSession.connectionDestroyed (http://localhost:8080/opentok.js:942:59)
    at TBSession.eventReceived (http://localhost:8080/opentok.js:759:36)
    at http://localhost:8080/opentok.js:942:59
    at Object.callbackFromNative (http://localhost:8080/cordova.b8b05ba265b9ff1d69c8.js:1:3352)
    at processMessage (http://localhost:8080/cordova.b8b05ba265b9ff1d69c8.js:1:12098)
    at processMessages (http://localhost:8080/cordova.b8b05ba265b9ff1d69c8.js:1:12446)
    at e.invoke (http://localhost:8080/polyfills.74b0d4fa927f69a53a28.js:1:7278)
    at t.run (http://localhost:8080/polyfills.74b0d4fa927f69a53a28.js:1:2455)
    at http://localhost:8080/polyfills.74b0d4fa927f69a53a28.js:1:13702
n.onUnhandledError @ polyfills.74b0d4fa927f69a53a28.js:1
f @ polyfills.74b0d4fa927f69a53a28.js:1
e @ polyfills.74b0d4fa927f69a53a28.js:1
n.microtaskDrainDone @ polyfills.74b0d4fa927f69a53a28.js:1
d @ polyfills.74b0d4fa927f69a53a28.js:1
Promise.then (async)
v @ polyfills.74b0d4fa927f69a53a28.js:1
e.scheduleTask @ polyfills.74b0d4fa927f69a53a28.js:1
t.scheduleTask @ polyfills.74b0d4fa927f69a53a28.js:1
t.scheduleMicroTask @ polyfills.74b0d4fa927f69a53a28.js:1
z @ polyfills.74b0d4fa927f69a53a28.js:1
e.then @ polyfills.74b0d4fa927f69a53a28.js:1
nextTick @ cordova.b8b05ba265b9ff1d69c8.js:1
androidExec @ cordova.b8b05ba265b9ff1d69c8.js:1
TBSubscriber @ opentok.js:1057
TBSession.subscribe @ opentok.js:622
streamCreated @ 169.778c078f33008a7fc063.js:1
(anonymous) @ opentok.js:2273
handleMessage @ opentok.js:2166
postMessage (async)
OTHelpers.callAsync @ opentok.js:2191
(anonymous) @ opentok.js:2269
OTHelpers.forEach @ opentok.js:1207
executeListenersAsyncronously @ opentok.js:2262
self.dispatchEvent @ opentok.js:2395
TBSession.streamCreated @ opentok.js:821
(anonymous) @ opentok.js:942
TBSession.eventReceived @ opentok.js:759
(anonymous) @ opentok.js:942
callbackFromNative @ cordova.b8b05ba265b9ff1d69c8.js:1
(anonymous) @ VM2020:1
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
cordova.b8b05ba265b9ff1d69c8.js:1 Error in Success callbackId: OpenTokPlugin1018099063 : TypeError: Cannot read property 'sessionConnected' of undefined
cordova.b8b05ba265b9ff1d69c8.js:1 Uncaught TypeError: Cannot read property 'sessionConnected' of undefined
    at TBPublisher.streamCreated (opentok.js:401)
    at TBPublisher.streamCreated (opentok.js:942)
    at TBPublisher.eventReceived (opentok.js:396)
    at opentok.js:942
    at Object.callbackFromNative (cordova.b8b05ba265b9ff1d69c8.js:1)
    at <anonymous>:1:9
TBPublisher.streamCreated @ opentok.js:401
(anonymous) @ opentok.js:942
TBPublisher.eventReceived @ opentok.js:396
(anonymous) @ opentok.js:942
callbackFromNative @ cordova.b8b05ba265b9ff1d69c8.js:1
(anonymous) @ VM2033:1
opentok.js:621 stream, domId, props
opentok.js:248 JS: Objects being updated in TBUpdateObjects
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: TBPublisher
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 9afc7ab0-c7c0-4818-9878-586ba95151e3
opentok.js:253 JS: Object updated
opentok.js:255 JS sessionId: 22B8C75C-2472-429E-A955-A7722CB7CA84
cordova.b8b05ba265b9ff1d69c8.js:1 Error in Success callbackId: OpenTokPlugin1018099080 : TypeError: this[response.eventType] is not a function
cordova.b8b05ba265b9ff1d69c8.js:1 Uncaught TypeError: this[response.eventType] is not a function
    at TBSubscriber.eventReceived (opentok.js:1062)
    at opentok.js:942
    at Object.callbackFromNative (cordova.b8b05ba265b9ff1d69c8.js:1)
    at <anonymous>:1:9
TBSubscriber.eventReceived @ opentok.js:1062
(anonymous) @ opentok.js:942
callbackFromNative @ cordova.b8b05ba265b9ff1d69c8.js:1
(anonymous) @ VM3218:1
cordova.b8b05ba265b9ff1d69c8.js:1 Error in Success callbackId: OpenTokPlugin1018099080 : TypeError: this[response.eventType] is not a function
cordova.b8b05ba265b9ff1d69c8.js:1 Uncaught TypeError: this[response.eventType] is not a function
    at TBSubscriber.eventReceived (opentok.js:1062)
    at opentok.js:942
    at Object.callbackFromNative (cordova.b8b05ba265b9ff1d69c8.js:1)
    at <anonymous>:1:9
Application crash logs
Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String com.opentok.android.Connection.getConnectionId()' on a null object reference
       at com.tokbox.cordova.OpenTokAndroidPlugin.onConnected(OpenTokAndroidPlugin.java:725)
       at com.opentok.android.Session.onConnected(Session.java:1477)
       at com.opentok.android.Session$3.run(Session.java:1461)
       at android.os.Handler.handleCallback(Handler.java:809)
       at android.os.Handler.dispatchMessage(Handler.java:102)
       at android.os.Looper.loop(Looper.java:166)
       at android.app.ActivityThread.main(ActivityThread.java:7555)
       at java.lang.reflect.Method.invoke(Method.java)
       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:469)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:963)
msach22 commented 5 years ago

@mmubasher We had some issues with reconnection in our native SDKs that have now been patched. Could you please check out the latest release (v3.4.2) of the plugin and see if this is still happening for you?

unixlabs commented 5 years ago

@mmubasher we have test again for you its release (v3.4.2) working, can you trace the max_fails/fail_timeout parameters of the server