Improve tracking on choreographer frame ends #68
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Behavior changes
Whenever possible (i.e. any API != 28), we'll now detect the end of a frame by spying on main thread messages and running code right when the main thread message is done running and before a new main thread message starts running, by leveraging
Looper.getMainLooper().setMessageLogging { }
. We're also detecting whether we're in a frame or not by looking at the name of the runnable, rather than by creating a stacktrace.Non backward compatible API changes
MainThreadMessageSpy.startTracing()
andMainThreadMessageSpy.stopTracing()
toMainThreadMessageSpy.addTracer()
andMainThreadMessageSpy.removeTracer()
.New APIs
MainThreadMessageSpy.startSpyingMainThreadDispatching()
andMainThreadMessageSpy.stopSpyingMainThreadDispatching()
,MainThreadMessageSpy.currentMessageAsString
,MainThreadMessageSpy.enabled
andMainThreadMessageSpy.onCurrentMessageFinished()
MainThreadMessageScopedLazy
(prop by mainThreadMessageScopedLazy {}
) property for main thread scoped lazy properties that get cleared at the end of each main thread message.Choreographers.postOnFrameRendered()
,Choreographers.postOnWindowFrameRendered()
andChoreographers.isInChoreographerFrame
InputEventTrigger.rendered
,InputEventTrigger.renderedUptime
andInputEventTrigger.onInputEventFrameRendered