bug: deviceready has not fired after 5 seconds
From @mccob on February 13, 2015 16:33
Type: bug
Platform: android 4.4 browser
With last stable versions of crosswalk, ionic and cordova, got "deviceready has not fired after 5 seconds" error and Cordova API are unusable.
Crosswalk developer say to open bug on ionic tracker : https://crosswalk-project.org/jira/browse/XWALK-3345
Copied from original issue: driftyco/ionic#3108
@ituhin / @growthclick would you please share what your meta tag looks like? I have this but it's not helping:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
@siphiwe try removing this one if you have it
if you dont have it then your problem is something else. try safari/chrome remote debugger to figure out the issue.
I do need a Content-Security-Policy meta tag. It's required by the cordova-plugin-whitelist plugin. By the way, I had pasted the wrong tag in my previous comment, I just corrected it as follows:
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'">
For the record, if I do remove this tag, I still get the problem with deviceready not firing within 5 seconds. Chrome developer tools only reveals csrf problems which I'm ok with because localhost is trying to make requests to my server.
If the priority is iOS, then removing the Content-Security-Policy should solve the problem (you can still keep the Cordova-plugin-whitelist in place), and you can use Safari remote debugging to clarify other issues. For Android, the Content-Security-Policy seems to be required (for ionic run android), otherwise I was getting a white screen when trying to debug with "ionic run android".
Here is a Content-Security-Policy that I'm using on iOS (it's a google maps project). This version may not be tight enough security wise but it's working for me right now on iOS development.
<meta http-equiv="Content-Security-Policy" content="default-src *; style-src 'self' http://*.googleapis.com
https://*.googleapis.com http://*.gstatic.com https://*.gstatic.com
'unsafe-inline'; script-src 'self' http://*.googleapis.com
https://*.googleapis.com http://*.gstatic.com https://*.gstatic.com 'unsafe-inline' 'unsafe-eval'">
The other thing to check for (with Cordova Whitelist) is that you specify access origin in your project's config.xml:
<access origin="*"/>
The above may not be secure enough for a production project - check out https://cordova.apache.org/docs/en/4.0.0/guide_appdev_whitelist_index.md.html for details.
Hope that helps!
I did face the same problem with device-motion plugin. When I remove it or stop calling it from the app it works without any problem
@siphiwe for me its this.... i had to add ws: and wss: for websockets in my app, and in ios it was crying for gap: i have something like this < meta http-equiv="Content-Security-Policy" content="default-src 'self' https:; connect-src 'self' wss://.xyz.com ws://.xyz.com https://.xyz.com https://.xyz.com ws://localhost:35729 gap:; style-src 'self' 'unsafe-inline' gap:; script-src 'self' 'unsafe-inline' 'unsafe-eval' https: http: gap:; frame-src https://*.xyz.com gap: localhost" >
Thanks for assistance guys. I have tweaked the Content-Security-Policymeta tag and got no joy. I just noticed that this issue doesn't occur on IOS. Well, I'm testing with Intel XDK emulators. It's on Windows and Android emulators that I get this. Am a bit stumed at the moment.
For what it's worth, I have now trimmed the whole thing down to a brand new Ionic project (using the tabs template), and put $ionicPlatform.ready in the app.run method and this bug popped up. It's only on IOS that the problem does not happen. I have created this setup both on Ubuntu 14.4 and on Windows 7. Not sure if it's a version mismatch between Ionic itself and plugins, cordova, etc. (How do people manage version compatibility reliably, anyway? Is bower the preferred way to take care of this?)
Essentially, I can't do a simple "Hello world" with a platformReady event. No idea what to do now. Any assistance would be appreciated. Thanks
@siphiwe ... try with remote debugging in chrome. you might get more info regarding error
Hi for everyone. I had the same problem and i just solve it :
- use yo ionic https://github.com/diegonetto/generator-ionic
- Choose blank project
- Copy - Paste my template folder with index.html and scripts
- sudo ionic platform ios
- sudo ionic build ios
- ionic emulate ios --livereload
and thats it.
I hope i help to someone with this.
Hey everyone. Often, the issue is a bad plugin install that is holding up device ready. I find that what usually works is removing my other plugins (ionic plugin rm cordova-plugin-statusbar for example), and adding them back.
We are trying remove this error or be louder about it by going a bit deeper in Cordova, but we're not there yet.
Max Lynch Chief Executive Ion [email protected] 414-530-9687
ionicframework.com | @ionicframework http://twitter.com/ionicframework | 121 S. Pinckney st. Ste 300 Madison, WI 53703
On Thu, Oct 1, 2015 at 5:27 PM, jay [email protected] wrote:
Hi for everyone. I had the same problem and i jsut solve it :
- use yo ionic https://github.com/diegonetto/generator-ionic
- Choose blank project
- Copy - Paste my template folder with index.html and scripts
- sudo ionic platform ios
- sudo ionic build ios
- ionic emulate ios --livereload
and thats it.
I hope i help to someone with this.
— Reply to this email directly or view it on GitHub https://github.com/driftyco/ionic-cli/issues/259#issuecomment-144866158.
Still same problem here... I figured out that happend, to me, only the first time i open up the app. With no data nor cache. On Android
For me, its definitely the Content-Security-Policy which was causing the issue in iOS. Yes, I do need the Content-Security-Policy to run for Android as well. So what I did as a work around was to have a bash script to inject the meta Content-Security-Policy tag into the index.html if I need it to build and run on Android and not to have it injected for build and running on iOS.
now I get this trouble, but how can I solve it, Who can tell me???thank a lot
cordova -version 6.2.0 with ionic -version 1.7.16
I too have this problem (only on some android devices), is there any update on this one?
My plugin are as follow
com.telerik.plugins.nativepagetransitions 0.6.5 "Native Page Transitions" com.verso.cordova.clipboard 0.1.0 "Clipboard" cordova-plugin-compat 1.0.0 "Compat" cordova-plugin-crosswalk-webview 1.7.2 "Crosswalk WebView Engine" cordova-plugin-customurlscheme 4.2.0 "Custom URL scheme" cordova-plugin-facebook4 1.7.1 "Facebook Connect" cordova-plugin-geolocation 2.2.0 "Geolocation" cordova-plugin-inappbrowser 1.4.0 "InAppBrowser" cordova-plugin-network-information 1.2.1 "Network Information" cordova-plugin-social-message 0.4.0 "Social Message" cordova-plugin-splashscreen 3.2.2 "Splashscreen" cordova-plugin-statusbar 2.1.3 "StatusBar" cordova-plugin-whitelist 1.2.2 "Whitelist" cordova-plugin-x-socialsharing 5.1.3 "SocialSharing" ionic-plugin-keyboard 2.2.1 "Keyboard"
I am using cordova 6.3.1
When you develop a hybrid application with PhoneGap, Cordova, Ionic, CordovaChromeApps and any other framework that is built on top on PhoneGap, I can almost assure you that you’ll get this error. And it’s super annoying.
I think the issue is when you delete your platforms folder, or the files inside, and do a platform add ... afterwards. This is at least how I reproduced it.
You’ll need to:
-
add the platforms with cordova platform add ios android
-
remove them with cordova platform remove ios android
-
add them again.
I know this is super weird, but I think it’s related to a faulty android.json and ios.json inside the platforms folder.
Following the steps above fixed the issue for me :).
Any Update on this issue ?, this seems to happen on some of the android devices as well still. Ionic 2 RC 2 also having the same issue
Same problem for me with Ionic RC 3. Any Update? Please i need help
Same problem here (RC 3)
I'm going to lock this so people don't miss @bayanAbuawad's instructions above. 99% of the time the issue is a plugin that is in an inconsistent state. Try removing your plugins and your platforms and re adding them.