Fix ios black screen during splash screen if widget binding initializ…#52913
Fix ios black screen during splash screen if widget binding initializ…#52913fluttergithubbot merged 8 commits intoflutter:masterfrom
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie. Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
Gold has detected one or more untriaged digests on patchset 4. |
|
apparently it broke all the tests, I will add a WIP label |
| bool _appHasBootStapped = false; | ||
|
|
||
| @override | ||
| bool get framesEnabled => super.framesEnabled && _appHasBootStapped; |
There was a problem hiding this comment.
"BootStapped" isn't english... what did you mean? :-)
There was a problem hiding this comment.
I misspelled bootstrapped. but your suggestion may be better. will update
There was a problem hiding this comment.
fwiw you ended up going with a different name -- i'm fine with either, just wanted to mention it since you said above that you like the specific name i'd suggested.
There was a problem hiding this comment.
The rootWidgetAttached will confuse with the existing https://api.flutter.dev/flutter/widgets/WidgetsBinding/isRootWidgetAttached.html. This field actually need to be set to true right before attaching the root widget. That is why i change the name.
|
ready for review |
| Element get renderViewElement => _renderViewElement; | ||
| Element _renderViewElement; | ||
|
|
||
| bool _rootWidgetAttached = false; |
There was a problem hiding this comment.
We already have https://master-api.flutter.dev/flutter/widgets/WidgetsBinding/isRootWidgetAttached.html, what's the difference between isRootWidgetAttached and _rootWidgetAttached?
There was a problem hiding this comment.
I see, the name is confusing. I cannot use isRootWidgetAttached because it schedules the first frame during attaching the root widget, the frames should be enabled before that.
There was a problem hiding this comment.
I actually have some question about #40105. What is the issue behind this pr?
There was a problem hiding this comment.
isRootWidgetAttached is just a getter. How does it schedule a frame?
I actually have some question about #40105. What is the issue behind this pr?
The issue is described in the PR's description. What's your question?
There was a problem hiding this comment.
After the change in #39535 we were only scheduling the first frame on accident as a side-effect of the warm-up frame (SchedulerBinding. scheduleWarmUpFrame awaits SchedulerBinding.endOfFrame, which implicitly schedules a frame)
I know it is a fact, but what problem will it cause if we keep this behavior?
There was a problem hiding this comment.
Everything will continue to work as before because the warmup frame schedules the first frame as a side effect. However, if we ever were to remove the warmup frame, things would start to break. Therefore, we decided to make scheduling the first frame more explicit.
|
|
||
| void main() { | ||
| test('The frames will only be enabled after runApp attaches the root widget', () async { | ||
| final WidgetsFlutterBinding binding = WidgetsFlutterBinding.ensureInitialized() as WidgetsFlutterBinding; |
There was a problem hiding this comment.
Why does this need to be casted to a WidgetsFlutterBinding? ensureInitialized returns a WidgetsBinding, which should give you access to everything you may want to call.
There was a problem hiding this comment.
I copied from the other test. will update
| test('The frames will only be enabled after runApp attaches the root widget', () async { | ||
| final WidgetsFlutterBinding binding = WidgetsFlutterBinding.ensureInitialized() as WidgetsFlutterBinding; | ||
| expect(SchedulerBinding.instance.framesEnabled, isFalse); | ||
| // Framework starts with detached statue. Sends resumed signal to enable frame. |
|
ready for review @goderbauer |
…ed before runapp
Description
When ios engine starts up, it will send semantics enable message to framework if the binding has been initialized. Framework will schedule a new frame to make sure the semantics tree gets sent to the engine. This makes engine thinks the framework is ready to produce frame and takes down the splash screen.
This pr make sure scheduler binding only schedule frame when widget binding think it is ready by overriding the frameEnabled getter.
Related Issues
Fixes #39494
Tests
I added the following tests:
"The frames will only be enabled after runApp has bootstrapped the app"
Checklist
Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes (
[x]). This will ensure a smooth and quick review process.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Did any tests fail when you ran them? Please read Handling breaking changes.