diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/VsyncWaiterIosTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/VsyncWaiterIosTest.mm index dda84f9ac1..eace658519 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/VsyncWaiterIosTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/VsyncWaiterIosTest.mm @@ -187,6 +187,37 @@ fml::RefPtr CreateNewThread(std::string name) { } else { XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, maxFrameRate, 0.1); } + + if (@available(iOS 14.0, *)) { + // Fake response that we are running on Mac. + id processInfo = [NSProcessInfo processInfo]; + id processInfoPartialMock = OCMPartialMock(processInfo); + bool iOSAppOnMac = true; + [OCMStub([processInfoPartialMock isiOSAppOnMac]) andReturnValue:OCMOCK_VALUE(iOSAppOnMac)]; + + merger->MergeWithLease(5); + vsync_waiter.AwaitVSync(); + + // On Mac, framerate should be uncapped. + if (@available(iOS 15.0, *)) { + XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.maximum, maxFrameRate, 0.1); + XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.preferred, maxFrameRate, 0.1); + XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.minimum, maxFrameRate / 2, 0.1); + } else { + XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, 80, 0.1); + } + + merger->UnMergeNowIfLastOne(); + vsync_waiter.AwaitVSync(); + + if (@available(iOS 15.0, *)) { + XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.maximum, maxFrameRate, 0.1); + XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.preferred, maxFrameRate, 0.1); + XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.minimum, maxFrameRate / 2, 0.1); + } else { + XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, maxFrameRate, 0.1); + } + } } @end diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm index 5ed238704c..3396d1fc70 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm @@ -44,10 +44,16 @@ void VsyncWaiterIOS::AwaitVSync() { if (fml::TaskRunnerChecker::RunsOnTheSameThread( task_runners_.GetRasterTaskRunner()->GetTaskQueueId(), task_runners_.GetPlatformTaskRunner()->GetTaskQueueId())) { - // Pressure tested on iPhone 13 pro, the oldest iPhone that supports refresh rate greater than - // 60fps. A flutter app can handle fast scrolling on 80 fps with 6 PlatformViews in the scene at - // the same time. - new_max_refresh_rate = 80; + BOOL isRunningOnMac = NO; + if (@available(iOS 14.0, *)) { + isRunningOnMac = [NSProcessInfo processInfo].iOSAppOnMac; + } + if (!isRunningOnMac) { + // Pressure tested on iPhone 13 pro, the oldest iPhone that supports refresh rate greater than + // 60fps. A flutter app can handle fast scrolling on 80 fps with 6 PlatformViews in the scene + // at the same time. + new_max_refresh_rate = 80; + } } if (fabs(new_max_refresh_rate - max_refresh_rate_) > kRefreshRateDiffToIgnore) { max_refresh_rate_ = new_max_refresh_rate;