Perfetto triage

trace com.example.app-startup-sample.pftrace · package com.example.app · capture mode startup

1Can this trace be trusted?

Dropped data, a debuggable build or a missing data source makes every number below it meaningless, so this comes first.

Directional only

The findings point at real code paths, but do not quote the numbers.

Trace healthPasspassno errors and no dropped data
Recorded: slicesPassokthis data source is in the trace
Recorded: schedPassokthis data source is in the trace
Recorded: frametimelinePassokthis data source is in the trace
Recorded: blocked reasonsPassokthis data source is in the trace
Recorded: binderPassokthis data source is in the trace
Build typeUnknownunknown03_build_type did not run on this trace
Startup capturePassokcapture mode: startup
Info

Build type not verified

03_build_type did not run on this trace. This report cannot tell whether the app was a release build.

What to do. Run `adb shell dumpsys package <pkg> | grep -i debuggable` (any output means debuggable), or recapture with scripts/capture.sh, which refuses debuggable builds unless told otherwise.

Measured in 03_build_type

Findings, worst first

  1. Highcom.example.app: 31/32 frames janky (96.9%)
  2. Mediumcom.example.app: cost is on the UI thread
  3. MediumMeasure/layout/traversal cost during janky frames (1316 ms)
  4. MediumMain-thread binder: AIDL::cpp::android.gui.SensorEventConnection::#2::server costs 53 ms
  5. InfoBuild type not verified
  6. InfoApp never calls reportFullyDrawn()
  7. InfoStartup time is dominated by 'choreographer_do_frame'
  8. InfoStartup is compute-bound: main thread runs 66% of the time
  9. Info2991 classes loaded during startup, 31 ms on the critical path
  10. InfoSlow binder calls are queueing, not computing
  11. InfoCompose runtime work ranks in this trace: the fix belongs to compose-expert

2Was the main thread running or waiting?

Running means the app's code is slow. Waiting means it was blocked, and profiling the app's own code will find nothing.

Main thread during startup

Each colour is one thread state, sized by its share of the time. It is a total, not a timeline: the order is not the order things happened.

  • Running172 ms66%
  • Runnable6.4 ms2%
  • Uninterruptible sleep (IO)9.1 ms3%
  • Uninterruptible sleep (non-IO)0.1 ms<1%
  • Sleeping75 ms28%

inferenceWhat it means. The main thread was executing code for 66% of startup. The cost is work the app is doing, so the slices it was running are the place to look.

See it in Perfetto. Expand the app's process. The first thread is the main thread, and the thin coloured strip above its slices uses these same colours.

Main thread over the whole trace (com.example.app)

Each colour is one thread state, sized by its share of the time. It is a total, not a timeline: the order is not the order things happened.

  • Running389 ms7%
  • Runnable10 ms<1%
  • Uninterruptible sleep (IO)9.1 ms<1%
  • Uninterruptible sleep (non-IO)0.1 ms<1%
  • Sleeping4,889 ms92%

inferenceWhat it means. Over a whole capture the main thread is expected to sleep between frames and while it waits for input, so the sleeping share here is not a problem by itself. What to read is how much it ran (389 ms, 7%), how long it was ready with no CPU free (10 ms), and how long it was blocked in the kernel (9.2 ms).

See it in Perfetto. Expand the app's process. The first thread is the main thread, and the thin coloured strip above its slices uses these same colours.

What the states mean
  • Running: on a CPU, executing code
  • Runnable: ready to run, waiting for a CPU
  • Uninterruptible sleep (IO): blocked in the kernel on disk IO
  • Uninterruptible sleep (non-IO): blocked in the kernel, not on IO
  • Sleeping: waiting for something: a lock, a binder reply, a message, a timer
Infodirectional only

Startup is compute-bound: main thread runs 66% of the time

Running 172 ms vs waiting 90 ms (Running 172 ms, Sleeping 75 ms, Uninterruptible Sleep (IO) 9 ms, Runnable (Preempted) 3 ms, Runnable 3 ms, Uninterruptible Sleep (non-IO) 0 ms, Uninterruptible Sleep 0 ms). Startup is 288 ms to first frame, under the 500 ms this report flags, so this is information, not a problem.

What to do. Your code, class loading, or JIT is the cost. Baseline Profiles and deferring init work off the critical path are the levers.

Measured in 12_startup_main_thread_state

3Which frames were late, and who is to blame?

Every frame has a deadline. The frame timeline says whether the app or the system compositor missed it.

32frames recordedcom.example.app
31missed their deadline97% of frames
+156 msworst framepast its deadline

Frames by outcome

Every frame in the capture, grouped by whether it met its deadline and, if not, who the frame timeline blames. Sizes are frame counts.

  • On time1 frame3%
  • Late, app at fault12 frames38%
  • Late, system at fault5 frames16%
  • Late, other cause14 frames44%

inferenceWhat it means. 31 of 32 frames were late. The frame timeline blames the app for 12 of them and the system compositor for 5, so the app's own frame work is the first place to look.

See it in Perfetto. Under the app's process, expand Expected Timeline and Actual Timeline. The Actual Timeline slices use these colours.

