Deviceready did not fire


#1

Hi,

when building for iOS i see the following in my logs:

[12:37:49]  console.log: Angular is running in the development mode. Call enableProdMode() to enable the production
            mode.
[12:37:53]  console.log: deviceready has not fired after 5 seconds.
[12:37:53]  console.log: Channel not fired: onCordovaInfoReady
[12:37:53]  console.log: Channel not fired: onFileSystemPathsReady
[12:37:53]  console.warn: Ionic Native: deviceready did not fire within 5000ms. This can happen when plugins are in an
            inconsistent state. Try removing plugins from plugins/ and reinstalling them.

On android everything is fine. The problem shows in the iOS Simulator (with iOS 9.3 or 10) and on real devices.
I tried all suggestions found in this forum (removing and adding the ios platform, changing the Content-Security-Policy in index.html, …) but I am unable to create a working release build on iOS.
And without the deviceready event the plugins are not working, and so does my App.

Here are some informations about my system:


global packages:

    @ionic/cli-utils : 1.2.0
    Cordova CLI      : 7.0.1
    Ionic CLI        : 3.2.0

local packages:

    @ionic/app-scripts              : 1.3.7
    @ionic/cli-plugin-cordova       : 1.2.1
    @ionic/cli-plugin-ionic-angular : 1.2.0
    Cordova Platforms               : android 6.1.2 ios 4.4.0
    Ionic Framework                 : ionic-angular 3.1.1

System:

    Node       : v7.7.3
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002
    ios-deploy : 1.9.1
    ios-sim    : 5.0.13

the used plugins:

> cordova plugin ls
✔ Running command - done!
com.googlemaps.ios 2.2.0 "Google Maps SDK for iOS"
cordova-plugin-app-version 0.1.9 "AppVersion"
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-file 4.3.3 "File"
cordova-plugin-file-opener2 2.0.16 "File Opener2"
cordova-plugin-file-transfer 1.6.3 "File Transfer"
cordova-plugin-geolocation 2.4.3 "Geolocation"
cordova-plugin-googlemaps 1.4.0 "phonegap-googlemaps-plugin"
cordova-plugin-inappbrowser 1.7.1 "InAppBrowser"
cordova-plugin-nativestorage 2.2.2 "NativeStorage"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
cordova-sqlite-ext 0.10.4 "Cordova sqlite storage plugin with extras"
cordova-sqlite-storage 2.0.4 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Another (maybe related issue): when building using the Ionic Cloud Services (ionic package build ios) the build fails with error 65

duplicate symbol _sqlite3_prepare_v2 in:
    /Users/package/Library/Developer/Xcode/DerivedData/WastApp-euejyxfqalnonrbwpeekvozszrlu/Build/Intermediates/ArchiveIntermediates/WastApp/IntermediateBuildFilesPath/WastApp.build/Debug-iphoneos/WastApp.build/Objects-normal/arm64/sqlite3-1EA2915C0E061965.o
    /Users/package/Library/Developer/Xcode/DerivedData/WastApp-euejyxfqalnonrbwpeekvozszrlu/Build/Intermediates/ArchiveIntermediates/WastApp/IntermediateBuildFilesPath/WastApp.build/Debug-iphoneos/WastApp.build/Objects-normal/arm64/sqlite3-9759FEAE7800AB80.o
duplicate symbol _sqlite3_create_module_v2 in:
    /Users/package/Library/Developer/Xcode/DerivedData/WastApp-euejyxfqalnonrbwpeekvozszrlu/Build/Intermediates/ArchiveIntermediates/WastApp/IntermediateBuildFilesPath/WastApp.build/Debug-iphoneos/WastApp.build/Objects-normal/arm64/sqlite3-1EA2915C0E061965.o
    /Users/package/Library/Developer/Xcode/DerivedData/WastApp-euejyxfqalnonrbwpeekvozszrlu/Build/Intermediates/ArchiveIntermediates/WastApp/IntermediateBuildFilesPath/WastApp.build/Debug-iphoneos/WastApp.build/Objects-normal/arm64/sqlite3-9759FEAE7800AB80.o
ld: 212 duplicate symbols for architecture arm64

** ARCHIVE FAILED **


The following build commands failed:
	Ld /Users/package/Library/Developer/Xcode/DerivedData/WastApp-euejyxfqalnonrbwpeekvozszrlu/Build/Intermediates/ArchiveIntermediates/WastApp/IntermediateBuildFilesPath/WastApp.build/Debug-iphoneos/WastApp.build/Objects-normal/armv7/WastApp normal armv7
(1 failure)
Error: Error code 65 for command: xcodebuild with args: -xcconfig,/Users/package/workspace/apps-312bdc3f-4/cordova/platforms/ios/cordova/build-debug.xcconfig,-workspace,WastApp.xcworkspace,-scheme,WastApp,-configuration,Debug,-destination,generic/platform=iOS,-archivePath,WastApp.xcarchive,archive,CONFIGURATION_BUILD_DIR=/Users/package/workspace/apps-312bdc3f-4/cordova/platforms/ios/build/device,SHARED_PRECOMPS_DIR=/Users/package/workspace/apps-312bdc3f-4/cordova/platforms/ios/build/sharedpch

Locally it builds fine, but with the mentioned problem that the deviceready event does not fire.

Any ideas?


#2

deleting the platforms and plugins folders and then performing a ionic cordova prepare (previously ionic state command) to get all installed clean does not help.
Update: using ionic serve command platform ready function fires. What is wrong with my iOS build?


#3

This just means your app startup time is a bit long; not that anything is wrong. Try using fewer plugins or adapting the ionic 3 lazy load pattern to reduce startup time…


#4

That seems strange, I deleted everything, this is my complete home.ts file:

import { Component } from '@angular/core';
import { NavController, Platform } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html',
  providers : []
})
export class HomePage {

  constructor(  public platform: Platform, 
                public navCtrl: NavController ,
                //private sqlite: SQLite,
                //private nativeStorage: NativeStorage,
                //private alertCtrl: AlertController,
                //private localNotifications: LocalNotifications
                ) { 

  	this.platform.ready().then((readySource) => {
      console.log("Platform ready!");
      
    });
  }
}

Again platform.ready() is not executed and I see the same problems.

I will try the lazy load pattern, but I doubt it will help, since this small example doesn’t even work.
What can I try further, to debug this issue?


#5

You can uncomment those things, but the plugins are still being loaded. Remove them from your project and try again. Or just try it out with a clean project, add the plugins in one by one and see where you’ve entered the point of no return and the loading time stacks up.

If you have many pages lazy loading could reduce startup times. BTW, what command are you running exactly? Do you use the --prod variable?


#6
cordova-sqlite-ext 0.10.4 "Cordova sqlite storage plugin with extras"

I would lose this.


#7

This is my build command:ionic cordova emulate ios -lc --prod
Removing the --prod parameter does not change anything for my build.

I removed the following plugins (in this order) and did a build after each plugin removal. The problem still persists:

cordova-sqlite-ext
cordova-sqlite-storage
cordova-plugin-file-opener2
cordova-plugin-file-transfer
cordova-plugin-file
cordova-plugin-nativestorage
cordova-plugin-geolocation
cordova-plugin-inappbrowser

I have the following plugins left (should be the bare minimum of any App):

> cordova plugin ls
✔ Running command - done!
cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Anything else I can try to debug this issue? Other projects build fine, this project builds fine on Android (and is already published). I did no big modifications in the last time, cloud it be some versioning issue with the plugins?


#8

Yes, don’t try and run it on an emulator. Run it on a real device and please use --prod because it uses aot instead of jit. Especially when you’re debugging on a real device you’ll see real startup improvements then.


#9

Thanks for your help.
I try to run it on a real device from now on (using ionic cordova run ios --device -lc --prod)
But here comes the strange thing:
If I create a new project (starter template), set it up and build it everything works fine.
It uses this plugins:

cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.2 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Removing from my existing project all others and leaving only these, it does not work:

cordova-plugin-console 1.0.5 "Console"
cordova-plugin-device 1.1.4 "Device"
cordova-plugin-splashscreen 4.0.3 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
ionic-plugin-keyboard 2.2.1 "Keyboard"

Is there anything other that can affect plugin loading, or at least a way to get a more verbose log ouput (and maybe see what plugins gets loaded that is blocking)?

Thanks for any help.
This is kind of urgent, all worked fine until a few days and I need to create a release build. I just updated the ionic components.

Thanks.


#10

Did you rebuild the platform? You’re 100% sure the plugins aren’t in your project build anymore? Then it something in your regular coding that’s blocking the loading. Look for code you’re running at app startup, it should give you some direction where to look. Or port over your code to the empty new project bit by bit.


#11

How to increase the timeout time for the dialog “The connection to the server was unsuccessful”? On console: “deviceready has not fired after 5 seconds.” and “channel not fired”.
But the app is ready in about 30 seconds. btw. sometimes immediately under 5 seconds. weird. Whatever… the error dialog box will terminate the app on confirm. this is very annoying. how to disable it or increase the timeout time?