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
Splash screen on Android jumps down during startup #47634
Comments
I also encountered this problem, this problem will not occur in lower versions |
I was unable to reproduce on an emulator Pixel 2 API 28. The icon appears to remain in the same place (though I did see a flicker of black between the launch screen and the splash screen that shouldn't be there). I'll try to reproduce on a physical device. |
Same problem for me. a little relieved to see that I'm not alone. ;-) |
I encountered the problem both with physical device or emulators. By adding a drawable splash screen, the problem doesn't occur any more.
But I think it's not the real answer. |
@tfalvo would you mind posting a gif or a short video of the issue happening? I just tried to repro on a physical Pixel device on API 28 and the launch screen and splash screen matched perfectly. |
Actually, I take that back. Upon closely looking at a video of my repro attempt, I do think the logo is jumping slightly. I'll dig deeper into my repro case. |
Here is what I think is happening... In the current "new project" structure for a Flutter app, the By making the change that @Hixie posted originally, the app places an image in the "launch theme", but there is still no "normal theme". As a result, after Android gets past the launch screen, the Presently, if you want to use a launch screen in Flutter you are expected to:
Directions are here: Only step 1 was taken in the case of this reported issue. I am able to achieve the desired splash behavior by extending @Hixie's original steps as follows:
So, technically, I think the issue here is incomplete configuration of splash behavior. However, this issue probably indicates that the process is too confusing, so we should do something to prevent easy mistakes. Possible Improvements
@Hixie @xster do you have any opinions about the possible improvements above? |
This issue seems to have been around for a few stable releases of flutter. It was present with 1.9.x also. I suspect it crept in when much of the enhancement of AddToApp was added. @matthew-carroll I repeated your test and it works. In fact if you remove the normal theme meta data completely, leaving only the SplashScreenDrawable meta data, it also works. So this will also achieve desired behaviour:
So the least effort to remove the 'jump' of a centered graphic on the launch screen is to just add this section to the AndroidManifest.xml:
The new documentation on this page here is pretty good and it does correctly say this (which explains why above works without normal theme):
Possible Improvements
|
Note previously in the AndoidManifest.xml I was using this meta data section:
But with this section there is still a 'jump' of a centered logo image. |
In fact I was trying to make a smooth transition between a static android launch screen image and a Flutter + Rive (Flare) animation (SplashScreen) which starts with the same image (as launch screen)... not sure I'm clear. ;-). But if must add |
@matthew-carroll That page is on the "add-to-app" part of the Web site; should it be moved to the Android section in general? |
After experimenting I can cause the skip on demand. This is one cause, but it may not be the only cause of the 'jump'. So add to your theme the line android:windowDisablePreview to true:
|
@tfalvo I think what you want is a custom The standard |
@workerbee22 do you think it's a good idea to use
Edit: I tried using |
@matthew-carroll disabling the window preview is not great, because there is a slight but noticeable longer startup time before you see the Launch screen. But it is 'less' noticeable than a 'jump' of a logo in the center of the screen. I can't find any other solutions to remove the 'jump' at the moment, so Note I'm still also having problems seeing a black blank screen in some projects as well, despite having a NormalTheme. But this may be because I am using the Android Material Components DayNight as the parent Theme for both launch and normal themes which is currently still 1.2.0-alpha03. So I have this line for both themes:
https://github.com/material-components/material-components-android Reason I'm using using this theme as the parent, is because on Android 10 it adapts to the current devices background color being light or dark themed. I don't think there is any other Android theme that current does this? |
@workerbee22 can you post a minimal project that causes the jump? |
@matthew-carroll Ok I have a minimal project here that shows the jump of the flutter logo when running on a Pixel 3 Xl physical device. See zip file in here: https://drive.google.com/open?id=1fkpDPq7ckU6f2KygxmUcrK_Ud_haZgyi As per the documentation here: https://flutter.dev/docs/development/add-to-app/android/add-splash-screen#showing-a-drawable-splash-screen Which says: To display a splash screen with the same visual as a launch screen, reference the same @drawable/launch_background in the io.flutter.embedding.android.SplashScreenDrawable meta-data. So you will see in this project both the LaunchTheme and the Flutter SplashScreenDrawable use the same @drawable/launch_background Interestingly if you use the |
@workerbee22 thanks for sending that example, I was able to repro what you described. In your case, what you'll want to add to your launch theme is:
The above configuration causes the window to display content beneath the status bar, instead of stopping at the status bar. By flowing content beneath the status bar, the screen becomes slightly taller, which impacts the alignment of a "centered" splash image.
in code because Flutter wants to draw all of the screen's content, including the part beneath the status bar. That's why your splash image appears slightly lower in your launch theme than it does once The issue you experienced in a specific case of a more general situation where developers will need to ensure that their launch theme is congruent with their splash |
@matthew-carroll Thanks that explains it 👍 And I've now re-tested and that does indeed fix it, thank you 🎉 So just for anyone else, this is what I did: 1 - That is remove this line:
2 - and replace it with this line for just the LaunchTheme:
Also yep isn't a bug but probably a common use case, so perhaps consider adding to documentation somewhere because as Flutter Devs we can't easily know what the framework has and has not set by default. So this section of the new splash screen Flutter.dev page, last paragraph? https://flutter.dev/docs/development/ui/splash-screen/android-splash-screen#showing-a-drawable-splash-screen This goes for a few of these android settings in styles, layouts etc. we have to find the Android info and then try them out to see behaviour, because we don't know what the Flutter framework is doing exactly at its interface with Android. Sure we can dive into the framework code, but that would take quite a bit of digging. So same also probably applies to iOS or any platform ie. how do we know what Flutter is doing by default at this interface to the operating system.👍 |
To handle this ticket I have done the following:
https://github.com/flutter/flutter/issues/49267 With these changes I'm going to close this issue. |
This gets rid of the jump, but the drawback is, that the status bar color is black for a few frames, right? or is there a war to avoid that? See behaviour with and with |
I know this issue is closed but with the current documentation and framework behaviour there are some problems that doesn't happens in native.
|
FWIW, I'm getting this on iOS too in flutter 1.16.1-pre.20, dart 2.8.0, where it did not do it on previous versions (though I honestly can't remember how far back this started). |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Steps to reproduce:
flutter create splash_bug
cd splash_bug
android/app/src/main/res/drawable/launch_background.xml
as follows:flutter run
Expected result: Flutter logo centered on the screen and steady for a while, followed by counter app.
Actual result: Flutter logo centered on the screen, then suddenly Flutter logo centered slightly differently on the screen, then counter app.
cc @matthew-carroll and @jason-simmons since you're probably the most knowledgeable about this area...
The text was updated successfully, but these errors were encountered: