Basic watchdog that triggers thread dumps on puck jank #2558
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.
Summary of changes
An example on how to extend a custom location provider to track puck animations jank.
Every time the puck is animated it starts a watchdog that will create a thread dump if the animation has not run for some milliseconds.
Capturing multiple thread dumps allows to detect if the
main
thread is stuck.The gist of it is to add listeners to the animator and signal the watchdog (see
LocationComponentAnimationActivity.listeners
).If enough time elapses (
Watchdog.TIME_TO_FIRST_TRIGGER
) without the watchdog being rescheduled (Watchdog.reschedule
), then a thread dump will be written to disk (root
permission is most likely needed to extract them). It continues to do so every 100 milliseconds (maximum 5 times) ifreschedule
is not yet called.That way you could study the thread dumps and see what the
main
thread is doing.NOTE: this is a simple implementation please study the code and adapt it better to your needs.