-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Let the Android embedding adopt OnPreDrawListener #85292
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
Comments
@jiahaog any updates on this issue? Let me know if you want me to take a look, and go ahead with the PR. |
One consideration to make though wrt #85139 is that it still can't make Android's first frame a correct measurement of Flutter's first frame, since Android's first frame will still be [Flutter's first frame] + [time needed to jump from raster to main thread and get a next Android vsync] = [Android's first frame]. |
Yes, I've started looking at it, will follow up with a PR soon |
What about if we check if the user has supplied a Also, is there a valid use case for this custom splash screen API? could we deprecate it, and document that it's not longer needed? @xster any thoughts? |
@blasten we may still need a flag - users may still want to provide There are a few approaches I can think of: Option 1: Support the Flutter-specific splash screen for APIs >= 31There may be a jarring transition here depending on how users set up their Flutter splash screen. But in this case, we continue to show the provided drawable. This will require a flag roughly named
The guidance here is for users who want to show a splash screen to do the following, which are not mutually exclusive, and since the API 31 rollout may take a while:
Option 2: Don't support the Flutter-specific splash screen for APIs >= 31Another approach is to use preDraw unconditionally for APIs >= 31. This is probably breaking, since the provided splash screens through Do we need to worry about the V1 embedding? I also noticed the existence of the |
Jotting down my findings as well about how it works today on cold start. API < 31
API 31
|
Thanks Jia. I was under the impression that the custom Flutter splash screen was added because we didn’t know that we could delay showing the Android view hierarchy until Flutter painted the first frame. If this is true, then this feature is not longer necessary. I’d like to see a real world use case where a secondary splash screen is needed because the oficial Android splash screen isn’t sufficient. have you seen this case internally? |
Note that |
From what I can see, most use cases internally point their |
Thanks Jia. Do we still need the flag |
Not sure if we should reuse it - the linked check comes from the I do like the simplicity of not having a flag though as you've mentioned. Do you know if there are other valid external use cases of manually providing a splash screen? |
There's also the equivalent in the V2 embedding: https://github.com/flutter/engine/blob/138c91c614d742c52aa5432b4cb921f0ff9fdee2/shell/platform/android/io/flutter/embedding/android/FlutterActivityLaunchConfigs.java#L16 |
Right, I think we were both referring to that flag ( |
We synced up, next steps:
|
@jiahaog I just tested it on Android 30/ Moto G7. No white splash. However, I do see the fade-out transition. I changed the custom drawable bg color to purple, and I see a fade-out purple background that gets blended with the color I set in the initial Android splash screen. |
Here's the code I added to FlutterView.java: private void init() {
// ... current code ... //
this.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
return isFlutterUiDisplayed;
}
});
} |
Yeah, I can reproduce that as well. I must have remembered something wrongly, apologies for the confusion. As discussed, I'll work on a PR for the following then:
|
Update: Working on a PR for what was discussed above |
flutter/engine#27645 was rolled back in flutter/engine#27788 because it broke some devicelab tests.
Will investigate and try to reland |
@jiahaog flutter/engine#27811 seems to have landed. Can we close this issue? |
I think so |
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 |
Uh oh!
There was an error while loading. Please reload this page.
Internal bugs: http://b/190767277, http://b/185423816
Using https://developer.android.com/reference/android/view/ViewTreeObserver.OnPreDrawListener to delay when Flutter's activity first draws can help solve
Things this might involve:
The text was updated successfully, but these errors were encountered: