From cb25cb029d94bce001075d58924e6a35bfa2fd09 Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Wed, 30 Oct 2024 15:15:18 -0700 Subject: [PATCH] iOS: Eliminate strong retain loop in Scenario tests `FlutterViewControllerTest testDrawLayer` created a callback which strongly referenced itself in its own body as part of an asynchronous recursive loop. The recursion was unnecessary and the test consistenly passes, even if run on repeat > 100 times without it. --- .../ScenariosTests/FlutterViewControllerTest.m | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/testing/scenario_app/ios/Scenarios/ScenariosTests/FlutterViewControllerTest.m b/testing/scenario_app/ios/Scenarios/ScenariosTests/FlutterViewControllerTest.m index 533b4153af061..339e0d7c002b8 100644 --- a/testing/scenario_app/ios/Scenarios/ScenariosTests/FlutterViewControllerTest.m +++ b/testing/scenario_app/ios/Scenarios/ScenariosTests/FlutterViewControllerTest.m @@ -91,9 +91,7 @@ - (void)testDrawLayer { [rootVC presentViewController:self.flutterViewController animated:NO completion:nil]; CGColorSpaceRef color_space = CGColorSpaceCreateDeviceRGB(); - - __block dispatch_block_t callback; - callback = ^{ + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC), dispatch_get_main_queue(), ^{ size_t width = 300u; CGContextRef context = CGBitmapContextCreate(nil, width, width, 8, 4 * width, color_space, @@ -104,14 +102,8 @@ - (void)testDrawLayer { [imageRendered fulfill]; return; } - CGContextRelease(context); - - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC), dispatch_get_main_queue(), - callback); - }; - dispatch_after(dispatch_time(DISPATCH_TIME_NOW, NSEC_PER_SEC), dispatch_get_main_queue(), - callback); + }); [self waitForExpectationsWithTimeout:30.0 handler:nil];