Open Matheus90 opened 10 years ago
Sorry - I have not yet played with this, but I'm pleased to hear about it. I would like to experiment with it, but it may be a while before I do, and I wanted to at least respond to you.
Are you sure the JS for the plugin is being loaded? Can you get it to work, not in Meteor but in a native "on device" HTML/JS test? Is PhoneGap loading a special, dynamic (hidden?) JS file for your plugins (some versions have)? If so, you will need to replicate that manually. It should be the case that all PhoneGap loaded JS initializes before MeteorRider hijacks the DOM and all JS object (not overwritten by Meteor) should remain available.
fyi, we (Matheus90 and I) got everything working in iOS, but never in Android.
Having similar issue with phonegap-faceboom-plugin. The userData callback fires okay on iOS but on android it doesn't fire until the login exec is called again.
FWIW, I tried a spike of the media capture plugin (basically just their hello world app) and it was broken for Android, so I assume it's a phonegap thing and not a Meteor-Rider issue. It's working on iOS but Android is broken (v3.3 with Android fires on the 2nd open capture window :frowning: )
Similar problem with this plugin https://github.com/wildabeast/BarcodeScanner/
It works in a plain HTML/JS app.
Not sure it is related to MeteorRider. Others have similar problems without Meteor or MeteorRider. See for example: http://stackoverflow.com/questions/19809164/navigator-camera-getpicture-callback-doesnt-execute-until-2nd-call
@mstn Check out this fix that is in my Meteor PhoneGap Oauth package... it will unclog the Android plugin callbacks:
if (device.platform === 'Android') {
setInterval(function () {
cordova.exec(null, null, '', '', [])
}, 200);
}
This should be activated and shutoff as needed.
https://github.com/AdamBrodzinski/meteor-phonegap-oauth/blob/master/patch_window.js#L20-L29
@AdamBrodzinski thanks! It works. Do you have any idea about why this happens? I agree with you that it is a cordova/phonegap issue, but the bug appears when MeteorRider does "something".
@Matheus90 have you tried Adam's trick?
That is crazy - great find/workaround. Would you recommend me implementing into the MeteorRider script itself? Perhaps after DOM replacement has begun...?
Thanks, -alan
On Mon, Jul 21, 2014 at 4:59 AM, Marco notifications@github.com wrote:
@AdamBrodzinski https://github.com/AdamBrodzinski thanks! It works. Do you have any idea about why this happens? I agree with you that it is a cordova/phonegap issue, but the bug appears when MeteorRider does "something".
@Matheus90 https://github.com/Matheus90 have you tried Adam's trick?
— Reply to this email directly or view it on GitHub https://github.com/zeroasterisk/MeteorRider/issues/16#issuecomment-49583965 .
Do you have any idea about why this happens?
Actually i'm not quite sure.... pinging @jperl .
I agree with you that it is a cordova/phonegap issue, but the bug appears when MeteorRider does "something"
Yea i'm not quite sure how much of it is MeteorRider... I was having problems with photo and video capture on Android using their Hello World on 3.4. I do know that I don't like developing on Android with Phonegap :scream:
Would you recommend me implementing into the MeteorRider script itself?
@zeroasterisk I'm not quite sure of the performance drawbacks. @jperl just submitted a PR to only fire this when the OAuth was using it, maybe he has some insights on performance?
@AdamBrodzinski I am doing some pretty intensive UI. While profiling our app to get to 60FPS I noticed the callback flush was causing a jump during animations. And I have no idea why it works, I noticed that results were returning after the next cordova action, so I just guessed that this hack would work :).
@zeroasterisk I think the best way to use the workaround is only when you need to, so I do not recommend adding it to MeteorRider.
@jperl I'm really glad you've been doing that investigation and have come back with recommendations... that said, I'd really like to streamline OAuth, as a very important component of this "stack" of tools...
I've been toying with optional "extras" to add on MeteorRider... perhaps one would install and use the basic MeteorRider to get Meteor fired up... but we could have an optional extra set of JS files you could include in the Cordova project to facilitate various extras (like on-device testing, loading pages, connection failed pages, and whatnot).
If we went down that path (or perhaps as the first move down it) we could make meteor-rider-oauth.js
which would extend the existing MeteorRider
object with a watch(ttl)
method.
MeteorRider.watch = function(ttl) {
this.watchInterval = setInterval(function () {
cordova.exec(null, null, '', '', [])
}, 200);
setTimeout(function () {
clearInterval(MeteorRider.watchInterval);
}, ttl);
};
We could also put a hook into Meteor (?), such that any time an OAuth process was started we did something like:
if (_.isObject(MeteorRider) && _.has(MeteorRider, 'watch')) {
MeteorRider.watch(5000);
}
@zeroasterisk OAuth works, my PR just limits when to apply the callback flush workaround. Now it only runs when the InAppBrowser is open.
Instead of a ttl
parameter I suggest an on / off mechanism. Something like MeteorRider.watch(enabled)
. That way when people are expecting a callback they can turn it on and when they are not, off. Or they can leave it on if they do not care about the performance impact.
Also I am pretty sure the workaround only helps android, so I would make sure to document that and check the device is Android before running the setInterval.
And thanks for the work on MeteorRider, it looks really great!
Interesting...
I have reviewed meteor-phonegap-oauth/patch_window.js a bit and I'm impressed... it does all the work including starting/stopping that I was going to recommend to the user to do in their Meteor app...
I think I'm just going to recommend meteor-phonegap-oauth in the Readme as a recommended Add On to MeteorRider.
Think maybe we should still make a watch()
method for other callback problems/delays?
eventually I'll get off my ass and make MeteorRider a package too :)
Yeah I think a watch()
helper, with a way to stop it, would be useful until that bug goes away.
I am having similar callback not firing issue with cordova-camera-plugin in android jelly beans 4.4.2 & 4.4.4. The workaround recommended by @AdamBrodzinski did not work for me. Posted at http://stackoverflow.com/questions/37808733/cordova-navigator-camera-getpicture-not-working-in-android
Hy, I've set up a project with MeteorRider and videoCapturePlus (https://github.com/EddyVerbruggen/VideoCapturePlus-PhoneGap-Plugin) and experienced that callbacks are not working. Tested the same with media-capture and it resulted the same.
I've used Meteor-cordova before which worked fine with both media-capture and VideoCapturePlus, but moved to MeteorRider because of oauth issues and the iframe rendering speed.
Have you got any fix for this? Any help will be much appreciated, thanks.