Ionic-framework: bug: Launch freeze/crash on manual splash screen hiding

Created on 3 Feb 2016  ·  79Comments  ·  Source: ionic-team/ionic-framework

Type: bug

Ionic Version: 1.x

Platform: ios 9 webview

Experiencing a rather critical issue since getting on Cordova 6.0.0 for iOS. We have a scenario where we hide the Cordova splash screen manually relatively shortly after app launch. The problem is that quite often during launch the app just stays on the splash screen instead of continuing after hiding it, and eventually crashes. It looks like some sort of race condition at least from a user perspective.

Some testing shows with a good certainty that:

  • Cordova 5.4.1 does not manifest the problem.
  • Removing the cordova-plugin-device from the test app makes the problem disappear.
  • I cannot reproduce in a pure Cordova app (without Ionic & Angular).
  • In case the freeze doesn't occur, try killing the app and the starting it again - at one attempt or another it will come to a halt.
  • Android is not a problem.
  • Experiencing on both simulator and device, and both iOS 8.4.x and 9.x.
  • Console / system logs don't appear to show anything useful or relevant.

Use a cordova-plugin-splashscreen from its latest Github master branch since its latest "stable" version 3.1.0 has a bug related to the AutoHideSplashScreen config.xml parameter.

This might just be a pure Cordova core or plugins bug but as said - so far I haven't been able to trigger it with an app that doesn't use Ionic.

My system information:

Cordova CLI: 6.0.0
Gulp version: CLI version 3.9.0
Gulp local:
Ionic Version: 1.2.4
Ionic CLI Version: 1.7.14
Ionic App Lib Version: 0.7.0
ios-deploy version: 1.8.4
ios-sim version: 5.0.6
OS: Mac OS X El Capitan
Node Version: v4.2.4
Xcode version: Xcode 7.2.1 Build version 7C1002

cordova-ios 4.0.1

Most helpful comment

@pke I use cordova 6.0.0 and [email protected].

You need to remove platform ios first, then add it back to 4.1.0 version

ionic platform remove ios
ionic platform add [email protected]

All 79 comments

Download a demo app here: http://1drv.ms/20rf9fu

  • Make sure you have Cordova 6.0.0 installed
  • Run ionic platform add ios
  • Run ionic emulate ios

Start the app and see the splash screen not go away when it should. If it does go away, kill the app and start it again. Repeat until reproduced.

@mhartington Please have someone look at this to at least reproduce and get the case going. I will also write on the Cordova Dev mailing list.

As said, personally I wasn't able to reproduce without Ionic. But maybe someone will. In such a case we can close the case here and move it in Cordova's Jira.

try with the latest version of the splash plugin on github that has the AutoHideSplashScreen problem fixed

@jcesarmobile I know. But this problem occurs with a plugin version from the latest master. See the config.xml in the demo app (ionicSplash.zip).

cc @daserge

Ok so I've been able to replicate this but it's very hit and miss. I see it once, kill the process, and it works fine again. But I haven't been able to pin point the exact cause of it yet

@mhartington If you clone https://github.com/rossholdway/ionic-ios-cordova-bug and run that on an actual device the 'freeze' frequently occurs. (manually booting angular seems to cause it a lot, maybe some sort of race condition).

Now check this out Mike: Remove the device plugin from the config, then ionic state clear, ionic platform add ios and ionic emulate ios. I tried pretty hard to reproduce in such a case but the problem oddly disappeared.

I mean, try it with the latest version of the splash plugin on github that has the AutoHideSplashScreen problem fixed, because maybe your issue is fixed too, just to confirm.

@jcesarmobile I'm pulling the plugin right from github and can see it

@jcesarmobile not sure how to make myself anymore clearer. I do use the latest version from master, not 3.1.0.

Okay so some update information
So when the splashscreen does fail, it's still logging out Calling navigator.splashscreen.hide.

Still very hit and miss, but this does seem like a race condition

