anr-audit-and-fix

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese
Select the execution path matching the user's request:
选择与用户请求匹配的执行路径:

1. Path A: Static codebase ANR risk audit

1. 路径 A:静态代码库 ANR 风险审计

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).
审计源文件或扫描线程阻塞操作时:
  • 按照 references/risk_analysis_guide.md 中的步骤逐项执行:列出候选项,证明执行线程(当线程依赖关系取决于调用方时,追踪调用方),证明调用会阻塞,然后进行归因和分级。仅报告通过这些检查的候选项;被排除的候选项应单独列出,并附上一行排除原因。
  • 评估非主线程对已挂载 View 的修改时,不仅要将其视为崩溃风险(
    CalledFromWrongThreadException
    ),还要将其视为 Sync Barrier Leak ANR 风险,并提供相应证明(非主线程执行且操作涉及已挂载的 View)。

2. Path B: Trace-driven diagnosis and remediation

2. 路径 B:基于追踪信息的诊断与修复

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_DEFECT
    or
    APP_RESOURCE_OVERLOAD
    (never for
    EXTERNAL_BOTTLENECK
    ).
分析 ANR 追踪信息或堆栈转储时:
  • 使用 references/trace_analysis_guide.md 进行系统诊断,并按照 references/anr_trace_report_template.md 格式化报告。
  • 严格基于日志证据得出结论。仅针对
    APP_DEFECT
    或
    APP_RESOURCE_OVERLOAD
    提出应用修复方案,绝不要针对
    EXTERNAL_BOTTLENECK
    提出修复方案。