Skip to content

Commit 13cdf93

Browse files
authored
Fix race condition in Unobstructed Platform View Scenario tests (flutter#48096)
Fixes race situation where `_onPlatformMessage` is triggered before the first frame, essentially skipping the first frame. Fixes flutter#138193. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent f7e5ae4 commit 13cdf93

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

testing/scenario_app/lib/src/platform_view.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
422422
required this.secondId,
423423
}) {
424424
_nextFrame = _firstFrame;
425-
channelBuffers.setListener('flutter/lifecycle', _onPlatformMessage);
426425
}
427426

428427
/// The platform view identifier to use for the first platform view.
@@ -438,7 +437,13 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
438437
_nextFrame();
439438
}
440439

440+
bool _firstFrameBegan = false;
441+
441442
void _firstFrame() {
443+
if (!_firstFrameBegan) {
444+
channelBuffers.setListener('flutter/lifecycle', _onPlatformMessage);
445+
}
446+
_firstFrameBegan = true;
442447
final SceneBuilder builder = SceneBuilder();
443448

444449
builder.pushOffset(50, 600);

0 commit comments

Comments
 (0)