@zarko-tg and @rossholdway, can you try this out in our demos?

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    console.log('Calling splashscreen hide');
  }).then(function(){
    navigator.splashscreen.hide();
  });
})

@mhartington true. Other than that, if you wrap the _hide_ call for example with a setTimeout of couple of seconds, the problem will be gone. I thus suspect some race condition in Cordova, Ionic/Angular or in relation to one another. I had a hard time scratching my head today.
A blocker for moving onto Cordova 6.0.0 in our case.

@mhartington first thing tomorrow. I'm still on Windows at home for some reason.

There's some work-arounds right now, like moving that splashscreen.hide call into the .then, which will wait until the promise is resolved. Will look into this tomorrow

I'm not sure my issue #5318 is related to the splash screen... The app sometimes freezes for me before the console.log can output anything.

Hi guys,
Investigating this issue - indeed repros only on Cordova 6.0.0 + [email protected].
It in fact repros with [email protected] as well after fixing AssetCatalog image paths:

    // Add Asset Catalog specific prefixes
    if ([imageName isEqualToString:@"LaunchImage"])
    {
        if (device.iPhone4 || device.iPhone5 || device.iPad) {
            imageName = [imageName stringByAppendingString:@"-700"];
        } else if(device.iPhone6) {
            imageName = [imageName stringByAppendingString:@"-800"];
        } else if(device.iPhone6Plus) {
            imageName = [imageName stringByAppendingString:@"-800"];
            if (currentOrientation == UIInterfaceOrientationPortrait || currentOrientation == UIInterfaceOrientationPortraitUpsideDown)
            {
                imageName = [imageName stringByAppendingString:@"-Portrait"];
            }
        }
    }

Otherwise the splashscreen will not even show because of the image could not be found:
WARNING: The splashscreen image named LaunchImage-736h was not found

@mhartington making the call to navigator.splashscreen.hide after $ionicPlatform.ready resolved does not make a big difference as it is stil possible to reproduce. However, the mystery deepened even further after some more testing with the following code:

.run(function($ionicPlatform) {
  var t = performance.now();
  console.log('Calling $ionicPlatform.ready');

  $ionicPlatform.ready(function() {
    console.log('$ionicPlatform.ready took ' + (performance.now() - t) + ' ms.');
    t = performance.now();
  }).then(function() {
    console.log(
      '$ionicPlatform.ready resolve took ' + (performance.now() - t) + ' ms. '
        + 'Calling navigator.splashscreen.hide'
    );
    navigator.splashscreen.hide();
    console.log('navigator.splashscreen.hide called');
  });
})

when ran on my iPhone 6 (with iOS 9.3 13E5191d).

Here's some of the log output taken using _idevicesyslog | grep ionicSplash_:

