songz / cordova-plugin-opentok

Cordova Plugin for OpenTok - add webrtc video to your iOS or Android App
Other
162 stars 270 forks source link

getting error when connecting to session with opentok 1.0.3 on Intel XDK Cordova Crosswalk Android build #156

Open tysjiang opened 9 years ago

tysjiang commented 9 years ago

When trying to connect to a session, this error is popping up: "Attempt to invoke virtual method 'void com.opentok.android.Session.connect(java.lang.String)' on a null object reference"

Steps to reproduce:

  1. built app with Intel XDK v1826 Cordova 4.1.2 Crosswalk (10) Android
  2. try to connect to session session.connect(videoToken, function(){ // session.publish( publisher ); });
    • checked videoToken to make sure it is valid
    • tested with Samsung s5 Lollipop
    • note: same code works on the iOS builds
byronalfonso commented 9 years ago

hmm.. seems like a null videoToken... have you tried using a static token for testing?

tysjiang commented 9 years ago

just tried using a static token but got the same error

the same code works (or at least past this breaking point) with Intel XDK v1826 Cordova 4.1.2 Android builds so I'm thinking it's related to how opentok interop with Crosswalk 10

tysjiang commented 9 years ago

additional info: This issue will actually happen on iOS builds also if you use brodysoft sqlite 0.7.3 for some reason... So if you have to use sqlite, use 0.7.0, that version works fine with this plugin on iOS.

mark-veenstra commented 9 years ago

I have the same issue at this moment with Crosswalk and OpenTok for Android. I am using following versions:

Anyone have the same issues and/or solution? When I remove Crosswalk all is working correct, but when using Crosswalk OpenTok is crashing.

MathildeLemee commented 9 years ago

Same issue here. If I remove crosswalk, it works. With crosswalk, it doesn't work.

gevorgmakaryan commented 9 years ago

The same issue for me.

gevorgmakaryan commented 9 years ago

Has anyone any updates related to this issue?

IjzerenHein commented 9 years ago

I'm running into this as well. I'm not too familiar with Android development, but managed to pull out this using logcat:

I/OTPlugin(18618): initSession
I/OTPlugin(18618): created new session with data: ["xxxxxxxx","XXXXXXXXXXXXXX"]
I/art     (18618): Rejecting re-init on previously-failed class java.lang.Class<com.opentok.android.Session>
W/System.err(18618): java.lang.UnsatisfiedLinkError: com.opentok.android.Session
W/System.err(18618):    at com.tokbox.cordova.OpenTokAndroidPlugin.execute(OpenTokAndroidPlugin.java:396)
W/System.err(18618):    at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:95)
W/System.err(18618):    at org.apache.cordova.PluginManager.exec(PluginManager.java:130)
W/System.err(18618):    at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
W/System.err(18618):    at org.crosswalk.engine.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
W/System.err(18618):    at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
W/System.err(18618):    at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
W/System.err(18618):    at android.os.Handler.dispatchMessage(Handler.java:102)
W/System.err(18618):    at android.os.Looper.loop(Looper.java:145)
W/System.err(18618):    at android.os.HandlerThread.run(HandlerThread.java:61)
I/chromium(18618): [INFO:CONSOLE(10177)] "connecting: XXXXXXXX", source: file:///android_asset/www/cordova_bundle.js (10177)
I/OTPlugin(18618): addEvent
I/OTPlugin(18618): adding new event - sessionEvents
I/OTPlugin(18618): connect
I/OTPlugin(18618): connect command called
E/PluginManager(18618): Uncaught exception from plugin
E/PluginManager(18618): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.opentok.android.Session.connect(java.lang.String)' on a null object reference
E/PluginManager(18618):     at com.tokbox.cordova.OpenTokAndroidPlugin.execute(OpenTokAndroidPlugin.java:433)
E/PluginManager(18618):     at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:95)
E/PluginManager(18618):     at org.apache.cordova.PluginManager.exec(PluginManager.java:130)
E/PluginManager(18618):     at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
E/PluginManager(18618):     at org.crosswalk.engine.XWalkExposedJsApi.exec(XWalkExposedJsApi.java:40)
E/PluginManager(18618):     at org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
E/PluginManager(18618):     at org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:53)
E/PluginManager(18618):     at android.os.Handler.dispatchMessage(Handler.java:102)
E/PluginManager(18618):     at android.os.Looper.loop(Looper.java:145)
E/PluginManager(18618):     at android.os.HandlerThread.run(HandlerThread.java:61)

