Skip to content

ANR Detection Improvements Needed for Modal Dialog HandlingΒ #1016

@smeubank

Description

@smeubank

Problem Statement

Summary

The current ANR (Application Not Responding) detection in the Electron SDK generates false positives when modal dialogs are shown, particularly on Windows. This leads to misleading non-responsiveness reports for intentional UI pauses.

Problem Description

When using modal dialogs (e.g., dialog.showSaveDialog) in Electron applications, the UI thread is intentionally blocked while waiting for user input. However, the ANR detection system interprets this as an application freeze and generates false positive reports.

Current Behavior

  • ANR events are triggered after 5 seconds of UI thread blocking
  • Modal dialogs that take longer than 5 seconds to dismiss trigger ANR reports
  • No built-in way to distinguish between actual freezes and intentional modal pauses
  • High volume of false positives in common scenarios

Expected Behavior

The ANR detection should:

  1. Automatically detect and handle system modal dialogs
  2. Provide API to temporarily disable ANR detection during known modal operations
  3. Include context about foreground window/process ownership in ANR reports
  4. Distinguish between intentional UI blocks and actual application freezes

Solution Brainstorm

  1. Automatic Detection:

    • Detect when foreground window is owned by system process
    • Skip ANR reporting in these scenarios
  2. API Improvements:

    • Expose methods to manually pause/resume ANR detection
    • Allow configuration of modal dialog handling
    • Provide hooks for custom modal detection logic
  3. Enhanced Context:

    • Include foreground process information in ANR reports
    • Add window ownership details to event metadata
    • Enable filtering/grouping of modal-related ANRs

Impact

  • Customers are disabling ANR detection due to noise
  • Reduced reliability of actual freeze detection
  • Decreased confidence in ANR reporting accuracy

Related Documentation

Notes

  • Current workarounds using powerMonitor events exist but aren't officially supported/documented
    • not verified
  • Re-enabling consideration depends on proper modal handling implementation

Metadata

Metadata

Assignees

Labels

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions