Skip to content

Crash when the app is opened right after an update: WebService stopped before startForeground #308

Backlog

Description

@compot-dev

Seen on aceline-3 (Android 10, API 29) with 2.30.0 from latest; the code is the same since 2.27.0 (#289, 9aa04e8), so it is not new in 2.30.0.

Repro: adb install -r decoder-v2.apk over an installed Decoder with remote access allowed, then am start -n com.openipc.decoder/.Decoder at once. 2 of 3 tries crashed:

android.app.RemoteServiceException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{… com.openipc.decoder/.WebService}
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1945)

The Crash screen shows; a new start of the app works.

Cause: MY_PACKAGE_REPLACED → WebService.startAfterUpdate → startForegroundService (the app is not open yet). The activity opens before the service's onStartCommand ran and calls WebService.stop → stopService. A foreground service stopped before it called startForeground crashes the app (Android 9+).

Fix idea: do not stop a service whose start is still pending: stop() leaves it, and onStartCommand (after startForeground) stops itself when the app is open or opening (Decoder.openOrOpening()), as it already does when remote access is off.

Activity

  1. added
    bug
    on Nov 24, 2026
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

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions