From 4d9360ac5bb5e0c31e50c136201d5e17b6e0b946 Mon Sep 17 00:00:00 2001 From: Matej Knopp Date: Thu, 8 Aug 2024 18:39:17 +0200 Subject: [PATCH] Fix FlutterMetalLayer testDealloc flakiness on iOS 18 (flutter/engine#54403) Fixes https://github.com/flutter/flutter/issues/152990 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style --- .../darwin/ios/framework/Source/FlutterMetalLayerTest.mm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm index 034ae62115..efab8b6ea9 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm @@ -283,8 +283,11 @@ [compositor commitTransaction]; [self removeMetalLayer:layer]; + } + CFTimeInterval start = CACurrentMediaTime(); + while (weakLayer != nil && CACurrentMediaTime() - start < 1) { // Deallocating the layer after removing is not synchronous. - CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1, YES); + CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.01, YES); } XCTAssertNil(weakLayer);