Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Fix race condition in Unobstructed Platform View Scenario tests (#48096)
Browse files Browse the repository at this point in the history
Fixes race situation where `_onPlatformMessage` is triggered before the first frame, essentially skipping the first frame.

Fixes flutter/flutter#138193.

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
  • Loading branch information
vashworth authored Nov 16, 2023
1 parent f7e5ae4 commit 13cdf93
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion testing/scenario_app/lib/src/platform_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,6 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
required this.secondId,
}) {
_nextFrame = _firstFrame;
channelBuffers.setListener('flutter/lifecycle', _onPlatformMessage);
}

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

bool _firstFrameBegan = false;

void _firstFrame() {
if (!_firstFrameBegan) {
channelBuffers.setListener('flutter/lifecycle', _onPlatformMessage);
}
_firstFrameBegan = true;
final SceneBuilder builder = SceneBuilder();

builder.pushOffset(50, 600);
Expand Down

0 comments on commit 13cdf93

Please sign in to comment.