Anr Audit And Fix
Android (Google)OfficialCreated by Google LLCDistributed by Android (Google)
- Skill
- Review and audit
- Software development
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
The anr-audit-and-fix skill provides a structured methodology for identifying and remediating Application Not Responding (ANR) issues in Android applications. It supports two primary workflows: a static analysis path for auditing source code to detect potential thread-blocking operations or sync barrier leaks, and a trace-driven path for analyzing existing ANR stack dumps to determine root causes and propose fixes.
What it does
- Performs static analysis on Android source code to identify potential main-thread blocking operations.
- Detects Sync Barrier Leak risks caused by off-main-thread mutations of attached Views.
- Systematically diagnoses ANR stack dumps and trace files.
- Categorizes ANR findings into application defects, resource overloads, or external bottlenecks.
- Provides a standardized reporting template for ANR trace analysis.
- Offers guidance on distinguishing between actual ANR risks and non-blocking operations.
When to use it
- When auditing Android source code to proactively find potential ANR-causing code patterns.
- When investigating a reported ANR to determine if it is caused by application code or external factors.
- When analyzing stack dumps to identify specific blocking chains or thread contention issues.
- When verifying if off-main-thread UI access is creating a Sync Barrier Leak risk.
Advantages
- Enforces a rigorous proof-based approach to identifying thread-blocking candidates.
- Distinguishes between critical ANR risks and minor frame drops.
- Provides a clear framework for differentiating between application-level defects and external system bottlenecks.
- Standardizes the documentation and reporting of ANR investigations.
Usage examples
- “Audit this Activity for potential ANR risks.”
- The agent will scan the provided code, verify the executing thread for blocking primitives, and report any confirmed ANR risks or Sync Barrier Leaks.
- “Analyze this ANR stack dump and suggest a fix.”
- The agent will process the trace, identify the unresponsive thread and blocking mechanism, and provide a structured report with a recommended code fix if the issue is an application defect.
Install
Download the skill as a ZIP:
https://mp-staging.autogineer.com/agent-skills/android/anr-audit-and-fix/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip anr-audit-and-fix.zip -d .agents/skills
Documentation by Google LLC
Select the execution path matching the user's request:
1. Path A: Static codebase ANR risk audit
When auditing source files or scanning for thread-blocking operations:
Follow references/risk_analysis_guide.md step by step: list candidates, prove the executing thread (trace callers when the thread depends on them), prove the call blocks, then attribute and grade. Report only candidates that pass these checks; list the dismissed ones separately with a one-line reason.
Evaluate off-main-thread mutations of attached Views not merely as crash risks (
CalledFromWrongThreadException), but as Sync Barrier Leak ANR risks with their own proof (off-main execution plus an attached View).
2. Path B: Trace-driven diagnosis and remediation
When analyzing ANR traces or stack dumps:
Diagnose systematically using references/trace_analysis_guide.md and format the report with references/anr_trace_report_template.md.
Base findings strictly on log evidence. Propose application fixes only for
APP_DEFECTorAPP_RESOURCE_OVERLOAD(never forEXTERNAL_BOTTLENECK).
Files
- ATTRIBUTION.mdAdded by AutoGineer972 B
- LICENSELicence file added by AutoGineer11.1 KiB
- SKILL.md1.7 KiB
- references/anr_trace_report_template.md1.9 KiB
- references/risk_analysis_guide.md6.9 KiB
- references/trace_analysis_guide.md11.6 KiB
references/anr_trace_report_template.md
> **Overview**: **`<APP_DEFECT | APP_RESOURCE_OVERLOAD | EXTERNAL_BOTTLENECK>`**<>/span>
(`<Diagnosis>`) -- `<1-line conclusion and exact trace evidence to inspect>`
### 1. Trace validity and context
- **Process**: `<package or unknown>` (PID: `<pid>`, Foreground: `<Yes/No>`)
- **ANR Trigger**: `<Subject>`
- **Unresponsive Thread**: `<tid=1 | binder:<tid> (ContentProvider) | <handler
or goAsync worker thread> (BroadcastReceiver)>`
- **User-Perceived ANR**: **`<Yes | No>`** (`<Foreground UI freeze / Foreground
termination | Silent background term>ination`)
- **Capture Delay**: `<Immediate | Delayed Snapshot>` (`<stack trustworthy |
b>ypassed`)
### 2. System health assessment
- **Metrics**: `<Key PSI avg10, CPU %, iowait %, page faults, or lock state>`
- **Verdict**: **`<APP_DEFECT | APP_RESOURCE_OVERLOAD | EXTERNAL_BOTTLENECK>`**
- **Contributing Factor**: `<None | EXTERNAL (<process or metric>) | APP (<thread or workload>)>`
### 3. Root cause analysis
- **Unresponsive Thread State**: `<Thread state and top blocking frame>`
- **Blocking Chain / Mechanism**: `<Lock holder tid=N / UI race / Sync I/O /
Binder target>`
- **Secondary / Compounding Threads**: `<state=D I/O, native hooks, or None>`
- **Diagnosis**: **`<Concise root-cause label, e.g., View Threading Violation
(Sync Barrier Leak [Confirmed | probable]), Lock Contention, Deadlock,
Main-Thread Blocking Call / I/O / Compute, IPC Stall, Async Lifecycle
Timeout, External Starvation, or Indeterminate (Delayed Snapshot)>`**
### 4. Remediation
1. **Code Fix**: `<Concrete fix for APP_DEFECT / APP_RESOURCE_OVERLOAD, or "N/A
-- No application code change required (External system bottleneck)">`
2. **Prevention**: `<Architectural safeguard, or "N/A -- No application code
change required (External system bottleneck)">`Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Google LLC
- Publisher
- Android (Google) (Official)
- Distributed by
- Android (Google)
- Source
- android/skills · performance/anr-audit-and-fix · commit bf68e2d
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.txt)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Google LLC or Android (Google).
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download anr-audit-and-fix.zip