09:50:13 ... [8032] <Warning>: Apache Cordova native platform version 4.0.1 is starting.
09:50:13 ... [8032] <Warning>: Multi-tasking -> Device: YES, App: YES
09:50:13 ... [8032] <Warning>: Using UIWebView
09:50:14 ... [8032] <Warning>: [CDVTimer][handleopenurl] 0.186980ms
09:50:14 ... [8032] <Warning>: Unlimited access to network resources
09:50:14 ... [8032] <Warning>: [CDVTimer][intentandnavigationfilter] 2.368987ms
09:50:14 ... [8032] <Warning>: [CDVTimer][gesturehandler] 0.154018ms
09:50:14 ... [8032] <Warning>: [CDVTimer][splashscreen] 40.008008ms
09:50:14 ... [8032] <Warning>: [CDVTimer][TotalPluginStartup] 43.819964ms
09:50:14 ... [8032] <Warning>: Resetting plugins due to page load.
09:50:14 ... [8032] <Error>: Ring Logging is disabled
09:50:14 ... [8032] <Warning>: Finished load of: file:///var/containers/Bundle/Application/4DFB0B3A-EB6A-4E07-A0BD-659487998B37/.app/www/index.html#/tab/dash
09:50:14 ... [8032] <Warning>: $ionicPlatform.ready took 347.33000000000004 ms.
09:50:14 ... [8032] <Warning>: $ionicPlatform.ready resolve took 17.029999999999973 ms. Calling navigator.splashscreen.hide
09:50:14 ... [8032] <Warning>: navigator.splashscreen.hide called
09:50:41 ... [8033] <Warning>: Apache Cordova native platform version 4.0.1 is starting.
09:50:41 ... [8033] <Warning>: Multi-tasking -> Device: YES, App: YES
09:50:41 ... [8033] <Warning>: Using UIWebView
09:50:41 ... [8033] <Warning>: [CDVTimer][handleopenurl] 0.126004ms
09:50:41 ... [8033] <Warning>: Unlimited access to network resources
09:50:41 ... [8033] <Warning>: [CDVTimer][intentandnavigationfilter] 2.272010ms
09:50:41 ... [8033] <Warning>: [CDVTimer][gesturehandler] 0.154972ms
09:50:41 ... [8033] <Warning>: [CDVTimer][splashscreen] 40.107012ms
09:50:41 ... [8033] <Warning>: [CDVTimer][TotalPluginStartup] 43.406010ms
09:50:41 ... [8033] <Warning>: Resetting plugins due to page load.
09:50:41 ... [8033] <Error>: Ring Logging is disabled
09:50:42 ... [8033] <Warning>: Finished load of: file:///var/containers/Bundle/Application/4DFB0B3A-EB6A-4E07-A0BD-659487998B37/.app/www/index.html#/tab/dash

As you can see, the first attempt until 09:50:41 goes well. (In meantime I kill the app and start it again at 09:50:41). If the log is to be trusted, not even the callback of Angular's run gets executed.

And here comes the fun part - I decided to just set AutoHideSplashScreen to true and comment out _navigator.splashscreen.hide();_ in the code above. At some attempt after killing the app and starting it, the spash screen would get auto-hidden as expected but the app (UI) would become unresponsive and eventually crash. Again, the logger didn't indicate that anything was executed in the callback of Angular's run method.

So @rossholdway could be right.

Update: it repros on 5.4 as well.
Hang occurs when Device plugin and SplashScreen plugin are both installed (only splashscreen works as well as only device).
https://issues.apache.org/jira/browse/CB-10530 - I thought it could be caused by an infinite recursive call in splahscreen plugin method swizzling - but it's not the case.

What I just found out is that the problem occurs when using cordova-ios engine 4.0.1 but not when using 3.9.2. Note that in both cases I used the cordova 6.0.0 CLI.
I suspect the root cause or trigger for this issue resides in changes done between 3.9.2 and 4.0.x of cordova-ios.

@zarko-tg I can also confirm that the issue only happens with Cordova iOS 4.0.0 and 4.0.1.

cc @shazron

Has anyone been able to replicate this with using ionic or angular?

It reroduces on ionic@latest but not on a blank cordova app.

Keeping everyone update. Spent all morning trying to debug this. It seems to be a race condition at the native level so far. Right now I've come up with

splash screen only - all good
device only - all good
splash screen + device - hit and miss but it breaks device ready

It seems the ball is in Cordova's yard. I suggest the case continues at https://issues.apache.org/jira/browse/CB-10530.

Ionic devs may reopen this thread if necessary.

Update


Case should now be closed by the good folks of Apache Cordova.
The release of cordova-ios 4.1.0 addresses the issue as stated here: http://cordova.apache.org/announcements/2016/03/02/ios-4.1.0.html

I downloaded 4.1.0 and still getting the same error. I'm on a really tight schedule here so any help would be great.

The issue is not solved. I wonder what the device plugin can possibly do that causes a deadlock. Its not supposed to do anything before its queried by the apps developer in the first place. Strange plugin.

I've solved this issue by performing a complete uninstall of node (version 5.x) and reinstall the last stable version of nodejs (version 4.4.x).
For the record, i got it working with cordova version 6.0.0 and ionic v 1.7.x on mac osx
Hope help someone.

Having the same issue, my app need to be released asap. Need to solve this issue. Thanks if anyone can help! I am using ionic. I update all the latest version (both cordova and ionic)

I solved this by changin my cordova ios platform from 4.0.1 to 3.8. Nothing
helped other than this.

19 Mart 2016 Cumartesi tarihinde, Emmy Chen [email protected]
yazdı:

Having the same issue, my app need to be released asap. Need to solve this
issue. Thanks if anyone can help!


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
https://github.com/driftyco/ionic/issues/5324#issuecomment-198750676

This should be fixed in Cordova-iOS 4.1.

ionic platform add [email protected]

@mhartington it isn't. The culprit is the device plugin. I don't use the useless splashscreen here.

@mhartington Thanks. I updated to [email protected] I am still testing my app. I will let you know if the freeze issue is gone or not.

The issue seems to be solved after upgrading to [email protected].

Yes. I have not find my app freeze after upgrade to [email protected]. That is great!

hi @martinezleoml I have the same problem, my app runs on android with no problem but on ios it gets freeze on the ionic splash screen, I have read the post saying that 4.1.0 will solved this issue, but I just update and I get the same problem, looks like ionic doesn't get trigger. Any help how to solved this issue.

2016-03-21 17:58:23.586 AdminApp[334:24810] DiskCookieStorage changing policy from 2 to 0,     cookie file: file:///private/var/mobile/Containers/Data/Application/8ACD937F-ECC1-42BF-A830-    D694662748D1/Library/Cookies/Cookies.binarycookies
2016-03-21 17:58:23.721 AdminApp[334:24810] Apache Cordova native platform version 4.1.0 is starting.
2016-03-21 17:58:23.722 AdminApp[334:24810] Multi-tasking -> Device: YES, App: YES
2016-03-21 17:58:23.856 AdminApp[334:24810] Using UIWebView
2016-03-21 17:58:23.861 AdminApp[334:24810] [CDVTimer][handleopenurl] 0.283003ms
2016-03-21 17:58:23.863 AdminApp[334:24810] [CDVTimer][intentandnavigationfilter] 2.087951ms
2016-03-21 17:58:23.864 AdminApp[334:24810] [CDVTimer][gesturehandler] 0.132024ms
2016-03-21 17:58:23.890 AdminApp[334:24810] [CDVTimer][splashscreen] 26.520014ms
2016-03-21 17:58:23.917 AdminApp[334:24810] [CDVTimer][localstorage] 26.280999ms
2016-03-21 17:58:23.917 AdminApp[334:24810] [CDVTimer][TotalPluginStartup] 56.608021ms
2016-03-21 17:58:24.232 AdminApp[334:24810] Resetting plugins due to page load.
2016-03-21 17:58:24.822 AdminApp[334:24810] Finished load of: file:///var/mobile/Containers/Bundle/Application/505434F3-D1B1-4344-9426-F990E82D61E4/AdminApp.app/www/index.html

@cesar-oyarzun-m You need to update your cordova-ios to 4.1.0 . The issue has been fixed there.

@emmychen I did update the Cordova iOS, I posted the console logs but I still have the same issue, maybe something else, do you have example project ?

@emmychen you saw that @cesar-oyarzun-m wrote he just updated to 4.1.0 and the issue is not solved. I reported the same several posts before.

I'm testing on Xcode 7.2 , ionic v1.7.14 , cordova 6.0.0, simulator ipad air 9.2. Here is my list of plugins

