[iOS] remove arbitrary framerate cap. (flutter/engine#51663)
This doesn't actually seem to be helping. For the most part, the frame time of the banners is steady with occassional spikes. Adding the framerate cap doesn't help the spikes, since those are in the 30+ ms frame time, and just results in everything else looking janky as well (especially if we dance around the cap, then we go 120 - 80) Since this is based on an arbitrary number, from an arbitrary app, on an arbitrary point in time we should remove it and instead try to fix the performance problems
This commit is contained in:
@@ -127,88 +127,4 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
|
||||
XCTAssertTrue(link.isPaused);
|
||||
}
|
||||
|
||||
- (void)testRefreshRateUpdatedTo80WhenThraedsMerge {
|
||||
auto platform_thread_task_runner = CreateNewThread("Platform");
|
||||
auto raster_thread_task_runner = CreateNewThread("Raster");
|
||||
auto ui_thread_task_runner = CreateNewThread("UI");
|
||||
auto io_thread_task_runner = CreateNewThread("IO");
|
||||
auto task_runners =
|
||||
flutter::TaskRunners("test", platform_thread_task_runner, raster_thread_task_runner,
|
||||
ui_thread_task_runner, io_thread_task_runner);
|
||||
|
||||
id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]];
|
||||
double maxFrameRate = 120;
|
||||
[[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate];
|
||||
[[[mockDisplayLinkManager stub] andReturnValue:@(YES)] maxRefreshRateEnabledOnIPhone];
|
||||
auto vsync_waiter = flutter::VsyncWaiterIOS(task_runners);
|
||||
|
||||
fml::scoped_nsobject<VSyncClient> vsyncClient = vsync_waiter.GetVsyncClient();
|
||||
CADisplayLink* link = [vsyncClient.get() getDisplayLink];
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
const auto merger = fml::RasterThreadMerger::CreateOrShareThreadMerger(
|
||||
nullptr, platform_thread_task_runner->GetTaskQueueId(),
|
||||
raster_thread_task_runner->GetTaskQueueId());
|
||||
|
||||
merger->MergeWithLease(5);
|
||||
vsync_waiter.AwaitVSync();
|
||||
|
||||
if (@available(iOS 15.0, *)) {
|
||||
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.maximum, 80, 0.1);
|
||||
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.preferred, 80, 0.1);
|
||||
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.minimum, 60, 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);
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
@@ -41,20 +41,6 @@ VsyncWaiterIOS::~VsyncWaiterIOS() {
|
||||
|
||||
void VsyncWaiterIOS::AwaitVSync() {
|
||||
double new_max_refresh_rate = [DisplayLinkManager displayRefreshRate];
|
||||
if (fml::TaskRunnerChecker::RunsOnTheSameThread(
|
||||
task_runners_.GetRasterTaskRunner()->GetTaskQueueId(),
|
||||
task_runners_.GetPlatformTaskRunner()->GetTaskQueueId())) {
|
||||
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;
|
||||
[client_.get() setMaxRefreshRate:max_refresh_rate_];
|
||||
|
||||
Reference in New Issue
Block a user