Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Diagnoses SwiftUI performance issues — slow rendering, janky scrolling, high CPU/memory — through code review and Instruments profiling guidance.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/understanding-hangs-in-your-app.md
1# Understanding Hangs in Your App (Summary)23Context: Apple guidance on identifying hangs caused by long-running main-thread work and understanding the main run loop.45## Key concepts67- A hang is a noticeable delay in a discrete interaction (typically >100 ms).8- Hangs almost always come from long-running work on the main thread.9- The main run loop processes UI events, timers, and main-queue work sequentially.1011## Main-thread work stages1213- Event delivery to the correct view/handler.14- Your code: state updates, data fetch, UI changes.15- Core Animation commit to the render server.1617## Why the main run loop matters1819- Only the main thread can update UI safely.20- The run loop is the foundation that executes main-queue work.21- If the run loop is busy, it can’t handle new events; this causes hangs.2223## Diagnosing hangs2425- Observe the main run loop’s busy periods: healthy loops sleep most of the time.26- Hang detection typically flags busy periods >250 ms.27- The Hangs instrument can be configured to lower thresholds.2829## Practical takeaways3031- Keep main-thread work short; offload heavy work from event handlers.32- Avoid long-running tasks on the main dispatch queue or main actor.33- Use run loop behavior as a proxy for user-perceived responsiveness.34