DavidTalevski commented on issue #1650: URL: https://github.com/apache/cordova-android/issues/1650#issuecomment-1691209729
> Your config indicates that you're letting Cordova auto hides the splashscreen with a `0` delay, which (without checking) I believe occurs when the webview loads up. > > You can have a look at the [splashscreen plugin](https://github.com/apache/cordova-android/blob/e61e271f5bbb517a9598078f7a1ad7585bfe5f9c/framework/src/org/apache/cordova/SplashScreenPlugin.java#L131) that's embedded into the cordova framework to see when it exactly dismisses it. Note that by explicitly assigning `SplashScreenDelay` Cordova is treating this as a custom delay, so it creates a handler to be delayed `0ms` later (in otherwords when the next time the main thread is free). > > If this is taking more than 5 seconds to trigger then it could be a cause for the ANR. If this is the case, I suspect a plugin or plugin(s) to be the cause of the delay. > > If you remove the `SplashScreenDelay` preference, or set it to `-1` , then it should trigger Cordova to immediately set the keep flag to [false](https://github.com/apache/cordova-android/blob/e61e271f5bbb517a9598078f7a1ad7585bfe5f9c/framework/src/org/apache/cordova/SplashScreenPlugin.java#L166), which allows the Android to dismiss the splashscreen as soon as possible, though this may occur before your webview actually has finished loading. > > For more info on how splashscreens trigger ANR you can read: #1510 > > If your splashscreen is dismissing quickly (less than 5 seconds), then splashscreen is probably not the source of your ANR. In which case, you'll probably need to use Android Studio to [trace](https://developer.android.com/topic/performance/vitals/anr#pull_a_traces_file) the problem. I've done a lot of testing with `SplashScreenDelay` and I've gotten the best results by setting it to 0. Here are some averages I collected on a hot startup time on a Xiaomi Redmi Note 8 Pro: Setting `SplashScreenDelay` to `"-1"` gave an average of `+2s454ms`. Setting `SplashScreenDelay` to `"0"` gave an average of `+930ms`. Removing the `SplashScreenDelay` preference gave the same results as setting it to `"-1"` which is normal as I believe it is the default value. By reading the documentation on [SplashScreenDelay](https://cordova.apache.org/docs/en/11.x/core/features/splashscreen/index.html#splashscreendelay) it says that `Android -1: The splash screen will automatically hide when the onPageFinished has been triggered.`, which, to my understanding, means that my page has to finish loading before the splashscreen is removed, which explains why it is about 1.5 seconds slower. When I compare the app to other apps, the startup time is about twice to three times slower. Is there a way to hide the splashscreen before the page loads without setting a custom delay? -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
