From 88bfe1a6da92018a8456da04b69dbf0c711334c3 Mon Sep 17 00:00:00 2001 From: Victoria Ashworth <15619084+vashworth@users.noreply.github.com> Date: Thu, 2 Nov 2023 10:16:46 -0500 Subject: [PATCH] Fix race condition in Platform View Scenario tests (flutter/engine#47575) Fixes race condition in Platform View Scenario tests, see https://github.com/flutter/flutter/issues/126627 for description of issue. Fixes https://github.com/flutter/flutter/issues/137547 and https://github.com/flutter/flutter/issues/126627. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../flutter/testing/scenario_app/lib/src/platform_view.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/engine/src/flutter/testing/scenario_app/lib/src/platform_view.dart b/engine/src/flutter/testing/scenario_app/lib/src/platform_view.dart index 7c15465dc9..39e6d42c16 100644 --- a/engine/src/flutter/testing/scenario_app/lib/src/platform_view.dart +++ b/engine/src/flutter/testing/scenario_app/lib/src/platform_view.dart @@ -1758,6 +1758,7 @@ class PlatformViewsWithClipsScrolling extends Scenario } final Map _createdPlatformViews = {}; +final Map _calledToBeCreatedPlatformViews = {}; /// Adds the platform view to the scene. /// @@ -1787,6 +1788,10 @@ void addPlatformView( ); return; } + if (_calledToBeCreatedPlatformViews.containsKey(platformViewKey)) { + return; + } + _calledToBeCreatedPlatformViews[platformViewKey] = true; final bool usesAndroidHybridComposition = scenarioParams['use_android_view'] as bool? ?? false; final bool expectAndroidHybridCompositionFallback =