EDIT: I found this related post on stackoverflow: http://stackoverflow.com/questions/30843969/opentok-for-cordova-with-crosswalk-throws-alert

silverio commented 9 years ago

Anyone found a solution to this issue?

mark-veenstra commented 9 years ago

Maybe this answer helps: http://stackoverflow.com/a/31562610/1800695

mark-veenstra commented 9 years ago

I think we should all be focused on this repository: https://github.com/aoberoi/cordova-plugin-opentokjs But I have created a plugin which uses the old library for iOS and the new library for Android and browser. This way Crosswalk is supported: https://github.com/Mobilea/cordova-plugin-opentok.git#develop

IjzerenHein commented 9 years ago

@mark-veenstra How did you fix the issue that WebRTC cannot be used when your cordova app is loaded over 'file://' ?

mark-veenstra commented 9 years ago

@IjzerenHein Don't open your project by double clicking on index.html. But make sure you serve the page. For example create a gulp task to serve your platform browser:

var webserver = require('gulp-webserver');
gulp.task('browser:serve', function() {
    gulp.src('./platforms/browser/www/')
        .pipe(webserver({
            livereload: {enable: true, port: 35729},
            directoryListing: false,
            host: localhost,
            port: 8100,
            open: true
        }));
});

Make sure to have the NPM module gulp-webserver installed.

IjzerenHein commented 9 years ago

I eventually abandoned the approach trying to get the original OpenTok plugin to work with Crosswalk. Instead, I solved it by taking the following steps:

In your config.xml, add --allow-access-from-files to the xWalkCommandLine preference:

<preference name="xwalkCommandLine" value="--disable-pull-to-refresh-effect --allow-access-from-files" />

Now download a copy of the original OpenTok.js file (http://static.opentok.com/v2/js/opentok.js) and outcomment the following lines:

//if (location.protocol === 'file:') {
//  /*global alert*/
//  alert('You cannot test a page using WebRTC through the file system due to browser ' +
//    'permissions. You must run it over a web server.');
//}
mark-veenstra commented 9 years ago

@IjzerenHein : This plugin does the same as you did manually: https://github.com/Mobilea/cordova-plugin-opentok.git#develop

IjzerenHein commented 9 years ago

@mark-veenstra I tried it, but it didn't work for me. I tried like a 100 hundred things so I'm not sure what went wrong or why I abandoned that approach. I see that it automatically parses and changes the OpenTok.js file, how cool is that, nice :)

Does it also enable --allow-access-from-files ?

mark-veenstra commented 9 years ago

@IjzerenHein : Hmm I am using the same plugin in a project now with CrossWalk on Android. I did install the plugin with cordova/ionic plugin add https://github.com/Mobilea/cordova-plugin-opentok#develop And when building for IOS manually in XCode make sure to set the ENABLE_BITCODE to no

IjzerenHein commented 9 years ago

@mark-veenstra Alright, well I'm gonna have a look at it later. I've made some changes to the original plugin which I need to run my project. I've pushed pull-requests for them to the original repo, but it doesn't seem very active anymore. When I get it up & running using your repo, I'll send the pull requests there, so we can hopefully have a single good repo.

derwaldgeist commented 8 years ago

+1 Is there a "best practice approach" available now for dealing with this? I'm using the OpenTok plugin together with Meteor, and could not even install the app. It crashed on first run.

derwaldgeist commented 8 years ago

Got it running now (was a problem with setting the background color). But I cannot see any videos (neither subscriber nor publisher). It only works without Crosswalk. Any ideas how the videos can be enabled if Crosswalk is included?