diff --git a/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm index 034ae62115a4b..efab8b6ea921e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterMetalLayerTest.mm @@ -283,8 +283,11 @@ - (void)testDealloc { [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);