[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 beginFrame,
|
||||||
required ui.VoidCallback drawFrame,
|
required ui.VoidCallback drawFrame,
|
||||||
}) {
|
}) {
|
||||||
_isFrameScheduled = true;
|
|
||||||
|
|
||||||
// A note from dkwingsmt:
|
// A note from dkwingsmt:
|
||||||
//
|
//
|
||||||
// We use timers here to ensure that microtasks flush in between.
|
// 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
|
// https://github.com/flutter/engine/pull/50570#discussion_r1496671676
|
||||||
|
|
||||||
Timer.run(() {
|
Timer.run(() {
|
||||||
_isFrameScheduled = false;
|
|
||||||
_isRenderingFrame = true;
|
_isRenderingFrame = true;
|
||||||
_debugFrameNumber += 1;
|
_debugFrameNumber += 1;
|
||||||
// TODO(yjbanov): it's funky that if beginFrame crashes, the drawFrame
|
// 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
|
// "we did this before so let's continue doing it" excuse
|
||||||
// only works so far (referring to the discussion linked
|
// only works so far (referring to the discussion linked
|
||||||
// above).
|
// above).
|
||||||
beginFrame();
|
try {
|
||||||
|
beginFrame();
|
||||||
|
} finally {
|
||||||
|
_isRenderingFrame = false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Timer.run(() {
|
Timer.run(() {
|
||||||
|
_isRenderingFrame = true;
|
||||||
try {
|
try {
|
||||||
drawFrame();
|
drawFrame();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -136,8 +136,13 @@ void testMain() {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
// IMPORTANT: scheduled, but not yet rendering
|
// Even though the warm-up frame is scheduled the value of
|
||||||
expect(instance.isFrameScheduled, isTrue);
|
// 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);
|
expect(instance.isRenderingFrame, isFalse);
|
||||||
await frameCompleter.future;
|
await frameCompleter.future;
|
||||||
expect(instance.isFrameScheduled, isFalse);
|
expect(instance.isFrameScheduled, isFalse);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user