commit | 3f3e560236539b7e2702f5ac790b2a4691b32d49 | [log] [tgz] |
---|---|---|
author | Xilai Zhang <xilaizhang@google.com> | Tue Dec 19 12:48:00 2023 -0800 |
committer | GitHub <noreply@github.com> | Tue Dec 19 20:48:00 2023 +0000 |
tree | 71d330c8177ee5d421ebee085707fec8f52abfcd | |
parent | 61b336001c273178633ba9c22f5dd6f90aeb1dba [diff] |
[cherrypick-stable]Skip unexpected events in MultiPlatformViewBackgroundForegroundScenar… (#49247) â¦io (#48456) Fixes https://github.com/flutter/flutter/issues/138193. Was first attempted to fix in https://github.com/flutter/engine/pull/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
diff --git a/testing/scenario_app/lib/src/platform_view.dart b/testing/scenario_app/lib/src/platform_view.dart index 7c15465..92679d2 100644 --- a/testing/scenario_app/lib/src/platform_view.dart +++ b/testing/scenario_app/lib/src/platform_view.dart
@@ -510,6 +510,13 @@ 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;