[web] warm-up frame does not block schedule frame (#162779)
Fix the issue with the first frame not rendering, introduced in https://github.com/flutter/flutter/pull/162554. Nobody filed an issue yet. I found it while testing something else.
This commit is contained in:
parent
1f5cb0d665
commit
d4772e591c
@ -120,8 +120,6 @@ class FrameService {
|
||||
required ui.VoidCallback beginFrame,
|
||||
required ui.VoidCallback drawFrame,
|
||||
}) {
|
||||
_isFrameScheduled = true;
|
||||
|
||||
// A note from dkwingsmt:
|
||||
//
|
||||
// We use timers here to ensure that microtasks flush in between.
|
||||
@ -133,7 +131,6 @@ class FrameService {
|
||||
// https://github.com/flutter/engine/pull/50570#discussion_r1496671676
|
||||
|
||||
Timer.run(() {
|
||||
_isFrameScheduled = false;
|
||||
_isRenderingFrame = true;
|
||||
_debugFrameNumber += 1;
|
||||
// TODO(yjbanov): it's funky that if beginFrame crashes, the drawFrame
|
||||
@ -142,10 +139,15 @@ class FrameService {
|
||||
// "we did this before so let's continue doing it" excuse
|
||||
// only works so far (referring to the discussion linked
|
||||
// above).
|
||||
beginFrame();
|
||||
try {
|
||||
beginFrame();
|
||||
} finally {
|
||||
_isRenderingFrame = false;
|
||||
}
|
||||
});
|
||||
|
||||
Timer.run(() {
|
||||
_isRenderingFrame = true;
|
||||
try {
|
||||
drawFrame();
|
||||
} finally {
|
||||
|
@ -136,8 +136,13 @@ void testMain() {
|
||||
},
|
||||
);
|
||||
|
||||
// IMPORTANT: scheduled, but not yet rendering
|
||||
expect(instance.isFrameScheduled, isTrue);
|
||||
// Even though the warm-up frame is scheduled the value of
|
||||
// isFrameScheduled remains false. This is because, for reasons to be yet
|
||||
// addressed, the warm-up frame can be (and indeed is) interleaved with
|
||||
// a normal scheduleFrame request. See the TODOs inside the
|
||||
// scheduleWarmUpFrame code, and this discussion in particular:
|
||||
// https://github.com/flutter/engine/pull/50570#discussion_r1496671676
|
||||
expect(instance.isFrameScheduled, isFalse);
|
||||
expect(instance.isRenderingFrame, isFalse);
|
||||
await frameCompleter.future;
|
||||
expect(instance.isFrameScheduled, isFalse);
|
||||
|
Loading…
x
Reference in New Issue
Block a user