Custom router over API

Started by TrulloF, April 13, 2026, 08:49:49

0 Members and 1 Guest are viewing this topic.

TrulloF

[Bug] InvalidObjectException crash when tapping navigation tile with external routing providers - ACTION_COMPUTE_TRACK_PROVIDER service not yet bound

Hi Menion,

I'm developing a third-party routing addon with the help of Claude Code that registers as an ACTION_COMPUTE_TRACK_PROVIDER service. Routing and rerouting work correctly, but Locus crashes whenever the navigation tile is tapped during active navigation (or when the navigation menu is opened, e.g. from the point menu, without having gone through Navigation → Routing first).

Crash:

java.io.InvalidObjectException: Service does not return valid 'trackTypes'

Root cause:
The navigation tile/menu ViewModel enumerates all registered ACTION_COMPUTE_TRACK_PROVIDER services and calls getTrackTypes() on each one synchronously, before onServiceConnected() has fired for services that haven't been bound in the current session. Internally, the API proxy guards every call with an isConnected flag that is only set inside onServiceConnected(). If the service wasn't previously bound, isConnected is still false at call time → InvalidObjectException.

100% reproducible steps:

Install any app (e.g. BRouter) that exports a service with action="locus.api.android.ACTION_COMPUTE_TRACK_PROVIDER".
Start a navigation session without going through Navigation → Routing (so the service was never bound in this session).
Tap the navigation tile during active navigation.
Crash.
Suggested fix (Locus side):

Wrap the getTrackTypes() call in a try/catch and treat the service as temporarily unavailable rather than crashing:

try {
    int[] types = service.getTrackTypes();
    // use types
} catch (InvalidObjectException | RemoteException e) {
    Log.w(TAG, "Routing service not yet connected, skipping: " + e.getMessage());
}

Alternatively, collect track types asynchronously inside onServiceConnected() and update the UI once binding completes, rather than calling eagerly before the connection is established.

Thanks for looking into this!
  •