Merge "Make sure the removeObservers be called correctly" into sc-dev am: 766eff7df1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15747424 Change-Id: Ia24326d6b43ca86e46511ebdaaee9718af701e98
This commit is contained in:
@@ -50,6 +50,7 @@ import com.android.internal.util.FrameworkStatsLog;
|
|||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that allows the app to get the frame metrics from HardwareRendererObserver.
|
* A class that allows the app to get the frame metrics from HardwareRendererObserver.
|
||||||
@@ -103,6 +104,7 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
|
|||||||
private boolean mCancelled = false;
|
private boolean mCancelled = false;
|
||||||
private FrameTrackerListener mListener;
|
private FrameTrackerListener mListener;
|
||||||
private boolean mTracingStarted = false;
|
private boolean mTracingStarted = false;
|
||||||
|
private Runnable mWaitForFinishTimedOut;
|
||||||
|
|
||||||
private static class JankInfo {
|
private static class JankInfo {
|
||||||
long frameVsyncId;
|
long frameVsyncId;
|
||||||
@@ -263,10 +265,16 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
|
|||||||
if (mListener != null) {
|
if (mListener != null) {
|
||||||
mListener.onCujEvents(mSession, ACTION_SESSION_END);
|
mListener.onCujEvents(mSession, ACTION_SESSION_END);
|
||||||
}
|
}
|
||||||
|
// We don't remove observer here,
|
||||||
|
// will remove it when all the frame metrics in this duration are called back.
|
||||||
|
// See onFrameMetricsAvailable for the logic of removing the observer.
|
||||||
|
// Waiting at most 10 seconds for all callbacks to finish.
|
||||||
|
mWaitForFinishTimedOut = () -> {
|
||||||
|
Log.e(TAG, "force finish cuj because of time out:" + mSession.getName());
|
||||||
|
finish(mJankInfos.size() - 1);
|
||||||
|
};
|
||||||
|
mHandler.postDelayed(mWaitForFinishTimedOut, TimeUnit.SECONDS.toMillis(10));
|
||||||
}
|
}
|
||||||
// We don't remove observer here,
|
|
||||||
// will remove it when all the frame metrics in this duration are called back.
|
|
||||||
// See onFrameMetricsAvailable for the logic of removing the observer.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -396,7 +404,8 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void finish(int indexOnOrAfterEnd) {
|
private void finish(int indexOnOrAfterEnd) {
|
||||||
|
mHandler.removeCallbacks(mWaitForFinishTimedOut);
|
||||||
|
mWaitForFinishTimedOut = null;
|
||||||
mMetricsFinalized = true;
|
mMetricsFinalized = true;
|
||||||
|
|
||||||
// The tracing has been ended, remove the observer, see if need to trigger perfetto.
|
// The tracing has been ended, remove the observer, see if need to trigger perfetto.
|
||||||
@@ -481,7 +490,7 @@ public class FrameTracker extends SurfaceControl.OnJankDataListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DEBUG) {
|
if (DEBUG) {
|
||||||
Log.i(TAG, "FrameTracker: CUJ=" + mSession.getName()
|
Log.i(TAG, "finish: CUJ=" + mSession.getName()
|
||||||
+ " (" + mBeginVsyncId + "," + mEndVsyncId + ")"
|
+ " (" + mBeginVsyncId + "," + mEndVsyncId + ")"
|
||||||
+ " totalFrames=" + totalFramesCount
|
+ " totalFrames=" + totalFramesCount
|
||||||
+ " missedAppFrames=" + missedAppFramesCount
|
+ " missedAppFrames=" + missedAppFramesCount
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class InteractionJankMonitor {
|
|||||||
private static final String ACTION_PREFIX = InteractionJankMonitor.class.getCanonicalName();
|
private static final String ACTION_PREFIX = InteractionJankMonitor.class.getCanonicalName();
|
||||||
|
|
||||||
private static final String DEFAULT_WORKER_NAME = TAG + "-Worker";
|
private static final String DEFAULT_WORKER_NAME = TAG + "-Worker";
|
||||||
private static final long DEFAULT_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(5L);
|
private static final long DEFAULT_TIMEOUT_MS = TimeUnit.SECONDS.toMillis(2L);
|
||||||
private static final String SETTINGS_ENABLED_KEY = "enabled";
|
private static final String SETTINGS_ENABLED_KEY = "enabled";
|
||||||
private static final String SETTINGS_SAMPLING_INTERVAL_KEY = "sampling_interval";
|
private static final String SETTINGS_SAMPLING_INTERVAL_KEY = "sampling_interval";
|
||||||
private static final String SETTINGS_THRESHOLD_MISSED_FRAMES_KEY =
|
private static final String SETTINGS_THRESHOLD_MISSED_FRAMES_KEY =
|
||||||
|
|||||||
Reference in New Issue
Block a user