summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Melody Hsu <melodymhsu@google.com> 2025-01-17 11:04:12 -0800
committer Android (Google) Code Review <android-gerrit@google.com> 2025-01-17 11:04:12 -0800
commitd37e16f4df7e7500766a77edbf6c57d1e6df32bb (patch)
treeea074dd53e23b9b24e61b0d1f014cbc45c17955e
parent1c0fdb076b1e24d3c014361538228c4e83b875b3 (diff)
parent19b23d6ccee409d0eacb7a52be7c59e6409747a0 (diff)
Merge "Start buffer stuffing recovery based on time blocked in dequeueBuffer" into main
-rw-r--r--core/java/android/view/Choreographer.java9
-rw-r--r--core/jni/android_graphics_BLASTBufferQueue.cpp11
-rw-r--r--graphics/java/android/graphics/BLASTBufferQueue.java4
3 files changed, 16 insertions, 8 deletions
diff --git a/core/java/android/view/Choreographer.java b/core/java/android/view/Choreographer.java
index 992790e092d1..053ccdd73c8c 100644
--- a/core/java/android/view/Choreographer.java
+++ b/core/java/android/view/Choreographer.java
@@ -250,11 +250,14 @@ 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() {
- mBufferStuffingState.isStuffed.set(true);
+ public void onWaitForBufferRelease(long durationNanos) {
+ if (durationNanos > mLastFrameIntervalNanos / 2) {
+ mBufferStuffingState.isStuffed.set(true);
+ }
}
/**
diff --git a/core/jni/android_graphics_BLASTBufferQueue.cpp b/core/jni/android_graphics_BLASTBufferQueue.cpp
index 7b61a5db0b41..10d6d33c5a76 100644
--- a/core/jni/android_graphics_BLASTBufferQueue.cpp
+++ b/core/jni/android_graphics_BLASTBufferQueue.cpp
@@ -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;
}
diff --git a/graphics/java/android/graphics/BLASTBufferQueue.java b/graphics/java/android/graphics/BLASTBufferQueue.java
index 1c34e0d54908..9b9be244cf90 100644
--- a/graphics/java/android/graphics/BLASTBufferQueue.java
+++ b/graphics/java/android/graphics/BLASTBufferQueue.java
@@ -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. */