diff options
| author | 2024-06-26 00:45:51 +0000 | |
|---|---|---|
| committer | 2024-06-26 00:45:51 +0000 | |
| commit | ccf93234af274fd8acb51a85aa25b186087826b1 (patch) | |
| tree | e19fa7d56c28010211edb956911efbb91f24f046 | |
| parent | 995f91ad36efa6b3ae1910d1505da5b40839981d (diff) | |
| parent | 771ec0b577b37bed5302cab1f185363635e60aba (diff) | |
Merge "Add SurfaceView callback event logs" into main
| -rw-r--r-- | core/java/android/view/EventLogTags.logtags | 3 | ||||
| -rw-r--r-- | core/java/android/view/SurfaceView.java | 44 | ||||
| -rw-r--r-- | core/java/com/android/internal/view/SurfaceCallbackHelper.java | 18 |
3 files changed, 59 insertions, 6 deletions
diff --git a/core/java/android/view/EventLogTags.logtags b/core/java/android/view/EventLogTags.logtags index f1cd671ef176..f3792930647a 100644 --- a/core/java/android/view/EventLogTags.logtags +++ b/core/java/android/view/EventLogTags.logtags @@ -62,6 +62,9 @@ option java_package android.view # following other view events defined in system/logging/logcat/event.logtags # ViewRoot Draw Events 60004 viewroot_draw_event (window|3),(event|3) +# SurfaceView Events +60005 surfaceview_layout (window|3),(format|1),(width|1),(height|1),(z|1),(sizeFrom|3),(attached|1),(lifecycleStrategy|1),(viewVisible|1) +60006 surfaceview_callback (window|3),(callback|3) # NOTE - the range 1000000-2000000 is reserved for partners and others who diff --git a/core/java/android/view/SurfaceView.java b/core/java/android/view/SurfaceView.java index 1d70d18ac4c8..fedbe4a65e07 100644 --- a/core/java/android/view/SurfaceView.java +++ b/core/java/android/view/SurfaceView.java @@ -49,6 +49,7 @@ import android.os.SystemClock; import android.text.TextUtils; import android.util.ArraySet; import android.util.AttributeSet; +import android.util.EventLog; import android.util.Log; import android.view.SurfaceControl.Transaction; import android.view.accessibility.AccessibilityNodeInfo; @@ -163,6 +164,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall private static final boolean DEBUG_POSITION = false; private static final long FORWARD_BACK_KEY_TOLERANCE_MS = 100; + private static final int LOGTAG_SURFACEVIEW_LAYOUT = 60005; + private static final int LOGTAG_SURFACEVIEW_CALLBACK = 60006; @UnsupportedAppUsage( maxTargetSdk = Build.VERSION_CODES.TIRAMISU, @@ -320,6 +323,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall private final ConcurrentLinkedQueue<WindowManager.LayoutParams> mEmbeddedWindowParams = new ConcurrentLinkedQueue<>(); + private String mTag = TAG; + private final ISurfaceControlViewHostParent mSurfaceControlViewHostParent = new ISurfaceControlViewHostParent.Stub() { @Override @@ -418,13 +423,26 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall updateSurface(); } + private void setTag() { + String windowName = ""; + ViewRootImpl viewRoot = getViewRootImpl(); + if (viewRoot != null) { + // strip package name + final String[] split = viewRoot.mWindowAttributes.getTitle().toString().split("\\."); + if (split.length > 0) { + windowName = " " + split[split.length - 1]; + } + } + + mTag = "SV[" + System.identityHashCode(this) + windowName + "]"; + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); - + setTag(); getViewRootImpl().addSurfaceChangedCallback(this); mWindowStopped = false; - mViewVisibility = getVisibility() == VISIBLE; updateRequestedVisibility(); @@ -1146,13 +1164,22 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall + " format=" + formatChanged + " size=" + sizeChanged + " visible=" + visibleChanged + " alpha=" + alphaChanged + " hint=" + hintChanged - + " visible=" + visibleChanged + " left=" + (mWindowSpaceLeft != mLocation[0]) + " top=" + (mWindowSpaceTop != mLocation[1]) + " z=" + relativeZChanged + " attached=" + mAttachedToWindow + " lifecycleStrategy=" + surfaceLifecycleStrategyChanged); + if (creating || formatChanged || sizeChanged || visibleChanged + || layoutSizeChanged || relativeZChanged || !mAttachedToWindow + || surfaceLifecycleStrategyChanged ) { + EventLog.writeEvent(LOGTAG_SURFACEVIEW_LAYOUT, + mTag, mRequestedFormat, myWidth, myHeight, mRequestedSubLayer, + (mRequestedWidth > 0 ? "setFixedSize" : "layout"), + (mAttachedToWindow ? 1 : 0), + mRequestedSurfaceLifecycleStrategy, (mRequestedVisible ? 1 : 0)); + } + try { mVisible = mRequestedVisible; mWindowSpaceLeft = mLocation[0]; @@ -1235,6 +1262,8 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall mIsCreating = true; if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " + "visibleChanged -- surfaceCreated"); + EventLog.writeEvent(LOGTAG_SURFACEVIEW_CALLBACK, mTag, + "surfaceCreated"); callbacks = getSurfaceCallbacks(); for (SurfaceHolder.Callback c : callbacks) { c.surfaceCreated(mSurfaceHolder); @@ -1245,6 +1274,9 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " + "surfaceChanged -- format=" + mFormat + " w=" + myWidth + " h=" + myHeight); + EventLog.writeEvent(LOGTAG_SURFACEVIEW_CALLBACK, mTag, + "surfaceChanged -- format=" + mFormat + + " w=" + myWidth + " h=" + myHeight); if (callbacks == null) { callbacks = getSurfaceCallbacks(); } @@ -1256,6 +1288,9 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall if (DEBUG) { Log.i(TAG, System.identityHashCode(this) + " surfaceRedrawNeeded"); } + EventLog.writeEvent(LOGTAG_SURFACEVIEW_CALLBACK, mTag, + "surfaceRedrawNeeded"); + if (callbacks == null) { callbacks = getSurfaceCallbacks(); } @@ -1337,7 +1372,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall private void redrawNeededAsync(SurfaceHolder.Callback[] callbacks, Runnable callbacksCollected) { - SurfaceCallbackHelper sch = new SurfaceCallbackHelper(callbacksCollected); + SurfaceCallbackHelper sch = new SurfaceCallbackHelper(callbacksCollected, mTag); sch.dispatchSurfaceRedrawNeededAsync(mSurfaceHolder, callbacks); } @@ -2100,6 +2135,7 @@ public class SurfaceView extends View implements ViewRootImpl.SurfaceChangedCall if (mSurface.isValid()) { if (DEBUG) Log.i(TAG, System.identityHashCode(this) + " " + "surfaceDestroyed"); + EventLog.writeEvent(LOGTAG_SURFACEVIEW_CALLBACK, mTag, "surfaceDestroyed"); SurfaceHolder.Callback[] callbacks = getSurfaceCallbacks(); for (SurfaceHolder.Callback c : callbacks) { c.surfaceDestroyed(mSurfaceHolder); diff --git a/core/java/com/android/internal/view/SurfaceCallbackHelper.java b/core/java/com/android/internal/view/SurfaceCallbackHelper.java index 507b673ec279..3fd51206e891 100644 --- a/core/java/com/android/internal/view/SurfaceCallbackHelper.java +++ b/core/java/com/android/internal/view/SurfaceCallbackHelper.java @@ -16,11 +16,13 @@ package com.android.internal.view; -import android.os.RemoteException; -import android.view.Surface; +import android.util.EventLog; import android.view.SurfaceHolder; public class SurfaceCallbackHelper { + private static final int LOGTAG_SURFACEVIEW_CALLBACK = 60006; + private final String mTag; + private boolean mSurfaceRedrawImplemented; Runnable mRunnable; int mFinishDrawingCollected = 0; @@ -35,12 +37,23 @@ public class SurfaceCallbackHelper { return; } mRunnable.run(); + if (mSurfaceRedrawImplemented && mTag != null) { + EventLog.writeEvent(LOGTAG_SURFACEVIEW_CALLBACK, mTag, + "surfaceRedrawNeeded implemented"); + } } } }; public SurfaceCallbackHelper(Runnable callbacksCollected) { + // skip logging surfaceRedrawNeeded calls + this(callbacksCollected, null); + } + + public SurfaceCallbackHelper(Runnable callbacksCollected, String tag) { mRunnable = callbacksCollected; + mTag = tag; + mSurfaceRedrawImplemented = false; } public void dispatchSurfaceRedrawNeededAsync(SurfaceHolder holder, SurfaceHolder.Callback callbacks[]) { @@ -58,6 +71,7 @@ public class SurfaceCallbackHelper { if (c instanceof SurfaceHolder.Callback2) { ((SurfaceHolder.Callback2) c).surfaceRedrawNeededAsync( holder, mFinishDrawingRunnable); + mSurfaceRedrawImplemented = true; } else { mFinishDrawingRunnable.run(); } |