Skip to content

UI never resyncs engine state after the activity is recreated or misses a broadcast while stopped #96

Description

@tekstrand

A new MonitorViewModel starts at STOPPED and only learns otherwise from a broadcast. Local broadcasts aren't sticky, so two cases leave the UI wrong while the engine is fine:

  1. Android kills MainActivity under memory pressure while the foreground service keeps the process alive. The new activity gets fresh ViewModels and the service never says Running again.
  2. onStop unregisters the receivers, so anything that happens while the screen is off or another app is in front is lost. An engine error while backgrounded leaves the strip on Receiving.

Two possible solutions

  1. the activity asks the service for current state on start
  2. the service keeps the current state somewhere the ViewModels read directly

The first one just fixes engine state. The second one generally resolves this whole class of bug, since anything the UI reads from the service would always be current, rig status and frequency included. The second one seems like the better solutions but it's a bigger change so figured I'd get feedback first.

Activity

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