Uncap framerate for iOSAppOnMac (flutter/engine#43840)
Right now framerate when platform views are on screen is capped to 80 fps on iOS devices. I tried uncapping the framerate and ran the test app in https://github.com/flutter/flutter/issues/116640 on my M1 Max MBP and didn't notice any of the same slowdowns. `iOSAppOnMac` is only available on Apple Silicon Macs, so the performance baseline is really high. I think it's safe to remove the cap here. ### 120 Hz / ProMotion minimum specs | Category | Device | SoC | CPU | GPU | |--|--|--|--|--| iOS | iPhone 13 Pro | A15 | 2P+4e | 5 EU | Mac with built-in ProMotion | MacBook Pro 2021 | M1 Pro | 6P+2e | 14 EU | Mac with external 120Hz display | MacBook Air 2020 | M1 | 4P+4e | 7 EU | [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
@@ -187,6 +187,37 @@ fml::RefPtr<fml::TaskRunner> 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
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user