Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 97c11a93 authored by Rachel Lee's avatar Rachel Lee Committed by Android (Google) Code Review
Browse files

Merge changes from topic "cherrypicker-L38900000962607726:N28500001397100516" into udc-qpr-dev

* changes:
  Choreographer: Log instead of crash on frame late
  Set default frameTimelinesLength to 1
  Throw exception when VsyncEventData null.
  Fix frame timelines length on USE_VSYNC = false
parents 57b114f8 863f60cd
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -1167,10 +1167,9 @@ public final class Choreographer {
         */
        FrameTimeline update(
                long frameTimeNanos, DisplayEventReceiver.VsyncEventData vsyncEventData) {
            if (vsyncEventData.frameTimelinesLength == 0) {
                throw new IllegalArgumentException(
                        "Vsync event timelines length must be greater than 0");
            }
            // Even if the frame timelines length is 0, continue with allocation for API
            // FrameData.getFrameTimelines consistency. The 0 length frame timelines code path
            // should only occur when USE_VSYNC property is false.
            if (mFrameTimelines.length != vsyncEventData.frameTimelinesLength) {
                allocateFrameTimelines(vsyncEventData.frameTimelinesLength);
            }
@@ -1207,7 +1206,11 @@ public final class Choreographer {
            if (newPreferredDeadline < minimumDeadline) {
                DisplayEventReceiver.VsyncEventData latestVsyncEventData =
                        displayEventReceiver.getLatestVsyncEventData();
                if (latestVsyncEventData == null) {
                    Log.w(TAG, "Could not get latest VsyncEventData. Did SurfaceFlinger crash?");
                } else {
                    update(frameTimeNanos, latestVsyncEventData);
                }
            } else {
                update(frameTimeNanos, newPreferredIndex);
            }
+10 −4
Original line number Diff line number Diff line
@@ -158,7 +158,11 @@ public abstract class DisplayEventReceiver {
        static final int FRAME_TIMELINES_CAPACITY = 7;

        public static class FrameTimeline {
            FrameTimeline() {}
            FrameTimeline() {
                // Some reasonable values (+10 ms) for default timestamps.
                deadline = System.nanoTime() + 10_000_000;
                expectedPresentationTime = deadline + 10_000_000;
            }

            // Called from native code.
            @SuppressWarnings("unused")
@@ -179,11 +183,11 @@ public abstract class DisplayEventReceiver {
            public long vsyncId = FrameInfo.INVALID_VSYNC_ID;

            // The frame timestamp for when the frame is expected to be presented.
            public long expectedPresentationTime = Long.MAX_VALUE;
            public long expectedPresentationTime;

            // The frame deadline timestamp in {@link System#nanoTime()} timebase that it is
            // allotted for the frame to be completed.
            public long deadline = Long.MAX_VALUE;
            public long deadline;
        }

        /**
@@ -197,7 +201,9 @@ public abstract class DisplayEventReceiver {

        public int preferredFrameTimelineIndex = 0;

        public int frameTimelinesLength = 0;
        // The default FrameTimeline is a placeholder populated with invalid vsync ID and some
        // reasonable timestamps.
        public int frameTimelinesLength = 1;

        VsyncEventData() {
            frameTimelines = new FrameTimeline[FRAME_TIMELINES_CAPACITY];