Skip to content

fix widget built twice during warm up frame#39079

Merged
chunhtai merged 1 commit intoflutter:masterfrom
chunhtai:issues/31195-fix-warmup
Sep 6, 2019
Merged

fix widget built twice during warm up frame#39079
chunhtai merged 1 commit intoflutter:masterfrom
chunhtai:issues/31195-fix-warmup

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Aug 22, 2019

Description

The runapp work as follow
1, build rendering tree
2, schedule warm up frame
...(async gap)
3, run async draw frame

There is a chance engine will flush user setting in the middle of 2 and 3 which will dirty rendering tree. and draw frame will have to rebuild the rendering tree

With this pr the runapp work as follow
1, schedule build rendering tree
2, schedule warm up frame
...(async gap)
3, run async build rendering tree
4, run async draw frame

In this case, it does not matter whether something try to dirty render tree in the middle of 2 and 3 as there is no rendering tree to dirty.

This will however affect flutter test since it override schedulewarmup frame to be synchronized function to make sure runapp run synchronously. To addjust that, I implements a private runapp that flush timer after the regular runapp and removed the schedulewarmup override.

I do not use the callback solution we talked about @Hixie @goderbauer since that will create code duplication in flutter test binding and widgetflutterbinding. However, this approach might be a bigger breaking change for people who work directly with binding.

Related Issues

#31195

Tests

I added the following tests:

'WidgetBinding build rendering tree and warm up frame back to back'

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.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might as well create an api to just schedule attachRootWidget and flutter test can override this api. This might make it more clean, but I am not sure if it worth to expose an api for that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since it is no longer possible to dirty thing in the middle of warm up frame, I have to change the way to reproduce double builds. if we are ok to remove the null check in nestedscrollview, we can remove this test as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intend to keep this check as there might be other corner case that hit this, but i cannot think of any now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turn these into asserts then?

@dnfield dnfield added f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. labels Aug 22, 2019
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

testerbinding is no longer overriding scheduleWarmUpFrame, there is no point to test it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reminding myself, we can add this back since I decide to keep the override

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extraneous blank line

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this shouldn't be private, and it should be documented (and @Protected)

@Hixie
Copy link
Contributor

Hixie commented Aug 22, 2019

This will definitely have to go through the breaking change announcement process. Might be worth trying to run it through the internal Google test suite and see how many things we break there, too, to get an idea of how much breakage this will cause.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great debugging to figure this out!

Can you throw the "breaking change" label on here and sent out an announcement?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Turn these into asserts then?

@goderbauer
Copy link
Member

Looks like there are some tests on cirrus that were supposed to fail, but they are now passing.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, but we should announce it as a breaking change and as Hixie pointed out, it may be good to run this through Google's internal test suite to see what breaks there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... attaches the root widget...

@goderbauer
Copy link
Member

@kpsroka FYI

@chunhtai
Copy link
Contributor Author

internal test suite passed, breaking change email sent.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Probably good to wait until next week with submission to give people some time to respond to the breaking change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would probably remove the see also here since the sentence above just said the same thing.

@chunhtai chunhtai force-pushed the issues/31195-fix-warmup branch from 2f77a48 to 53a3a7f Compare August 30, 2019 20:21
@Piinks Piinks added the c: API break Backwards-incompatible API changes label Sep 3, 2019
@chunhtai chunhtai force-pushed the issues/31195-fix-warmup branch from 53a3a7f to a8aebfc Compare September 5, 2019 16:35
@chunhtai chunhtai merged commit 57d714e into flutter:master Sep 6, 2019
@tvolkert
Copy link
Contributor

tvolkert commented Dec 5, 2019

Was there a breaking change announcement for this change? If so, @chunhtai will you please link it here?

@chunhtai
Copy link
Contributor Author

chunhtai commented Dec 5, 2019

Was there a breaking change announcement for this change? If so, @chunhtai will you please link it here?

this is the one https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!searchin/flutter-announce/chun%7Csort:date/flutter-announce/m6ewfoO64mI/ziD4VmwUBQAJ

@tvolkert
Copy link
Contributor

tvolkert commented Dec 5, 2019

Thanks!

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

c: API break Backwards-incompatible API changes f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants