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

Splashscreen blinks on hide and Icon zoomed (Android 12+ API 32+) #1514

Open
3 tasks done
roman-rr opened this issue Oct 27, 2022 · 14 comments
Open
3 tasks done

Splashscreen blinks on hide and Icon zoomed (Android 12+ API 32+) #1514

roman-rr opened this issue Oct 27, 2022 · 14 comments
Labels

Comments

@roman-rr
Copy link

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

ezgif-3-29d5ee817f

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

  • I searched for existing GitHub issues
  • I updated all Cordova tooling to most recent version
  • I included all the necessary information above
@peitschie
Copy link
Contributor

I suspect this is related to the same cause as I have experienced in #1501 (comment)

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.

@nijakobius
Copy link

nijakobius commented Oct 31, 2022

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

@roman-rr
Copy link
Author

@nijakobius tried. This doesn't helps.

@nijakobius
Copy link

What exactly happens? Does the blinking occur after the 3000ms delay? To make it clearer try 10000ms

@roman-rr
Copy link
Author

@nijakobius a very bad practice and must be fixed in correct way.

@nijakobius
Copy link

nijakobius commented Oct 31, 2022

@roman-rr Sure but understanding what is happening and when it's happening helps fixing it in the correct way, thus the question :)

@roman-rr
Copy link
Author

@nijakobius thank you. In case. just tried 25000ms timeout and still same blink.
With dummy cordova@11 application.

@JesperBalslev
Copy link

This is quite annoying. Anyone figured out a way to stop the blinking? Nothing of the above works for me, including messing with postSplashScreenTheme .

@TiBz0u
Copy link

TiBz0u commented Nov 16, 2022

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.

@JesperBalslev
Copy link

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

@breautek
Copy link
Contributor

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.

@roman-rr
Copy link
Author

Just in case: Blinks reproduced within API 32, but not lower versions.
And just default cordova app created with command

$ cordova create MyApp

@breautek breautek added the bug label Nov 17, 2022
@george-martinec
Copy link

george-martinec commented Jan 30, 2023

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+

@roman-rr
Copy link
Author

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.

@roman-rr roman-rr changed the title Splashscreen blinks on hide (Android 12 API 32) Splashscreen blinks on hide and Icon zoomed (Android 12 API 32) Aug 28, 2023
@roman-rr roman-rr changed the title Splashscreen blinks on hide and Icon zoomed (Android 12 API 32) Splashscreen blinks on hide and Icon zoomed (Android 12+ API 32+) Aug 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants