petermetz / cordova-plugin-ibeacon

An iBeacon plugin for Phonegap / Cordova 3.x and upwards. Supports both iOS and Android (contributions are welcome)
Apache License 2.0
726 stars 373 forks source link

Delegate callback timeout #204

Open andersborgabiro opened 8 years ago

andersborgabiro commented 8 years ago

This error is visible in Weinre: "cordova-plugin-ibeacon did not receive delegate ready callback from dom after 30 seconds"

index.html shows up after a second or two, so DOM should be fully active.

cli-5.2.0 works somewhat: After this timeout deviceready is fired and the app initializes and works the normal way. With cli-6.0.0 it takes "forever" and eventually the app is terminated by iOS.

As deviceready hasn't been received before the error, no part of my code is running at the time, yet Javascript has been included. I've checked that I don't do any global initialisations that are dependent on any plugin or the core.

What's odd is that the amount of plugins used affect the timing for both cli versions. I suspected a conflict between plugins, but so far I haven't been able to nail that down, and maybe core would have signaled that somehow.

Anyone else that's seen the same phenomenon or has any idea what might be the problem?

When running on Android the startup is instantaneous.

Was anything changed for iOS between 3.3.0 and 3.4.0?

When deactivating debugging in PhoneGap Build the startup on 5.2.0 went faster, but on the other hand I had no way of telling whether the above error occurred. I see nothing suspicious in Safari Inspector.

Info: iPhone 4S (I know: old!) iOS 9.2.1

This is the complete plugin list (the latest of everything):

cordova-plugin-appversion npm * 1.0.0 n/a android,ios,winphone cordova-plugin-autostart npm * 2.0.1 n/a android,ios,winphone cordova-plugin-device npm * 1.1.1 n/a android,ios,winphone cordova-plugin-dialogs npm * 1.2.0 n/a android,ios,winphone cordova-plugin-globalization npm * 1.0.2 n/a android,ios,winphone cordova-plugin-ibeacon npm * 3.4.0 n/a android,ios,winphone cordova-plugin-inappbrowser npm * 1.3.0 n/a android,ios,winphone cordova-plugin-local-notifications-mm npm * 1.0.1 n/a android,ios,winphone cordova-plugin-network-information npm * 1.2.0 n/a android,ios,winphone cordova-plugin-statusbar npm * 2.1.1 n/a android,ios,winphone cordova-plugin-vibration npm * 2.1.0 n/a android,ios,winphone cordova-plugin-whitelist npm * 1.2.1 n/a android,ios,winphone cordova-plugin-x-toast npm * 2.4.2 n/a android,ios,winphone

andersborgabiro commented 8 years ago

After adding/removing plugins in different patterns I found that cordova-plugin-statusbar and cordova-plugin-ibeacon somehow are in conflict, making starting the core take a very long time. For now I will simply not include cordova-plugin-statusbar, and compensate in Javascript. If something else pops up I'll let you know.

petermetz commented 8 years ago

Hi @andersborgabiro ,

Can't reproduce this one I'm afraid. I've tried adding all these plugins in a few different order to a fresh checkout of https://github.com/petermetz/cordova-proximity-quickstart but the deviceready event was firing all the time without issues and I didn't get the delegate callback timeout either. Any chance that you could share a test project where this is reproducable ?

Kind regards, Peter

andersborgabiro commented 8 years ago

Even with statusbar removed it takes 10ish seconds for the app to start and core to issue deviceready. Sometimes it never arrives and iOS shuts down the app. In that case index.html is not opened, or the browser view is not launched (in any case blank screen).

It seems more like an aggregate problem than a hard conflict between plugins. Maybe my 4S runs out of memory (?).

I'll spend more time tomorrow trying to solve this, and test on newer phones, as a critical release is coming up. If I can't "break the code" I'll provide a project.

andersborgabiro commented 8 years ago

This is my revised plugin list (now also with geolocation):

cordova-plugin-appversion npm * 1.0.0 n/a android,ios,winphone cordova-plugin-autostart npm * 2.0.1 n/a android,ios,winphone cordova-plugin-device npm * 1.1.1 n/a android,ios,winphone cordova-plugin-dialogs npm * 1.2.0 n/a android,ios,winphone cordova-plugin-geolocation npm * 2.1.0 n/a android,ios,winphone cordova-plugin-globalization npm * 1.0.3 n/a android,ios,winphone cordova-plugin-ibeacon npm * 3.4.0 n/a android,ios,winphone cordova-plugin-inappbrowser npm * 1.3.0 n/a android,ios,winphone cordova-plugin-local-notifications-mm npm * 1.0.1 n/a android,ios,winphone cordova-plugin-network-information npm * 1.2.0 n/a android,ios,winphone cordova-plugin-vibration npm * 2.1.0 n/a android,ios,winphone cordova-plugin-whitelist npm * 1.2.1 n/a android,ios,winphone cordova-plugin-x-toast npm * 2.5.0 n/a android,ios,winphone https://github.com/robertklein/cordova-ios-security npm * 0.3.0 n/a android,ios,winphone

cesaralvarado9 commented 8 years ago

Hi. I've experienced this error also in my app. My app is written in angular (so as the quickstart). the difference is that my app is manually bootstrapped and doesn't kick in until the deviceready event is triggered thus having the App frozen by 30 seconds. What I realized is that the plugin expects a delegate no matter what. So in my case the delegate was settled in a provider in angular, but again that provider doesn't kicks in until my app is bootstrapped. So what I did was to set an empty delegate at the very beggining of the app (after cordova.js was loaded) in this way:

var delegate = new cordova.plugins.locationManager.Delegate(); cordova.plugins.locationManager.setDelegate(delegate);

and that did the trick

cesaralvarado9 commented 8 years ago

@petermetz Requiring to set a Delegate at the beginning onPageLoad is a desired behavior?

McGern commented 8 years ago

This worked for me @cesaralvarado9 thanks.

Would be great if this was added to the documentation, spent a few hours trying to work out what was going on.