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

Commit

Permalink
[cherrypick-stable]Skip unexpected events in MultiPlatformViewBackgro…
Browse files Browse the repository at this point in the history
…undForegroundScenar… (#49247)

�io (#48456)

Fixes flutter/flutter#138193.

Was first attempted to fix in #48096, but that was not reliable since it's all asynchronous. 

-------------------------------------------

cherry pick to fix mac unopt failures on stable branch: 
https://flutter-dashboard.appspot.com/#/build?repo=engine&branch=flutter-3.16-candidate.0
  • Loading branch information
XilaiZhang authored Dec 19, 2023
1 parent 61b3360 commit 3f3e560
Showing 1 changed file with 7 additions and 0 deletions.
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

0 comments on commit 3f3e560

Please sign in to comment.