-
Notifications
You must be signed in to change notification settings - Fork 6k
Report correct refresh rate if updated in a new frame #30054
Conversation
3bec621 to
22377e7
Compare
|
Please rebase this change to fix the windows UWP build |
| display_manager_->UpdateRefreshRateIfNecessary( | ||
| flutter::DisplayUpdateType::kUpdateRefreshRate, vsync_start_time, | ||
| frame_target_time); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the cost of this on iOS? We know for sure that on some Android platforms it's pretty expensive (e.g. 2-5ms) and this is during frameworkload.
Can we instead listen to refresh rate updates from the OS somehow?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate how this is expensive on Android. This method is essentially a no-op if framerate doesn't change. See: https://github.com/flutter/engine/pull/30054/files#diff-c9141b5122b7cb9dcc29a05b1660dbb92c1c6ea8e0df831c96b42708fa1e20b5R66
(I should probably need to update the code to return early so it is clearer)
shell/common/display_manager.cc
Outdated
|
|
||
| double new_frame_rate = | ||
| round((1 / (frame_target_time - vsync_start_time).ToSecondsF())); | ||
| if (!is_frame_rate_same(GetMainDisplayRefreshRate(), new_frame_rate)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On Android now this should always return false, but I'm curious if iOS can do something closer to what Android does and just supply a display object that always returns the right value for GetMainDisplayRefreshRate rather than polling/checking every frame.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On iOS, we can only get the frame time from target_time - start_time. We can have a platform(iOS) layer object to manage that calculation so it is abstracted from other platforms.
I think it is true for all the platforms that target_time - start_time represents the frame duration, and doing such calculation per frame is not expensive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you calculate the target_time on iOS?
On Android, it's calculated using the frame rate - requesting the frame rate every frame is expensive on Android in some vendor implementations though.
|
Close in favor of #30223 |
This PR makes the DisplayManager determines the frame rate at the beginning of each frame and update the reporting accordingly.
Fixes flutter/flutter#94507
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.