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

Commit d37e16f4 authored by Melody Hsu's avatar Melody Hsu Committed by Android (Google) Code Review
Browse files

Merge "Start buffer stuffing recovery based on time blocked in dequeueBuffer" into main

parents 1c0fdb07 19b23d6c
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -250,12 +250,15 @@ public final class Choreographer {

    /**
     * Set flag to indicate that client is blocked waiting for buffer release and
     * buffer stuffing recovery should soon begin.
     * buffer stuffing recovery should soon begin. This is provided with the
     * duration of time in nanoseconds that the client was blocked for.
     * @hide
     */
    public void onWaitForBufferRelease() {
    public void onWaitForBufferRelease(long durationNanos) {
        if (durationNanos > mLastFrameIntervalNanos / 2) {
            mBufferStuffingState.isStuffed.set(true);
        }
    }

    /**
     * Contains information about the current frame for jank-tracking,
+7 −4
Original line number Diff line number Diff line
@@ -107,10 +107,11 @@ public:
        }
    }

    void onWaitForBufferRelease() {
    void onWaitForBufferRelease(const nsecs_t durationNanos) {
        JNIEnv* env = getenv(mVm);
        getenv(mVm)->CallVoidMethod(mWaitForBufferReleaseObject,
                                    gWaitForBufferReleaseCallback.onWaitForBufferRelease);
                                    gWaitForBufferReleaseCallback.onWaitForBufferRelease,
                                    durationNanos);
        DieIfException(env, "Uncaught exception in WaitForBufferReleaseCallback.");
    }

@@ -255,7 +256,9 @@ static void nativeSetWaitForBufferReleaseCallback(JNIEnv* env, jclass clazz, jlo
    } else {
        sp<WaitForBufferReleaseCallbackWrapper> wrapper =
                new WaitForBufferReleaseCallbackWrapper{env, waitForBufferReleaseCallback};
        queue->setWaitForBufferReleaseCallback([wrapper]() { wrapper->onWaitForBufferRelease(); });
        queue->setWaitForBufferReleaseCallback([wrapper](const nsecs_t durationNanos) {
            wrapper->onWaitForBufferRelease(durationNanos);
        });
    }
}

@@ -305,7 +308,7 @@ int register_android_graphics_BLASTBufferQueue(JNIEnv* env) {
    jclass waitForBufferReleaseClass =
            FindClassOrDie(env, "android/graphics/BLASTBufferQueue$WaitForBufferReleaseCallback");
    gWaitForBufferReleaseCallback.onWaitForBufferRelease =
            GetMethodIDOrDie(env, waitForBufferReleaseClass, "onWaitForBufferRelease", "()V");
            GetMethodIDOrDie(env, waitForBufferReleaseClass, "onWaitForBufferRelease", "(J)V");

    return 0;
}
+3 −1
Original line number Diff line number Diff line
@@ -61,8 +61,10 @@ public final class BLASTBufferQueue {
        /**
         * Indicates that the client is waiting on buffer release
         * due to no free buffers being available to render into.
         * @param durationNanos The length of time in nanoseconds
         * that the client was blocked on buffer release.
         */
        void onWaitForBufferRelease();
        void onWaitForBufferRelease(long durationNanos);
    }

    /** Create a new connection with the surface flinger. */