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 iOS-12 when subscribing to stream #131

Closed p-sebastian closed 5 years ago

p-sebastian commented 5 years ago

CRASH Report

Current behavior

on StreamCreated event, right when its about to subscribe to the stream it crashes without any errors only on iOS, on android it works as intended. This is running in an ionic app on 2 different apps, but both run the same code below.

  • StreamDestroyed and SessionDisconnected dont run, it will just crash.
  • Both apps will crash on subscribe in iOS
  • If I dont subscribe on iOS, it will not crash but I wont be able to listen the other end.

Steps to reproduce

Im using this provider on both apps, where I just call the connect Function on both apps. And it will crash on the 'StreamCreated' event when running subscribe.

....
export class OpentokProvider {
  private _session = null;

  constructor(private _x: VariablesProvider,
              private _platform: Platform) { }

  connect(sessionId: string, token: string, callback: Function) {
    const self = this;
    this._platform.ready().then(() => {
      self._session = OT.initSession(self._x.OPENTOK_API_KEY, sessionId);

      // listen for events
      self._on();
      self._session.on('connectionDestroyed', () => callback());

      // connect to session and start publishing.
      self._session.connect(token, function(e) {
         // I know publish can be here instead of being below on the session connected event
         // it will still crash
      });
    });
  }
  close(): void {
    if (!this._session) { return; }

    // ends session
    this._session.disconnect();
  }
  private _on(): void {
    this._session.on('streamCreated', event => {
      console.log("New stream in the session: ", event);
      // here its where it crashes
      this._session.subscribe(event.stream, 'pergo-subscriber', { subscribeToAudio: true, subscribeToVideo: false });
    });
    this._session.on('streamDestroyed', event => {
      console.log(`Stream ${event.stream.name} ended because ${event.reason}.`)
    });
    this._session.on('sessionDisconnected', event => {
      console.log('sessionDisconnect', event.reason);
    });
    this._session.on('sessionConnected', event => {
      console.log('sessionConnected', event);
      const publisher = OT.initPublisher(null, { publishVideo: false, videoSource: false });
      // console.info(e);
      this._session.publish(publisher);
    });
    this._session.on('connectionCreated', event => {
      if (event.connection.connectionId != this._session.connection.connectionId) {
        console.log('Another client connected. ');
      }
    });
  }

What is the current bug behavior?

when its about to subscribe to the stream, the app crashes completely and closes on iOS only

What is the expected correct behavior?

Correctly subscribe, and be able to listen and speak to the other end.

Relevant logs and/or screenshots

Ionic:

   ionic (Ionic CLI)  : 4.1.2 (.../node/v10.7.0/lib/node_modules/ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.1.8

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 7.1.0, ios 4.5.4
   Cordova Plugins       : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 1.2.1, (and 18 other plugins)

System:

   ios-deploy : 2.0.0
   NodeJS     : v10.7.0 (.../node/v10.7.0/bin/node)
   npm        : 6.2.0
   OS         : macOS
   Xcode      : Xcode 10.0 Build version 10A255
msach22 commented 5 years ago

@p-sebastian Thanks for reporting this, could you please share if this is happening on iOS 11 or just with iOS 12?

p-sebastian commented 5 years ago

@msach22 I'm not entirely sure, since I cant find another device with iOS 11. So at the moment I've only tested iOS 12

msach22 commented 5 years ago

@p-sebastian I just ran this on iOS 12 and I'm unable to reproduce this. Please let me know if you're still seeing this with the latest version of the plugin.

msach22 commented 5 years ago

@p-sebastian I'm going to go ahead and close this issue, please feel free to re-open if you're still seeing this issue.