Merge "BBQ: Update TransactionHangCallback to pass ANR reason"

This commit is contained in:
Patrick Williams
2022-10-21 14:50:37 +00:00
committed by Android (Google) Code Review
3 changed files with 22 additions and 22 deletions

View File

@@ -888,20 +888,18 @@ public final class ViewRootImpl implements ViewParent,
static BLASTBufferQueue.TransactionHangCallback sTransactionHangCallback =
new BLASTBufferQueue.TransactionHangCallback() {
@Override
public void onTransactionHang(boolean isGPUHang) {
if (isGPUHang && !sAnrReported) {
sAnrReported = true;
try {
ActivityManager.getService().appNotResponding(
"Buffer processing hung up due to stuck fence. Indicates GPU hang");
} catch (RemoteException e) {
// We asked the system to crash us, but the system
// already crashed. Unfortunately things may be
// out of control.
}
} else {
// TODO: Do something with this later. For now we just ANR
// in dequeue buffer later like we always have.
public void onTransactionHang(String reason) {
if (sAnrReported) {
return;
}
sAnrReported = true;
try {
ActivityManager.getService().appNotResponding(reason);
} catch (RemoteException e) {
// We asked the system to crash us, but the system
// already crashed. Unfortunately things may be
// out of control.
}
}
};

View File

@@ -71,10 +71,12 @@ public:
}
}
void onTransactionHang(bool isGpuHang) {
void onTransactionHang(const std::string& reason) {
if (mTransactionHangObject) {
JNIEnv* env = getenv(mVm);
ScopedLocalRef<jstring> jReason(env, env->NewStringUTF(reason.c_str()));
getenv(mVm)->CallVoidMethod(mTransactionHangObject,
gTransactionHangCallback.onTransactionHang, isGpuHang);
gTransactionHangCallback.onTransactionHang, jReason.get());
}
}
@@ -177,7 +179,7 @@ static bool nativeIsSameSurfaceControl(JNIEnv* env, jclass clazz, jlong ptr, jlo
sp<BLASTBufferQueue> queue = reinterpret_cast<BLASTBufferQueue*>(ptr);
return queue->isSameSurfaceControl(reinterpret_cast<SurfaceControl*>(surfaceControl));
}
static void nativeSetTransactionHangCallback(JNIEnv* env, jclass clazz, jlong ptr,
jobject transactionHangCallback) {
sp<BLASTBufferQueue> queue = reinterpret_cast<BLASTBufferQueue*>(ptr);
@@ -186,9 +188,8 @@ static void nativeSetTransactionHangCallback(JNIEnv* env, jclass clazz, jlong pt
} else {
sp<TransactionHangCallbackWrapper> wrapper =
new TransactionHangCallbackWrapper{env, transactionHangCallback};
queue->setTransactionHangCallback([wrapper](bool isGpuHang) {
wrapper->onTransactionHang(isGpuHang);
});
queue->setTransactionHangCallback(
[wrapper](const std::string& reason) { wrapper->onTransactionHang(reason); });
}
}
@@ -236,7 +237,8 @@ int register_android_graphics_BLASTBufferQueue(JNIEnv* env) {
jclass transactionHangClass =
FindClassOrDie(env, "android/graphics/BLASTBufferQueue$TransactionHangCallback");
gTransactionHangCallback.onTransactionHang =
GetMethodIDOrDie(env, transactionHangClass, "onTransactionHang", "(Z)V");
GetMethodIDOrDie(env, transactionHangClass, "onTransactionHang",
"(Ljava/lang/String;)V");
return 0;
}

View File

@@ -47,7 +47,7 @@ public final class BLASTBufferQueue {
TransactionHangCallback callback);
public interface TransactionHangCallback {
void onTransactionHang(boolean isGpuHang);
void onTransactionHang(String reason);
}
/** Create a new connection with the surface flinger. */