Skip to content

Commit 30cce4d

Browse files
authored
Update fake_codec.dart to use Future.value instead of SynchronousFuture (flutter#152182)
Upcoming changes to DDC change the async semantics of code produced by the compiler. The changes will bring the semantics more in line with those of dart2js and fix several bugs in the old semantics. However in landing those changes I experienced a test failure in [obscured_animated_image_test](https://github.com/flutter/flutter/blob/master/packages/flutter/test/widgets/obscured_animated_image_test.dart). Some debugging uncovered that this is due to the use of `SynchronousFuture` in this `FakeCodec`. The old DDC async semantics forced an async gap when that future was [awaited](https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/painting/image_stream.dart#L1064). The new async semantics do not create an async gap here. This changes the render ordering of the widget tree created in the test leading to the test failure. `Future.value` should be a reasonable substitute here and should achieve what the test was trying to achieve while also preserving the correct render ordering given the new DDC semantics.
1 parent 2873053 commit 30cce4d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/flutter/test/painting/fake_codec.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ class FakeCodec implements ui.Codec {
4444
@override
4545
Future<ui.FrameInfo> getNextFrame() {
4646
_numFramesAsked += 1;
47-
final SynchronousFuture<ui.FrameInfo> result =
48-
SynchronousFuture<ui.FrameInfo>(_frameInfos[_nextFrame]);
47+
final Future<ui.FrameInfo> result =
48+
Future<ui.FrameInfo>.value(_frameInfos[_nextFrame]);
4949
_nextFrame = (_nextFrame + 1) % _frameCount;
5050
return result;
5151
}

0 commit comments

Comments
 (0)