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

Commit a7cc7a58 authored by Patrick Williams's avatar Patrick Williams Committed by Android (Google) Code Review
Browse files

Merge "BBQ: Update TransactionHangCallback to pass ANR reason"

parents 3c84af1b 3bb9f289
Loading
Loading
Loading
Loading
+12 −14
Original line number Diff line number Diff line
@@ -888,21 +888,19 @@ public final class ViewRootImpl implements ViewParent,
    static BLASTBufferQueue.TransactionHangCallback sTransactionHangCallback =
        new BLASTBufferQueue.TransactionHangCallback() {
            @Override
            public void onTransactionHang(boolean isGPUHang) {
                if (isGPUHang && !sAnrReported) {
            public void onTransactionHang(String reason) {
                if (sAnrReported) {
                    return;
                }

                sAnrReported = true;
                try {
                        ActivityManager.getService().appNotResponding(
                            "Buffer processing hung up due to stuck fence. Indicates GPU hang");
                    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.
                }
                } else {
                    // TODO: Do something with this later. For now we just ANR
                    // in dequeue buffer later like we always have.
                }
            }
        };

+9 −7
Original line number Diff line number Diff line
@@ -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());
        }
    }

@@ -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;
}
+1 −1
Original line number Diff line number Diff line
@@ -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. */