-
Notifications
You must be signed in to change notification settings - Fork 6k
Listen for display refresh changes and report them correctly #29800
Conversation
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.
LGTM
If I am understanding this correctly, this change makes it so Android’s Assuming that is correct, I think an alternative way of achieving the same thing would be to have the What do you think? |
We talked offline - the direction here is to have specific platform implemenations of It might be worth moving DisplayListener out of VsyncWaiter ont he java side at some point, but for now it's convenient to keep it there. |
/cc @cyanglaz FYI since I hear you might be looking at similar changes on iOS |
@dnfield Thanks, I was actually looking into this yesterday :) This is going to help a lot when I implement the iOS part. |
…date us right away
@jason-simmons was checking this on a different device and noticed the display manager doesn't call us back upon registration - I've updated this PR to make sure we set the refresh rate on initialization with a DisplayManager, so that we don't have to wait for it to update us. |
@VisibleForTesting | ||
public static void reset() { | ||
instance = null; | ||
listener = null; |
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.
Should refreshPeriodNanos
also be reset to -1 here?
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.
It's not static, so when the instance is re-created it'll be reset.
Per the sheriff, the CQ tag may not be doing the right thing. Landing this manually and pinging sheriff chat about it. |
See also #29765
Fixes flutter/flutter#93688
Fixes flutter/flutter#93698
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 becuase 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.