Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: Launch freeze/crash on manual splash screen hiding #5324

Closed
zarko-tg opened this issue Feb 3, 2016 · 79 comments
Closed

bug: Launch freeze/crash on manual splash screen hiding #5324

zarko-tg opened this issue Feb 3, 2016 · 79 comments
Assignees

Comments

@zarko-tg
Copy link

zarko-tg commented Feb 3, 2016

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

@Ionitron Ionitron added the v1 label Feb 3, 2016
@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

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.

@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

@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.

@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

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.

@jcesarmobile
Copy link
Member

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

@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

@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).

@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

cc @daserge

@mhartington
Copy link
Member

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

@rossholdway
Copy link
Contributor

@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).

@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

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.

@jcesarmobile
Copy link
Member

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.

@mhartington
Copy link
Member

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

@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

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

@mhartington
Copy link
Member

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

@mhartington
Copy link
Member

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();
  });
})

@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

@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.

@zarko-tg
Copy link
Author

zarko-tg commented Feb 3, 2016

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

@mhartington
Copy link
Member

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

@rossholdway
Copy link
Contributor

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.

@daserge
Copy link

daserge commented Feb 4, 2016

Hi guys,
Investigating this issue - indeed repros only on Cordova 6.0.0 + cordova-ios@4.0.1.
It in fact repros with cordova-plugin-splashscreen@3.0.0 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

@zarko-tg
Copy link
Author

zarko-tg commented Feb 4, 2016

@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.

@daserge
Copy link

daserge commented Feb 4, 2016

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.

@zarko-tg
Copy link
Author

zarko-tg commented Feb 4, 2016

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.

@rossholdway
Copy link
Contributor

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

@daserge
Copy link

daserge commented Feb 4, 2016

cc @shazron

@mhartington
Copy link
Member

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

@NickThorne123
Copy link

@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.

@ibnbd
Copy link

ibnbd commented Apr 30, 2016

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

@mhartington
Copy link
Member

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

@ibnbd
Copy link

ibnbd commented Apr 30, 2016

@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/'

@ibnbd
Copy link

ibnbd commented Apr 30, 2016

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

@mirko77
Copy link

mirko77 commented May 11, 2016

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

@BVJin
Copy link

BVJin commented May 26, 2016

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.

@BVJin
Copy link

BVJin commented May 31, 2016

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

@daserge
Copy link

daserge commented May 31, 2016

@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?

@baltazarqc
Copy link

baltazarqc commented May 31, 2016

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! ;)

@mhartington
Copy link
Member

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.

@baltazarqc
Copy link

baltazarqc commented May 31, 2016

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

@BVJin
Copy link

BVJin commented May 31, 2016

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

@mhartington
Copy link
Member

@baltazarqc
Copy link

baltazarqc commented May 31, 2016

@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 :(

@daserge
Copy link

daserge commented May 31, 2016

@baltazarqc, the latest published splashscreen version is 3.2.2.

@baltazarqc
Copy link

@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.

@BVJin
Copy link

BVJin commented May 31, 2016

@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?

@baltazarqc
Copy link

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

@jcesarmobile
Copy link
Member

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

@mhartington
Copy link
Member

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

@baltazarqc
Copy link

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

@BVJin
Copy link

BVJin commented May 31, 2016

@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...

@mhartington
Copy link
Member

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

@BVJin
Copy link

BVJin commented May 31, 2016

@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.

@mhartington
Copy link
Member

@dotdotcommadot
Copy link

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.)

@Rakonda
Copy link

Rakonda commented Jun 30, 2016

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

@mhartington
Copy link
Member

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.

@ionic-team ionic-team locked and limited conversation to collaborators Jun 30, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests