Skip to content

Commit 3f332b2

Browse files
author
Jonah Williams
authored
[iOS] remove arbitrary framerate cap. (flutter#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
1 parent 92ebd47 commit 3f332b2

2 files changed

Lines changed: 0 additions & 98 deletions

File tree

shell/platform/darwin/ios/framework/Source/VsyncWaiterIosTest.mm

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -127,88 +127,4 @@ - (void)testAwaitAndPauseWillWorkCorrectly {
127127
XCTAssertTrue(link.isPaused);
128128
}
129129

130-
- (void)testRefreshRateUpdatedTo80WhenThraedsMerge {
131-
auto platform_thread_task_runner = CreateNewThread("Platform");
132-
auto raster_thread_task_runner = CreateNewThread("Raster");
133-
auto ui_thread_task_runner = CreateNewThread("UI");
134-
auto io_thread_task_runner = CreateNewThread("IO");
135-
auto task_runners =
136-
flutter::TaskRunners("test", platform_thread_task_runner, raster_thread_task_runner,
137-
ui_thread_task_runner, io_thread_task_runner);
138-
139-
id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]];
140-
double maxFrameRate = 120;
141-
[[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate];
142-
[[[mockDisplayLinkManager stub] andReturnValue:@(YES)] maxRefreshRateEnabledOnIPhone];
143-
auto vsync_waiter = flutter::VsyncWaiterIOS(task_runners);
144-
145-
fml::scoped_nsobject<VSyncClient> vsyncClient = vsync_waiter.GetVsyncClient();
146-
CADisplayLink* link = [vsyncClient.get() getDisplayLink];
147-
148-
if (@available(iOS 15.0, *)) {
149-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.maximum, maxFrameRate, 0.1);
150-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.preferred, maxFrameRate, 0.1);
151-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.minimum, maxFrameRate / 2, 0.1);
152-
} else {
153-
XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, maxFrameRate, 0.1);
154-
}
155-
156-
const auto merger = fml::RasterThreadMerger::CreateOrShareThreadMerger(
157-
nullptr, platform_thread_task_runner->GetTaskQueueId(),
158-
raster_thread_task_runner->GetTaskQueueId());
159-
160-
merger->MergeWithLease(5);
161-
vsync_waiter.AwaitVSync();
162-
163-
if (@available(iOS 15.0, *)) {
164-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.maximum, 80, 0.1);
165-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.preferred, 80, 0.1);
166-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.minimum, 60, 0.1);
167-
} else {
168-
XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, 80, 0.1);
169-
}
170-
171-
merger->UnMergeNowIfLastOne();
172-
vsync_waiter.AwaitVSync();
173-
174-
if (@available(iOS 15.0, *)) {
175-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.maximum, maxFrameRate, 0.1);
176-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.preferred, maxFrameRate, 0.1);
177-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.minimum, maxFrameRate / 2, 0.1);
178-
} else {
179-
XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, maxFrameRate, 0.1);
180-
}
181-
182-
if (@available(iOS 14.0, *)) {
183-
// Fake response that we are running on Mac.
184-
id processInfo = [NSProcessInfo processInfo];
185-
id processInfoPartialMock = OCMPartialMock(processInfo);
186-
bool iOSAppOnMac = true;
187-
[OCMStub([processInfoPartialMock isiOSAppOnMac]) andReturnValue:OCMOCK_VALUE(iOSAppOnMac)];
188-
189-
merger->MergeWithLease(5);
190-
vsync_waiter.AwaitVSync();
191-
192-
// On Mac, framerate should be uncapped.
193-
if (@available(iOS 15.0, *)) {
194-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.maximum, maxFrameRate, 0.1);
195-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.preferred, maxFrameRate, 0.1);
196-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.minimum, maxFrameRate / 2, 0.1);
197-
} else {
198-
XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, 80, 0.1);
199-
}
200-
201-
merger->UnMergeNowIfLastOne();
202-
vsync_waiter.AwaitVSync();
203-
204-
if (@available(iOS 15.0, *)) {
205-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.maximum, maxFrameRate, 0.1);
206-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.preferred, maxFrameRate, 0.1);
207-
XCTAssertEqualWithAccuracy(link.preferredFrameRateRange.minimum, maxFrameRate / 2, 0.1);
208-
} else {
209-
XCTAssertEqualWithAccuracy(link.preferredFramesPerSecond, maxFrameRate, 0.1);
210-
}
211-
}
212-
}
213-
214130
@end

shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.mm

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,6 @@
4141

4242
void VsyncWaiterIOS::AwaitVSync() {
4343
double new_max_refresh_rate = [DisplayLinkManager displayRefreshRate];
44-
if (fml::TaskRunnerChecker::RunsOnTheSameThread(
45-
task_runners_.GetRasterTaskRunner()->GetTaskQueueId(),
46-
task_runners_.GetPlatformTaskRunner()->GetTaskQueueId())) {
47-
BOOL isRunningOnMac = NO;
48-
if (@available(iOS 14.0, *)) {
49-
isRunningOnMac = [NSProcessInfo processInfo].iOSAppOnMac;
50-
}
51-
if (!isRunningOnMac) {
52-
// Pressure tested on iPhone 13 pro, the oldest iPhone that supports refresh rate greater than
53-
// 60fps. A flutter app can handle fast scrolling on 80 fps with 6 PlatformViews in the scene
54-
// at the same time.
55-
new_max_refresh_rate = 80;
56-
}
57-
}
5844
if (fabs(new_max_refresh_rate - max_refresh_rate_) > kRefreshRateDiffToIgnore) {
5945
max_refresh_rate_ = new_max_refresh_rate;
6046
[client_.get() setMaxRefreshRate:max_refresh_rate_];

0 commit comments

Comments
 (0)