Skip to content

USB screen keeps stale state after the switch from Bluetooth #188

Closed

Description

@zeevy

BluetoothConnectionActivity.restartInUsbMode() starts UsbConnectionActivity and then calls finish(). Android creates the new activity first and destroys the old one after. So:

  1. UsbConnectionActivity and its tab fragments take MachineStatusListener.getInstance(), FileSenderListener.getInstance() and ConsoleLoggerListener.getInstance() in onCreate.
  2. Then BluetoothConnectionActivity.onDestroy() (through GrblActivity.onDestroy()) calls resetClass() on all three, which replaces the shared objects.
  3. The USB screen and its fragments keep the old objects, while the serial handlers and the streaming service use the new ones.

Result: in that session the status card does not update, and a selected file is set on the old object that the streaming service does not read. A restart of the app fixes it.

It happens when the app falls back from Bluetooth to USB: no Bluetooth adapter, or the Bluetooth permission is denied.

Expected: the USB screen uses the same shared objects as the rest of the app after the switch.

Found while fixing the streaming start crash (ForegroundServiceDidNotStartInTimeException).

Activity

  1. zeevy commented on Oct 10, 2026

    @zeevy
    OwnerAuthor

    Fixed in PR #192 (branch fix/187-188-lifecycle-state). Reproduced on the emulator with the old code and checked the fix there and on a Pixel 6a with GRBL 1.1f over USB. Closes when the PR is merged.

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions