Ionic 2 RC.1 IOS Build device-ready not fired because of plugin problem?


#1

This was my first message - see the second one for more details!

Since I have updated to RC.1 AND installed the newest Xcode-Version (because of IOS 10) the startup time of my project increased from about 2 secs to nearly 20 secs.

I have no idea whats going on - the debugger doesn’t show any message in the delay. Seems as if the app is waiting for something for ages…

Any idea what caused the problem?

Regards
Grischa


#2

I have fou d out the possible reason but don’t yet know how to solve it.

The delay is caused because I have set my splashscreen to show 20 secs or until it is disabled.
It is normally disabled when the platform_ready event fires - and thats the problem.

Looking in the debug window of xcode I found

CallyApp[823:195274] WARN: Native: deviceready did not fire within 2000ms. This can happen when plugins are in an inconsistent state. Try removing plugins from plugins/ and reinstalling them.
2016-10-17 20:55:37.204047 CallyApp[823:195274] deviceready has not fired after 5 seconds.
2016-10-17 20:55:37.204067 CallyApp[823:195274] Channel not fired: onCordovaInfoReady
2016-10-17 20:55:37.204088 CallyApp[823:195274] DEVICE READY FIRED AFTER 54542 ms
2016-10-17 20:55:37.213071 CallyApp[823:195274] app.ts: hiding the splashscreen

I found out two more things: the output above did show only after I entered the first textbox / when the keyboard was shown. So it might be a problem with the keyboard plugin?

Then I found that storing in the normal KV-List doen’ t work anymore, so its probably the sql-lite plugin???

Anyway: I removed all plugins and I added them all again - it didn’t help

The error appears only with IOS not when I run ionic serve.

Any ideas?


#3

Did you

ionic platform rm ios
ionic platform add ios

?

I had the problem with sql lite. I removed it.


#4

@Sulot: yes, I tried but it didn’t help


#5

I have solved this problem:

Althought it seemed to be a problem of plugins it was not!

This behaviour appears if you have iOS10 on the smartphone AND you have configured a Content Security Policy (CSP) in index.html (as can be found in the book of Josh Morony). This CSP was originally need back in beta11 and earlier, but with RC.0 it is not. However in iOS<9 it doesn’t make any problem, only in ios10.

If you have this problem and have read Josh Moronys book or blog, delete the content security policy meta tag in index.html.


#6

had a similar problem on android.
when building the final release version, i had to add -prod to the build command:
ionic build --release android -prod

this decreased the time to home screen with more than half!


#7

Awesome, that did the trick for me!


#8

Hey @Grischa may I ask you, if I understand correctly, you removed your all CSP in your index.html right?

I mean you removed something like

<meta http-equiv="Content-Security-Policy" content="default-src...

right?


#9

Definitely seems to be some kind of issue with CSP (not sure whether that’s an iOS10 bug or not), it looks like people are having success with this CSP though:

<meta http-equiv="Content-Security-Policy" content="default-src gap://ready file://* *; script-src 'self' 'unsafe-inline' 'unsafe-eval' *; style-src 'self' 'unsafe-inline' *”>

#10

Yes, thats what I did and it seems to work for me, but can’t guarantee, that this will work in your app. The content security policy must be good for something and I must say, I never understood completely what it does, because I thought the white-list-plug-in does the same.

In my app I use http to access a REST-service from a server, but I do not load any content into the page over http (all content is local). Perhaps that’s the reason, why I don’t need the CSP.
@joshmorony: Could you give us a hint, why and when exactly a CSP is needed?


#11

I would like to add, that I followed Josh’s suggestion and added the new Content-Security-Policy - in hoping that this will work everywhere. It definitely works on iOS 10 and Android/Crosswalk.

I have submitted my app to the google play store and the apple app store and so far I had no complaints. So I guess, it wirks everywhere (or I was just lucky so far)


#12

Thx for your comments @Grischa. I did the same at the end, I let my CSP in index.html

Good luck with the submission of your app in the stores!


#13

Thank you! I was already successfull. My app is available in both stores.


#14

Hi @Grischa may you share exactly how your CSP looks like?


#15

Thank you, I been wasting hours trying to fix it. Not I have to figure out how to selectively have CSP on Android, and not have it on iOS.


#16

I have the same issue with ios 11. AFAIK CSP is needed on IOS. What CSP did you use?


#17
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src * data:">