Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Nov 16, 2021

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

@dnfield
Copy link
Contributor Author

dnfield commented Nov 17, 2021

I looked at the AChoreographer implementation and it just calls Java based methods anyway. If I do this in Java, it will be a bit easier to test. I'm going to just do it in Java.

@dnfield dnfield closed this Nov 17, 2021
chinmaygarde pushed a commit that referenced this pull request Nov 18, 2021
This makes sure the frame timings recorder and vsync waiter implementations get
the correct refresh rate if or when it adjusts at runtime. This should be OK
because we'll only query the refresh rate when the display metrics actually
change, which is much less frequent than every frame. I experimented with an NDK
implementation in the previous patch, but that vastly restricts the API levels
we can support, and currently on API 30 and 31 it just calls Java methods
through JNI anyway.

I've refactored the way Display updates are reported so that AndroidDisplay can
just dynamically get the refresh rate correctly. These values are used by a
service protocol extension and by some Stopwatches on the CompositorContext.

See also #29765

Fixes flutter/flutter#93688
Fixes flutter/flutter#93698
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use AChoreographer_registerRefreshRateCallback to get actual refresh rate

1 participant