The worst frames

One bar per frame, starting at the frame's deadline. Longer means later.

deadline156 ms lateframe 26045026App Deadline Missed, App Resynced Jitter+156 ms · UI thread 139 msframe 26045279App Deadline Missed, App Resynced Jitter+114 ms · UI thread 81 msframe 26045316App Deadline Missed, App Resynced Jitter+110 ms · UI thread 9.7 msframe 26045703App Deadline Missed+54 ms · UI thread 16 msframe 26045900Buffer Stuffing+52 ms · UI thread 17 msframe 26045878App Deadline Missed+49 ms · UI thread 19 msframe 26045812App Deadline Missed+48 ms · UI thread 7.5 msframe 26045674App Deadline Missed+47 ms · UI thread 7.4 msframe 26045937SurfaceFlinger Scheduling+47 ms · UI thread 11 msframe 26045856App Deadline Missed+45 ms · UI thread 8.8 ms
  • Late, app at fault
  • Buffer stuffing
  • Late, system at fault

See it in Perfetto. Press / in the Perfetto UI and search for a frame number, for example 26045026. It appears in the Choreographer#doFrame slice name.

Who paid for the late frames

Time spent inside late frames, summed per stage.

inferenceWhat it means. The UI thread costs more than RenderThread in the late frames. Look at measure, layout, recomposition and work posted to the main thread before looking at the GPU.

Highdirectional only

com.example.app: 31/32 frames janky (96.9%)

Worst frame ran 156 ms over its deadline. App-attributed jank: 12, SurfaceFlinger-attributed: 5.

What to do. Blame lands on the app. Look at the UI-thread vs RenderThread split and the hot slices during janky frames.

Measured in 20_jank_summary

Mediumdirectional only

com.example.app: cost is on the UI thread

doFrame 547 ms vs DrawFrame 404 ms (vsync delay 308 ms). Jank rate: 31 of 32 frames (96.9%).

What to do. Look for measure/layout passes, recomposition, main-thread IO or deserialisation, and work posted onto the main Handler.

Measured in 22_jank_cpu_split

Mediumdirectional only

Measure/layout/traversal cost during janky frames (1316 ms)

Slices matched: traversal. Jank rate: 31 of 32 frames (96.9%).

What to do. Flatten the hierarchy, avoid nested weights / double measure, and hoist state so recomposition scopes stay small.

Measured in 23_jank_hot_slices

4Where did the time go?

Only now is it worth ranking slices.

Startup

288 mstime to first frame (TTID)cold start
not reportedtime to full content (TTFD)the app never calls reportFullyDrawn()
2,991classes loaded31 ms on the critical path

What startup was spent on

Perfetto's own breakdown of the launch, largest first. Categories overlap, so they do not add up to the total.

See it in Perfetto. Find the Android App Startups track near the top of the trace. Selecting the startup slice highlights this window.

Longest slices on the main thread during startup

Ranked by total time. A parent slice includes everything nested under it, so read this for where to look, not for blame.

Hot slices

Where the time was spent, by self time

Self time is the time inside a slice itself, with the slices nested under it taken out. It is the fairest ranking of what cost the most.

inferenceWhat it means. A name here that does not appear anywhere in the app's source is a framework or system slice. The app caused it but did not write it. Run triage with --app-repo to have each name checked.

See it in Perfetto. Press / and search for a slice name to jump to it.

Binder calls on the main thread

Synchronous calls to other processes

Each bar is one binder interface the main thread called and waited on. This trace does not name the interfaces, so those calls are grouped by the process that was called.

What the caller was doing while it waited

The calling thread's state during slow binder calls.

  • Running1.7 ms2%
  • Runnable3.4 ms5%
  • Sleeping68 ms93%

inferenceWhat it means. Most of the wait is the calling thread asleep until the reply arrives. The call is queueing, not computing, so fewer calls helps more than a faster server.

Mediumdirectional only

Main-thread binder: AIDL::cpp::android.gui.SensorEventConnection::#2::server costs 53 ms

2 synchronous calls from com.example.app to system_server, worst single call 42.5 ms.

What to do. Synchronous binder on the main thread is a frozen UI. Cache the result, batch the calls, or move them to a background dispatcher. System APIs that look local (PackageManager, ConnectivityManager, DisplayManager, SharedPreferences-backed system settings) are binder calls underneath.

Measured in 30_binder_main_thread

Infodirectional only

App never calls reportFullyDrawn()

com.example.app has no time-to-full-display. TTID only measures the first frame, which is often a skeleton or spinner.

What to do. Call Activity.reportFullyDrawn() (or ReportDrawn* in Compose) once real content is on screen, so TTFD becomes measurable and Play Console reports it.

Measured in 10_startup_summary

Infodirectional only

Startup time is dominated by 'choreographer_do_frame'

choreographer_do_frame 93 ms, binder 61 ms, Running 33 ms. Startup is 288 ms to first frame, under the 500 ms this report flags, so this is information, not a problem.

What to do. First-frame rendering is expensive. Usually composition/measure/layout cost or shader compilation.

Measured in 11_startup_breakdown

Infodirectional only

2991 classes loaded during startup, 31 ms on the critical path

startup_id=1 (com.example.app). Note this counts explicit class-load slices only; JIT and verification cost sits in the running time above. Startup is 288 ms to first frame, under the 500 ms this report flags, so this is information, not a problem.

What to do. This is the clearest Baseline Profile signal there is. Generate one with BaselineProfileRule, then prove the win by benchmarking CompilationMode.None() against CompilationMode.Partial(BaselineProfileMode.Require).

Measured in 14_startup_class_loading

Infodirectional only

Slow binder calls are queueing, not computing

Dominant client-side reason is 'S' (68 ms).

What to do. The server side is not the bottleneck; the client is descheduled or waiting for a free binder thread. Reducing call *count* helps more than making the server faster.

Measured in 31_binder_why_slow

Info

Compose runtime work ranks in this trace: the fix belongs to compose-expert

Slices: Recomposer:animation (162 ms), Recomposer:recompose (82 ms), Compose:recompose (57 ms), Compose:onRemembered (47 ms), Compose:applyChanges (17 ms). About 364 ms across them. The trace shows how much this work costs, not which composable causes it.

What to do. Use the compose-expert skill (aldefy/compose-skill) for the fix. It covers recomposition, state, lazy lists, animation and Compose performance. If it is not installed, on Claude Code: /plugin marketplace add aldefy/compose-skill, then /plugin install compose-expert. Ask before installing anything.

Measured in 23_jank_hot_slices, 40_slice_hotspots, 13_startup_top_slices

5What to fix, in order

Suggestions drawn from this one trace, for a person or an agent to review. They are not instructions.

Settle the capture question first (1 item). The other 5 suggestions point at real code paths, but their numbers cannot be quoted until then.

Before acting on any of these
  1. Read the code each suggestion points at. Drop any that do not apply, and say which and why. A candidate from the code audit is a pattern match: confirm the line runs on this path, and on which thread, before calling it the cause.
  2. Take the first one left. One fix per change, so the result can be attributed.
  3. Build before and after from the same build type. Trace sections go in both.
  4. Capture 10 or more runs per side and compare them: remeasure.py --before runs/before-* --after runs/after-*
  5. Raise the fix only if the number under "check" comes back clear or likely, and put that table in the pull request. If it comes back noise, say so and do not ship it as a win.

Do first: the capture

1

Confirm the build type before quoting any number

Because: Build type not verified

  • Run: adb shell dumpsys package <pkg> | grep -i debuggable. Any output means debuggable
  • Or capture again with capture.sh, whose config records the package list

Where. the capture, not the code

Check. build type is release

Review next

2

Report when the first screen is really drawn

Because: App never calls reportFullyDrawn()

  • Call Activity.reportFullyDrawn() once real content is on screen
  • In Compose use ReportDrawn or ReportDrawnWhen { contentIsReady }

Where. the Activity or root composable of the first screen

Check. TTFD (ms)

3

Take the binder call off the main thread

Because: Main-thread binder: AIDL::cpp::android.gui.SensorEventConnection::#2::server costs 53 ms

  • The finding names the interface. Find the framework API that wraps it
  • Call it from a background dispatcher, cache the result, or batch repeated calls

Where. AIDL::cpp::android.gui.SensorEventConnection::#2::server

Check. main-thread binder (ms)

Can wait

4

Defer or shrink the work done before the first frame

Because: Startup is compute-bound: main thread runs 66% of the time

Its finding is information in this trace. Nothing here says users see a problem from it yet.

  • Take the largest slice in 13_startup_top_slices that is the app's own
  • Defer anything the first screen does not need: lazy init, App Startup, a background dispatcher

Where. not known from the trace. Map the slices to code first.

Check. cold start TTID (ms)

5

Ship or refresh the Baseline Profile

Because: 2991 classes loaded during startup, 31 ms on the critical path

Its finding is information in this trace. Nothing here says users see a problem from it yet.

  • See what is compiled: adb shell dumpsys package dexopt | grep -A2 <pkg>
  • Not speed-profile: the profile is missing or was not installed. Add one with BaselineProfileRule
  • Already speed-profile: the profile is stale. Regenerate it over the startup path
  • Measure both builds with ab_startup.sh <pkg> <activity> 10 profile, so both are compiled

Where. baseline-prof.txt, or the module that generates the profile

Check. classes loaded in startup, class loading (ms), cold start TTID (ms)

6skill: compose-expert

Reduce the Compose work that runs every frame

Because: Compose runtime work ranks in this trace: the fix belongs to compose-expert

Also: com.example.app: cost is on the UI thread

Also: Measure/layout/traversal cost during janky frames (1316 ms)

Its finding is information in this trace. Nothing here says users see a problem from it yet.

  • Use the compose-expert skill to find what recomposes or animates on every frame
  • Pause infinite animations when the screen is idle, covered or in the background
  • Read state as late as possible: in layout or draw, not in composition

Where. not known from the trace. Map the slices to code first.

Check. late frames (%), worst overrun (ms)