Skip to content

Conversation

@yjbanov
Copy link
Contributor

@yjbanov yjbanov commented Dec 11, 2020

Description

Reschedule engine frame if it arrives in the middle of warm-up.

Related Issues

#69313

Tests

I added the following tests: added a new test in scheduler_test.dart.

@flutter-dashboard flutter-dashboard bot added the framework flutter/packages/flutter repository. See also f: labels. label Dec 11, 2020
@google-cla google-cla bot added the cla: yes label Dec 11, 2020
@Hixie
Copy link
Contributor

Hixie commented Dec 11, 2020

Isn't that what _ignoreNextEngineDrawFrame is trying to do?

cc @goderbauer

@yjbanov
Copy link
Contributor Author

yjbanov commented Dec 11, 2020

@Hixie

Isn't that what _ignoreNextEngineDrawFrame is trying to do?

_ignoreNextEngineDrawFrame is still there, I just renamed it to _rescheduleAfterWarmUpFrame and added some docs. The effective part of the PR is the call to scheduleFrame() in a timer inside the _handleDrawFrame (iow "reschedule" the frame, as opposed to just drop it).

@Hixie
Copy link
Contributor

Hixie commented Dec 12, 2020

cc @goderbauer

Copy link
Member

Choose a reason for hiding this comment

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

Why do we need to schedule another frame if one is already scheduled?

Copy link
Member

Choose a reason for hiding this comment

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

(In other words, why do we ignore _hasScheduledFrame here?)

Copy link
Member

Choose a reason for hiding this comment

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

From GVC: We should say that we need to reset it here because it was never reseted in _handleBeginFrame when we dropped the frame.

Copy link
Member

Choose a reason for hiding this comment

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

Actually, after discussing this a little more, this is fine. We have no idea what state _hasScheduledFrame is in, and we need it to be false so that scheduleFrame actually does something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added more explanation.

@yjbanov yjbanov force-pushed the app-load-bug-no-zones branch from 5684241 to 9e89622 Compare December 15, 2020 19:58
_rescheduleAfterWarmUpFrame = false;
// Reschedule in a timer to allow the draw-frame phase of the warm-up
// frame to finish.
Timer.run(() {
Copy link
Contributor

Choose a reason for hiding this comment

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

should this be a post-frame callback rather than a timer?

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 was wary of using any method that relies on the frame lifecycle, given that the issue we're dealing here is precisely a violation of said lifecycle 😃 Having said that, I just tried, and a post-frame callback seems to work fine. LMK what your preference is, and whether it has some advantages that I could capture in a test.

Copy link
Member

Choose a reason for hiding this comment

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

A post-frame callback would make the semantics a little clearer since we want to run this at the end of the currently executing frame (which is the warm-up frame).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@yjbanov yjbanov requested review from Hixie and goderbauer December 15, 2020 22:39
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

_rescheduleAfterWarmUpFrame = false;
// Reschedule in a timer to allow the draw-frame phase of the warm-up
// frame to finish.
Timer.run(() {
Copy link
Member

Choose a reason for hiding this comment

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

A post-frame callback would make the semantics a little clearer since we want to run this at the end of the currently executing frame (which is the warm-up frame).

@yjbanov yjbanov requested a review from goderbauer December 15, 2020 23:59
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

@Hixie
Copy link
Contributor

Hixie commented Dec 16, 2020

LGTM too. Please keep an eye out for regressions in the days after landing this (e.g. trawl through the recently-filed issues for unexplained weirdness, look out for failures in google's tests), even more so than usual, because this is a subtle and core part of the system.

@Hixie
Copy link
Contributor

Hixie commented Dec 16, 2020

(e.g. look for regressions around when the splash screen comes down on android apps)

@yjbanov
Copy link
Contributor Author

yjbanov commented Dec 16, 2020

(e.g. look for regressions around when the splash screen comes down on android apps)

Rgr. Hopefully this is a no-op on mobile, since on the VM we never get a frame in the middle of a warm-up frame and therefore the new codepath never executes.

@yjbanov
Copy link
Contributor Author

yjbanov commented Dec 16, 2020

(e.g. look for regressions around when the splash screen comes down on android apps)

Rgr. Hopefully this is a no-op on mobile, since on the VM we never get a frame in the middle of a warm-up frame and therefore the new codepath never executes.

"Hopefully", as in "I'm counting on it". If it's otherwise, I'll revert immediately as it would mean I probably messed it up big time.

@yjbanov
Copy link
Contributor Author

yjbanov commented Dec 16, 2020

Actually, now that I think about it, if in a rare occasion the mobile does get a frame in the middle of the warm-up frame it may be a source of flakiness in apps/tests. So this, theoretically, could fix the flakiness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants