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

[cherrypick-stable]Skip unexpected events in MultiPlatformViewBackgroundForegroundScenar… #49247

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions testing/scenario_app/lib/src/platform_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,13 @@ class MultiPlatformViewBackgroundForegroundScenario extends Scenario
PlatformMessageResponseCallback? callback,
) {
final String message = utf8.decode(data!.buffer.asUint8List());

// The expected first event should be 'AppLifecycleState.resumed', but
// occasionally it will receive 'AppLifecycleState.inactive' first. Skip
// any messages until 'AppLifecycleState.resumed' is received.
if (_lastLifecycleState.isEmpty && message != 'AppLifecycleState.resumed') {
return;
}
if (_lastLifecycleState == 'AppLifecycleState.inactive' &&
message == 'AppLifecycleState.resumed') {
_nextFrame = _secondFrame;
Expand Down