mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 00:35:44 +00:00
Bug 1675887 - Respect the time value that's passed to Choreographer.FrameCallback.doFrame. r=kats
This makes the vsync times more consistent. On a Pixel 2 running Android 11, the callback was called between 1ms and 6ms after the vsync timestamp in my tests. Having the vsync timestamp slightly in the past is what the rest of our vsync infrastructure expects. Differential Revision: https://phabricator.services.mozilla.com/D96279
This commit is contained in:
parent
7ddc009e5e
commit
cb3b5afd46
@ -298,9 +298,18 @@ class AndroidVsyncSource final : public VsyncSource {
|
||||
using Base = java::VsyncSource::Natives<JavaVsyncSupport>;
|
||||
using Base::DisposeNative;
|
||||
|
||||
static void NotifyVsync() {
|
||||
static void NotifyVsync(int64_t aFrameTimeNanos) {
|
||||
// Convert aFrameTimeNanos to a TimeStamp. The value converts trivially to
|
||||
// the internal ticks representation of TimeStamp_posix; both use the
|
||||
// monotonic clock and are in nanoseconds.
|
||||
TimeStamp nativeTime = TimeStamp::FromSystemTime(aFrameTimeNanos);
|
||||
|
||||
// Use the timebase from the frame callback as the vsync time, unless it
|
||||
// is in the future.
|
||||
TimeStamp now = TimeStamp::Now();
|
||||
TimeStamp vsyncTime = nativeTime < now ? nativeTime : now;
|
||||
|
||||
Display& display = GetDisplayInstance();
|
||||
TimeStamp vsyncTime = TimeStamp::Now();
|
||||
TimeStamp outputTime = vsyncTime + display.GetVsyncRate();
|
||||
display.NotifyVsync(vsyncTime, outputTime);
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ import org.mozilla.gecko.GeckoAppShell;
|
||||
}
|
||||
|
||||
@WrapForJNI(stubName = "NotifyVsync")
|
||||
private static native void nativeNotifyVsync();
|
||||
private static native void nativeNotifyVsync(final long frameTimeNanos);
|
||||
|
||||
// Choreographer callback implementation.
|
||||
public void doFrame(final long frameTimeNanos) {
|
||||
if (mObservingVsync) {
|
||||
mChoreographer.postFrameCallback(this);
|
||||
nativeNotifyVsync();
|
||||
nativeNotifyVsync(frameTimeNanos);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user