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

Crash on iOS10 #94

Closed amatakasap closed 6 years ago

amatakasap commented 6 years ago

Bug Report

Current behavior Application will crash on iOS 10 when re-making call after disconnecting call.

Steps to reproduce

  1. Connect to the opentok session with two smartphones https://github.com/opentok/opentok-cordova-samples/tree/master/Basic-Video-Chat
  2. When the image is displayed, execute session.disconnect () on the iOS 10 iPhone to disconnect the call.
  3. Application crash when calling OT.initSession () again on iOS 10 which executed session.disconnect ()

What is the expected correct behavior?

- (void)session:(OTSession*)mySession streamCreated:(OTStream*)stream{

It is because the observer added by the above streamDictionary method is not remove.

#93

Relevant logs and/or screenshots

streamDictionary = [[NSMutableDictionary alloc] init];

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x174284920 of class OTStream was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x1744208e0> ( <NSKeyValueObservance 0x1702530e0: Observer: 0x1700fa480, Key path: hasAudio, Options: <New: YES, Old: YES, Prior: NO> Context: 0x174284920, Property: 0x17065c620> <NSKeyValueObservance 0x17025bed0: Observer: 0x1700fa480, Key path: hasVideo, Options: <New: YES, Old: YES, Prior: NO> Context: 0x174284920, Property: 0x17065c3e0> <NSKeyValueObservance 0x170651100: Observer: 0x1700fa480, Key path: videoDimensions, Options: <New: YES, Old: YES, Prior: NO> Context: 0x174284920, Property: 0x17065c7a0> <NSKeyValueObservance 0x17025d400: Observer: 0x1700fa480, Key path: videoType, Options: <New: YES, Old: YES, Prior: NO> Context: 0x174284920, Property: 0x17065c920> )' *** First throw call stack: (0x18fd12fd8 0x18e774538 0x18fd12f20 0x19076e110 0x18fbf7e90 0x10010077c 0x100262104 0x1000e3e40 0x1000e51d0 0x1996095d8 0x1995a8c90 0x1995ab108 0x1993dbe48 0x199584878 0x1993a1d00 0x1993a44f8 0x194588e48 0x194589090 0x18fcc1424 0x18fcc0d94 0x18fcbe9a0 0x18fbeed94 0x191658074 0x195ea7130 0x10007108c 0x18ebfd59c) libc++abi.dylib: terminating with uncaught exception of type NSException

msach22 commented 6 years ago

@amatakasap Thanks for reporting the crash. To clarify, are you doing something like this:

session.disconnect();
var newSession = OT.initSession("your-api-key", "your-session-id");

The reason that you're seeing this crash is because you're calling initSession before the session has disconnected. You should really be calling the second initSession when the sessionDisconnected event fires. This is because at this time, the library only supports one session at a time.

You're PR is still resourceful because it's removing the unused observers. I'll run it for a quick smoke test and add comments as needed 😄

msach22 commented 6 years ago

This fix should go out with 3.3.0

msach22 commented 6 years ago

Released with 3.3.0