cordova-android
cordova-android copied to clipboard
Splashscreen blinks on hide and Icon zoomed (Android 12+ API 32+)
Bug Report
Problem
Splashscreen suddenly blinks before hide on device 32 API
Steps to reproduce
Simply create and launch few times clear cordova app with cordova-android@11
Information

Environment, Platform, Device
MacOS Ventura 13.0
Simulator Pixel 4 XL API 32
Version information
node --version
v16.18.0
cordova --version
11.0.0
Checklist
- [x] I searched for existing GitHub issues
- [x] I updated all Cordova tooling to most recent version
- [x] I included all the necessary information above
I suspect this is related to the same cause as I have experienced in https://github.com/apache/cordova-android/issues/1501#issuecomment-1294202691
On Android 12+, there is a postSplashScreenTheme that is applied when the splash finishes hiding. For what your gif there shows, it seems to me like this is the culprit.
Have you tried
<preference name="AutoHideSplashScreen" value="false" />
in config.xml and then using navigator.splashscreen.hide(); in your JavaScript once everything is loaded? Possibly with a setTimeout(() => navigator.splashscreen.hide(), 3000);
@nijakobius tried. This doesn't helps.
What exactly happens? Does the blinking occur after the 3000ms delay? To make it clearer try 10000ms
@nijakobius a very bad practice and must be fixed in correct way.
@roman-rr Sure but understanding what is happening and when it's happening helps fixing it in the correct way, thus the question :)
@nijakobius thank you. In case. just tried 25000ms timeout and still same blink. With dummy cordova@11 application.
This is quite annoying. Anyone figured out a way to stop the blinking? Nothing of the above works for me, including messing with postSplashScreenTheme .
Hi, Is this a problem on Android 12 or 13? I have a OnePlus 8T with Android 12 + Cordova Android 11 (Api level 32) application and it works perfectly. (I use programmatically splashscreen.hide() function). Have you try to define your own image? Maybe the problem occurs only with the default one?
In config.xml :
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/splash/splashscreen.png" /
<preference name="AndroidWindowSplashScreenIconBackgroundColor" value="#FFFFFF" />
Kr.
@TiBz0u It seems to work fine with a standard .png image. But when using an animated-vector (.xml) file i always get the blinking. But hey, i am just using a standard .png image for now, as you also wrote above. Cheers!
I too is using an rasterized PNG image instead of an animated vector file and don't see the flash, so far I think we have isolated the issue to animated vectors.
Just in case: Blinks reproduced within API 32, but not lower versions.
And just default cordova app created with command
$ cordova create MyApp
Looks like Android bug to me, After a month of searching I still coudn't find answer. Another example of blinking (https://user-images.githubusercontent.com/87377447/199126503-75637705-895f-47a1-985c-b14a4c5ba068.mp4)
Also Animated Vector Drawable fadeOut bug https://user-images.githubusercontent.com/87377447/199131487-c5db6ba5-22e1-41ec-9791-05c3ccacdf7b.mp4)
It has something to do with setting image to alpha 1f before animating it to alpha 0, if you see code where splashImage has something like this:
splashImage.setAlpha(1f);
Following by
splashImage
.animate()
.alpha(0)
.setInterpolator(new LinearInterpolator())
.setDuration(fadeOutDuration)
.setListener(listener)
.start();
You need to calculate the remaining alpha, you can't just set 1, similar to this code for calculating remaining duration (this code example is not for calculating remaining alpha):
// Get the duration of the animated vector drawable.
Duration animationDuration = splashScreenView.getIconAnimationDuration();
// Get the start time of the animation.
Instant animationStart = splashScreenView.getIconAnimationStart();
// Calculate the remaining duration of the animation.
long remainingDuration;
if (animationDuration != null && animationStart != null) {
remainingDuration = animationDuration.minus(
Duration.between(animationStart, Instant.now())
).toMillis();
remainingDuration = Math.max(remainingDuration, 0L);
} else {
remainingDuration = 0L;
}
https://developer.android.com/develop/ui/views/launch/splash-screen
This bug is for Android 12.0+
For some reason I can't reproduce this blinks on real device with following configuration:
<preference name="FadeSplashScreenDuration" value="250" />
<preference name="FadeSplashScreen" value="true" />
<preference name="ShowSplashScreenSpinner" value="true" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="SplashScreenDelay" value="-1" />
<preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/splash.png" />
But other configurations will give me a blinks on real device to.