Skip to content

onPause can block the UI thread for seconds (ANR risk), worst in Quad mode #32

Closed

Description

@compot-dev

Decoder.onPause() stops everything synchronously on the main thread:

  • RtspClient.stop() calls awaitTermination(2 s), and onPause calls it again for the decoder executor (2 s).
  • In Quad mode, QuadCell.stop() calls awaitTermination(2 s) for each of the 4 cells.

The worker loops sleep with SystemClock.sleep(), which ignores interrupts. A cell in reconnect back-off (up to 30 s) or in a handshake read (5 s timeout) therefore uses the whole 2 s timeout. With 4 cameras offline, leaving the app can block the UI thread for about 8 s. Android shows an ANR after 5 s of blocked input.

Fix: signal the threads to stop and return immediately; release codecs once the threads have finished. Use interruptible waits (Thread.sleep, or a condition with a timeout) instead of SystemClock.sleep.

Activity

  1. added
    bugSomething isn't working
    in progressBeing worked on right now (open PR)
    on Oct 12, 2026
  2. added a commit that references this issue on Oct 12, 2026
  3. added 2 commits that reference this issue on Oct 15, 2026
    c7b1db2
    b6d2e1d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions