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

Commit c40c077e authored by Wenhui Yang's avatar Wenhui Yang
Browse files

Capture transaction traces before system reboot

Bug: 299937754
Test: bugreport - data/misc/wmtrace/systemRestart_transactions.winscope
Test: go/winscope
Change-Id: I3dddb937005972f1a6878f72a7aedb8a9876eb3c
parent f1908787
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -302,6 +302,7 @@ public final class SurfaceControl implements Parcelable {
                                                                long desiredPresentTimeNanos);
    private static native void nativeSetFrameTimeline(long transactionObj,
                                                           long vsyncId);
    private static native void nativeNotifyShutdown();

    /**
     * Transforms that can be applied to buffers as they are displayed to a window.
@@ -4765,4 +4766,11 @@ public final class SurfaceControl implements Parcelable {
        return nativeGetStalledTransactionInfo(pid);
    }

    /**
     * Notify the SurfaceFlinger to capture transaction traces when shutdown.
     * @hide
     */
    public static void notifyShutdown() {
        nativeNotifyShutdown();
    }
}
+6 −0
Original line number Diff line number Diff line
@@ -2201,6 +2201,10 @@ static jobject nativeGetStalledTransactionInfo(JNIEnv* env, jclass clazz, jint p
    return jStalledTransactionInfo;
}

static void nativeNotifyShutdown() {
    SurfaceComposerClient::notifyShutdown();
}

// ----------------------------------------------------------------------------

SurfaceControl* android_view_SurfaceControl_getNativeSurfaceControl(JNIEnv* env,
@@ -2476,6 +2480,8 @@ static const JNINativeMethod sSurfaceControlMethods[] = {
            (void*) nativeGetStalledTransactionInfo },
    {"nativeSetDesiredPresentTimeNanos", "(JJ)V",
            (void*) nativeSetDesiredPresentTimeNanos },
    {"nativeNotifyShutdown", "()V",
            (void*)nativeNotifyShutdown },
        // clang-format on
};

+5 −0
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@ import android.util.ArrayMap;
import android.util.Log;
import android.util.Slog;
import android.util.TimingsTraceLog;
import android.view.SurfaceControl;
import android.view.WindowManager;

import com.android.internal.annotations.VisibleForTesting;
@@ -459,6 +460,10 @@ public final class ShutdownThread extends Thread {
        metricShutdownStart();
        metricStarted(METRIC_SYSTEM_SERVER);

        // Notify SurfaceFlinger that the device is shutting down.
        // Transaction traces should be captured at this stage.
        SurfaceControl.notifyShutdown();

        // Start dumping check points for this shutdown in a separate thread.
        Thread dumpCheckPointsThread = ShutdownCheckPoints.newDumpThread(
                new File(CHECK_POINTS_FILE_BASENAME));