BBQ: Update TransactionHangCallback to pass ANR reason
Bug: 244218818 Test: presubmits Change-Id: I00f961c743665b1a38fe3a9e66935b11570bc3e4
This commit is contained in:
@@ -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.
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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. */
|
||||
|
||||
Reference in New Issue
Block a user