This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Use AChoreographer methods to get refresh rate updates when available #29765
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes flutter/flutter#93688
This makes sure the frame timings recorder and vsync waiter implementations get the correct refresh rate if or when it adjusts at runtime. This method should be reasonably fast based on the NDK impelemntation I am able to view, and it will not poll every frame (instead it will get notified whenever the refresh rate actually updates).
I don't know how to test this, I'll have to look at what API level our RoboElectric tests are running and if they can even validate this. I'm imagining some kind of test where we artificially set the refresh rate to something unrealistic and then verify that the C++ side gets it correct as observed in frame timings recorder, but I'm not quite sure that would even work on Roboelectric. Another option is to try to make the VSyncWaiterAndroid class more testable and write some regular C++ unit tests against that, but that won't exercise the dynamic NDK function lookup.
This does not fix some issues we have where the display refresh rate is set on shell creation and never updated, e.g. for
Shell::GetMainDisplayRefreshRate. That is tracked by flutter/flutter#93698/cc @blasten @jason-simmons @ds84182 @iskakaushik fyi