com.scala.BeaconController 0.0.1 "BeaconController"
cordova-plugin-console 1.0.2 "Console"
cordova-plugin-device 1.1.1 "Device"
cordova-plugin-geolocation 2.1.0 "Geolocation"
cordova-plugin-inappbrowser 1.2.1 "InAppBrowser"
cordova-plugin-network-information 1.2.0 "Network Information"
cordova-plugin-splashscreen 3.1.0 "Splashscreen"
cordova-plugin-whitelist 1.2.1 "Whitelist"

I have try several things nothing works, I update all my plugins dependency and the only difference is that now the cordova logo disappear and I get blank screen.
@pke @emmychen Can you open the web inspector?, I have try but I get blank screen if I try to open my index.html

Hi guys, we do have the same issue appearing after cordova-ios update to 4.1.0. As @pke said, the problem is the device plugin. After removing it the freezes stop.

Last log from device was
<Error>: CoreAnimation: failed to allocate IOSurface

ionic platform add [email protected]

Worked for me to fix the problem. I have the device and splashscreen plugins.

@amit777 Which versions of those plugins?

@pke I use cordova 6.0.0 and [email protected].

You need to remove platform ios first, then add it back to 4.1.0 version

ionic platform remove ios
ionic platform add [email protected]

We're seeing the same issue. We can reproduce it with this in the AppDelegate.m

NSUInteger sizeInMB = 300; 
int * unusedMemoryBufferToSimulateMemoryScarcity = NSZoneCalloc(NSDefaultMallocZone(), sizeInMB * 1024 * 1024, 1);
if (NULL == unusedMemoryBufferToSimulateMemoryScarcity) {
       NSLog(@"MEMORY STRESS TEST FAILED: Was unable to allocate requested memory");
       return;
   }

for (int n=0;n<=(sizeInMB/4 * 1000000);n+=4096)
{
    *(unusedMemoryBufferToSimulateMemoryScarcity + n) = 99;
    int aVar = *(unusedMemoryBufferToSimulateMemoryScarcity + n);

}

Call this in application didFinishLaunchingWithOptions before initialising the main controller.

If we remove the Devices plugin then the issue goes away.
Trouble is we need it for the push notifications.

Any suggestions as to where to look next most welcome.

There seems to be some interaction with

  CDVCommandQueue fetchCommandsFromJs

and the memory warning... but could be wrong.

@IonicNick are you using cordova-ios 4.1.0?

@mhartington Just switched to it after that message and 8 restarts and no issue.
So yes cordova-ios 4.1.0 appears to solve it for us too.

Just upgraded to ios 4.1.1 and white screen after splash screen :( @mhartington

Please check the safari dev tools for errors. Also update any plugins you have installed

@mhartington
I checked and updated every single plugin. On my system log console I found my app giving this error from iphone simulator.
ERROR Internal navigation rejected - not set for url='http://192.168.1.5:8100/'

Guess it's fixed :) thank you
had to add <allow-navigation href="*"/> on my config file

Still able to reproduce it on an iPad 8.4 and Cordova iOS 4.1.1. No errors shown.

Reverting to iOS 3.9.2 solves the issue

Hi guys,I have to publish app to test flight today and i just used 3 hours to fix this...

Last time I changed the code, the app was working great on my own iPhone, but today the app only work for emulator but not the real phone. I tried all the things you guys said but it all doesn't.

My boss just added me to the company develop team account yesterday, but today I am still using my own account (not paid), so after I change the provisioning file to the develop team, the app doesn't stuck at splash screen anymore.

my ios version is 3.9.2

I hope this is helpful.

After I change the backend url, my trick doesn't work :( and I tried all the solution above this comment, the app still stuck at a white screen with a spinning loader :S

@BVJin, the issue does not reproduce for me neither on cordova-ios@3, nor on cordova-ios@4 with ionic tabs template.
Try upgrading to cordova-ios@4:
cordova platform add ios@4

Which device and iOS versions are you using?

upgraded to cordova-ios@4 and I still got the problem.

I fixed/patch it by wrapping $ionicPlatform.ready's content with a $timeout of 100 ms.

I am hiding the splash screen on "deviceready" event, wich is also inside.

Here's the pseudo code:

$ionicPlatform.ready
--- $timeout (100ms)
------ document.addEventListener("deviceready", onDeviceReady, false);

I was noting that the:
if (window.StatusBar) {
StatusBar.styleDefault();
}
(wich is also inside the platformready function)
didn't seems to be called, as the top status bar on the iPhone was not changing when it was hanging.

but with the timeout, now it's working each time!

just wanted to let you know how I fixed it!
Hope it can help...

Still looking for a real fix! ;)

