Skip to content

Always-on VPN may fail to start and sing-box crashes with ForegroundServiceDidNotStartInTimeException #1010

@CatzTimes

Description

@CatzTimes

Issue type

Feature not working as intended

Device

Xiaomi POCO F2 Pro (lmi)

crDroid version

crDroid 12

Exact version / Build date

12.10 / 2026-05-25

Bug description

When enabling “Always-on VPN” for sing-box, the VPN service may fail to start correctly after reboot or automatic system startup. The app can crash with ForegroundServiceDidNotStartInTimeException.

Manual VPN startup works normally. The issue only occurs when Always-on VPN is enabled.

Steps to reproduce

Step 1. Install sing-box VPN client.
Step 2. Go to Settings → Network & Internet → VPN.
Step 3. Enable “Always-on VPN” for sing-box.
Step 4. Reboot the device or allow the system to auto-start the VPN service.
Step 5. Observe VPN startup behavior.

Relevant log (logcat/build log)

time: 1778003195635
msg: android.app.StackTrace: Last startServiceCommon() call for this service was made here
stacktrace: android.app.RemoteServiceException$ForegroundServiceDidNotStartInTimeException: Context.startForegroundService() did not then call Service.startForeground(): ServiceRecord{47e88ce u0 io.nekohasekai.sfa/.bg.VPNService c:android}
	at android.app.ActivityThread.generateForegroundServiceDidNotStartInTimeException(ActivityThread.java:2530)
	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2498)
	at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2882)
	at android.os.Handler.dispatchMessage(Handler.java:132)
	at android.os.Looper.dispatchMessage(Looper.java:333)
	at android.os.Looper.loopOnce(Looper.java:263)
	at android.os.Looper.loop(Looper.java:367)
	at android.app.ActivityThread.main(ActivityThread.java:9317)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:569)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:929)
Caused by: android.app.StackTrace: Last startServiceCommon() call for this service was made here
	at android.app.ContextImpl.startServiceCommon(ContextImpl.java:2115)
	at android.app.ContextImpl.startForegroundService(ContextImpl.java:2069)
	at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:875)
	at e6.o.l(r8-map-id-c1c055f3283a5e997acc60fc44bae16a579dfbaedc816d08271cd56a5c2d7be6:1)
	at io.nekohasekai.sfa.bg.BoxService$Companion.start(r8-map-id-c1c055f3283a5e997acc60fc44bae16a579dfbaedc816d08271cd56a5c2d7be6:27)
	at io.nekohasekai.sfa.bg.BootReceiver$onReceive$1$1.invokeSuspend(r8-map-id-c1c055f3283a5e997acc60fc44bae16a579dfbaedc816d08271cd56a5c2d7be6:10)
	at tf.a.resumeWith(r8-map-id-c1c055f3283a5e997acc60fc44bae16a579dfbaedc816d08271cd56a5c2d7be6:9)
	at og.j0.run(r8-map-id-c1c055f3283a5e997acc60fc44bae16a579dfbaedc816d08271cd56a5c2d7be6:114)
	at android.os.Handler.handleCallback(Handler.java:1070)
	at android.os.Handler.dispatchMessage(Handler.java:125)
	... 7 more

Screenshots or videos

No response

Solution

No confirmed solution yet.

Additional context

The issue was originally observed on crDroid 12.9 and is still reproducible on crDroid 12.10 / 2026-05-25.

The system appears to start the VPN service through the Always-on VPN mechanism, but the service may not enter foreground state in time and gets terminated.

Current status:

  • Manual VPN start: working
  • Always-on VPN: unstable
  • Auto-start after reboot: may fail

I have also reported the same issue upstream in sing-box:
[SagerNet/sing-box Issue #4114]

The problem only occurs when the VPN service is automatically started through the Always-on VPN mechanism after boot.

This may be related to:

  • Android 16 foreground service timing restrictions
  • sing-box service initialization timing
  • or ROM-specific background service handling

Acknowledgements

  • I've checked device is officially supported and that no support is provided for unofficial devices (for device specific reports and not source related).
  • I'm running latest version available on crdroid.net for this device and that the device is still maintainer supported (not flagged unsupported on download page)
  • I have searched the existing issues and this is a new and no duplicate or related to another open issue.
  • I have written a short but informative title.
  • I filled out all of the requested information in this issue properly and understand that not doing so will automatically result in closing of ticket.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triagelabled for new issues in order to confirm viewed and directed properly

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions