From 128bb78bbe58cbd0671e2594d51d83b7df4b021b Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Sun, 6 Dec 2015 12:53:57 -0600 Subject: [PATCH] feat(platform): warn on lack of deviceready. Fixes #4723 --- js/utils/platform.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/utils/platform.js b/js/utils/platform.js index f25019e0ae8..0df0a8b13f3 100644 --- a/js/utils/platform.js +++ b/js/utils/platform.js @@ -393,7 +393,21 @@ var platformName = null, // just the name, like iOS or Android platformVersion = null, // a float of the major and minor, like 7.1 readyCallbacks = [], - windowLoadListenderAttached; + windowLoadListenderAttached, + platformReadyTimer = 2000; // How long to wait for platform ready before emitting a warning + + verifyPlatformReady(); + + // Warn the user if deviceready did not fire in a reasonable amount of time, and how to fix it. + function verifyPlatformReady() { + setTimeout(function() { + if(!self.isReady) { + console.warn('Possible issue: deviceready did not fire in a reasonable amount of time. ' + + 'This can be caused by plugins in an inconsistent state. One possible solution: uninstall/remove all ' + + 'plugins and reinstall them. Additionally, one or more plugins might be faulty or out of date.'); + } + }, platformReadyTimer); + } // setup listeners to know when the device is ready to go function onWindowLoad() {