You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Crash: USB screen starts its service while the app counts as in the background #189
android.app.BackgroundServiceStartNotAllowedException
at android.content.ContextWrapper.startService
at in.co.gorest.grblcontroller.UsbConnectionActivity.onStart (UsbConnectionActivity.java:82)
Cause
UsbConnectionActivity.onStart() calls startService() for GrblUsbSerialService. Android refuses a service start while it counts the app as in the background, and it can do that at the first onStart() (for example when the screen turns off as the activity starts). The refusal is not caught, so the app crashes.
The service is already created and kept alive by bindService() in onCreate(), and its onStartCommand() does nothing, so the start can be skipped when Android refuses it.
Fix
Catch IllegalStateException around that startService() call and log a warning. BackgroundServiceStartNotAllowedException (Android 12+) and the older refusal both extend it.
Acceptance
When Android refuses the start, the app logs a warning and does not crash. USB connect still works through the bound service.
Fixed in PR #190 (branch fix/186-streaming-fgs-start-crash). Reproduced on the emulator with the old code and checked the fix there. Closes when the PR is merged.
Activity
zeevy commentedon Oct 10, 2026
Fixed in PR #190 (branch
fix/186-streaming-fgs-start-crash). Reproduced on the emulator with the old code and checked the fix there. Closes when the PR is merged.