Skip to content

basic: duplicate worker threads after a quick pause/resume #38

Closed

Description

@compot-dev

startListener() starts 4 plain Threads that loop while (listener). onPause() sets listener = false, and onResume() sets it back to true and starts 4 new threads. The flags listener and activeStream are not volatile, and nothing waits for the old threads to exit.

If the app is resumed before every old thread has seen listener == false (a network thread blocked in a 1 s read, a quick screen off/on), the old threads keep running next to the new ones. Two network threads connect to the camera, and two decode threads feed the same decoder. Because the flags are not volatile, a thread may also never see the change at all.

Fix: use a generation counter (as v2 does) or an executor that is shut down and awaited, and make the flags volatile.

Activity

  1. added
    bugSomething isn't working
    basicLegacy basic branch
    on Oct 12, 2026
  2. compot-dev commented on Oct 12, 2026

    @compot-dev
    CollaboratorAuthor

    Fixed in #41 (merged into basic as 6cf68b5). Not closed automatically because basic is not the default branch.

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

    basicLegacy basic branchbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions