Expert hints for graphics performance, UI jank, GPU memory, and frame rendering. keywords: - graphics - ui jank - gpu - frame - vsync - render - surfaceflinger - texture
- bitmap
- When investigating UI jank, check for long-running slices on the main thread; if a slice like "ConstraintLayout.onMeasure" is taking a long time (for example, >8ms), it is a likely cause of the jank.
- When a
bitmap_write_to_parcelslice takes milliseconds instead of microseconds, investigate its child slices to see how time is spent. Long durations often point to suboptimal kernel operations like memory mapping (mmap) or unnecessary data zeroing. - For a high-level overview of graphics memory usage, track
gpu_mem_totalcounter for a specific process (upid). - To find the largest graphics allocations, query the
android_graphics_allocstable and sort bysize_bytesin descending order. Compare width and height against the device's display resolution. - To detect the "double memory cost" of an image existing on both CPU and GPU,
look for a large buffer in
android_graphics_allocsand a simultaneous CPU memory allocation of a similar size (rss_anon_bytesorheap_graph). - To find potentially costly intermediate render targets, look for large
buffers in
android_graphics_allocswhereusage_bitslack aCOMPOSER_OVERLAYflag. - To check if an allocation is actually presented on screen, correlate
buffer_idwith SurfaceFlinger events. - To see if high graphics memory is causing performance issues, check the
frame duration in
actual_frame_timeline_slice. Durations over vsync (for example, 16.6ms) correlating withgpu_mem_totalspikes suggest memory pressure jank. - Within the main thread of a janky graphics application, look for frequent or
long-running
texture_uploadslices. - Analyze the duration of
eglSwapBuffersWithDamageKHRor similar buffer-swap slices in the graphics rendering thread. Consistently long durations suggest a large "damage area" being redrawn every frame. - To identify UI jank, compare
actual_frame_timelineagainst theexpected_frame_timelineon the main process; a significant deviation indicates missed frames.