Please make sure you're also upgrading the plugins etc. It's more than just updating the platform, you need to make sure the plugins are updated as well.

My project was generated using Visual Studio 2015.
Do you have instructions on how to upgrades the plugins please? Thank you!

@daserge I tried both ios@3 and ios@4, and they don't work.

@mhartington upgraded the device plugin (which was 1.1.1) to 1.1.2 and the Splashscreen plugin was already to the last 3.1.0 release.

I removed my "fix" and still have the splashscreen hanging sadly :(

@baltazarqc, the latest published splashscreen version is 3.2.2.

@daserge hmm, I'll try to manually install it, because inside VS config.xml interface, when I remove and add the suggested, it install the 3.1.0 version.

Thank you, will upgrade then try again!

Will keep you informed.

@mhartington is cli
ionic state reset
the right way to upgrade all plugin?

or I have to cordova rm and cordova add one by one?

@daserge actually, it's 4.0.0! https://github.com/apache/cordova-plugin-splashscreen <<<

That's the version in development, latest release is 3.2.2 https://github.com/apache/cordova-plugin-splashscreen/releases

@BVJin yes, state reset will clear everything out and add them back.

thank you @jcesarmobile ! will take this one! ;)

@mhartington I just ionic state reset and this is plugin I have:

cordova-plugin-console 1.0.3 "Console"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-google-analytics 0.8.1 "Google Universal Analytics Plugin"
cordova-plugin-inappbrowser 1.1.1 "InAppBrowser"
cordova-plugin-splashscreen 3.0.0 "Splashscreen"
cordova-plugin-statusbar 2.0.0 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
cordova-plugin-x-socialsharing 5.1.1 "SocialSharing"
cordova-plugin-x-toast 2.3.2 "Toast"
cordova-sqlite-storage 0.7.14 "Cordova sqlite storage plugin"
ionic-plugin-keyboard 1.0.9 "Keyboard"
pushwoosh-cordova-plugin 5.0.3 "Pushwoosh"

it doesn't fix the issue.

As @jcesarmobile said, the splash plugin already update to 3.2.2, so I manually cordova rm and cordova add 3.2.2

still white screen...

@BVJin can you attach the safari dev tools? Maybe it's something else?

@mhartington I did that all the time, no errors and warnings
The weird thing is the app was working before I changed the backend url, it basically one line code. And even I change the code back, it doest work. I didn't upgrade my mac and iphone OS during these time.

Been fighting this issue all afternoon...
I was running Cordova version 6.2.0 and Cordova-ios 4.1.0 on a mac.
Even running the emulator just opened the screen, and then crashed immediately.

I reverted cordova-ios:
cordova platform remove ios
cordova platform add ios@3
Everything works again as expected after this.

First thing I noticed was that I had a JavaScript error in my app, right after startup (just a silly bug that threw an error).
I start to get the feeling that if there's an error in your app's code, cordova-ios 4+ can not handle this and will crash and close itself immediately (at least on startup, not when it has been running for a few seconds.)

i confirm this bug, working fine on my phones and crush happened only on tablet nexus 7, im using cordova 6.1.1.

Please make sure you updating your plugins, your platforms and everything else.
Also, check for JS error. Make sure your own code isn't causing problems.
Please open an new issue with a sample project that replicates the issue.

Was this page helpful?
0 / 5 - 0 ratings