Skip to content

Add NavigationView (NavigationViewController on iOS, UI components on Android) - #1

Merged
mfazekas merged 9 commits into
mainfrom
feat/navigation-view
Oct 21, 2026
Merged

mfazekas merged 9 commits into
mainfrom
feat/navigation-view

Conversation

@mfazekas

@mfazekas mfazekas commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Adds <NavigationView>, a full-screen "route from A to B and navigate" UI next to the headless API. On iOS it embeds MapboxNavigationUIKit's NavigationViewController as a child view controller. On Android it's an equivalent built from the Navigation SDK v3 ui-components on a plain Mapbox MapView: maneuver banner, speed limit, trip progress, mute, overview, recenter and end buttons, route line with the maneuver arrow, puck and navigation camera.

<NavigationView
  waypoints={[origin, destination]} // or route={routeFromRequestRoutes}
  simulate
  mute={muted}
  onRouteProgress={(e) => {}}
  onArrive={({ waypointIndex, isFinalDestination }) => {}}
  onCancel={() => close()}
  onError={({ code, message }) => {}}
/>

Fabric props can't carry host objects, so the JS component passes a numeric routeId from a new getRouteId(route) binding, and native views resolve it through a C++ registry of live routes. The view uses the shared navigation session: mounting it, or passing a new route, replaces any active guidance; unmounting it or the end button stops guidance. Module route-progress events also report its guidance. On Android the guidance start/stop logic moved from the module into RNMBXNavigationSession so both callers share it.

Changes in this pass:

  1. Rebased on main (maps 10.3.11 SPI, new README, CI fixes). The NavigationView docs are folded into the new README, and its known limitations updated. Trimmed the comments.
  2. Android simulation sometimes started at 100% and reported an arrival. On restart the navigator first matched the new route against the previous trip session's last location, extrapolated by the elapsed time (logs showed 140–150 m traveled, then OFF_ROUTE, then a jump back to the start; with a longer gap it lands past the destination). The session now calls resetTripSession and only sets the routes and starts the replay in its callback. After the fix, restarts begin at the full distance with no off-route.
  3. Android arrival: the final arrival is reported once per guidance start. The double arrival I could reproduce came from the bug above: a bogus arrival at start, then the real one.
  4. Android leaks found while looping open/close (the app was OOM-killed after about a dozen visits): the Maps lifecycle plugin kept each NavigationView's MapView alive until the activity was destroyed (~370 MB per visit on the emulator). The view now gives its map its own lifecycle, as @rnmapbox/maps does. Separately, RNMBXNavigationMapFactory.bindings (from main) was a WeakHashMap whose value referenced its key, so navigation maps were never collected. Views and PSS now stay flat across cycles.
  5. iOS had the same class of bug: restarting a route after arriving began at 0 m and reported an arrival. The SDK's simulator only re-seeds when the route length changes, and the replacement simulator from apply(coreConfig:) arrives two main-actor turns after guidance starts. prepareActiveGuidance now seeds the simulation with the route's origin and waits for the swap before guidance starts, on both the headless and the NavigationView path.
  6. iOS: the view controller's mute button now follows mute. The SDK keeps it internal, so it's found among floatingButtons as the one with a selected image. The state is re-applied after viewWillAppear, which otherwise resets it.

Tested on the iOS simulator and the Android emulator with the "NavigationView" example screen, which now counts arrival events: guidance with banner and progress, one arrival per run, clean restarts after an arrival, mute toggles in sync with the SDK button in both directions, and repeated open/close.

Android still has no end-of-route, feedback or alternative-route UI, no day/night styles, no road name label, and doesn't show reroutes as such. These are listed in the README.

The navigator first matched a new route against the previous trip session's
last location, extrapolated by the time since. Simulated guidance could
start at 100% progress and report an arrival, then arrive again. Reset the
trip session before setting the routes and starting the replay.
Under the activity's lifecycle the Maps lifecycle plugin keeps every MapView
and its renderer alive until the activity is destroyed, about 370 MB per
NavigationView on an emulator. Give the map its own lifecycle, as
@rnmapbox/maps does for its maps.
The WeakHashMap's value, the binding, references its key, so navigation
maps were never collected.
The view controller's mute button only reflected its own taps. The SDK keeps
the button internal; it's found as the floating button with a selected image.
@mfazekas
mfazekas force-pushed the feat/navigation-view branch from c0ef1f8 to 0836ccd Compare October 20, 2026 22:18
The SDK's simulator only re-seeds when the route length changes, and the
replacement simulator arrives after guidance has started, deriving its
position from progress matched against the previous simulation's location.
Restarting a route after arriving began at 0 m and reported an arrival.
Seed the simulation with the route's origin, and start guidance once the
SDK has swapped in the new location client.
@mfazekas
mfazekas force-pushed the feat/navigation-view branch from af47cdc to e319cd8 Compare October 20, 2026 22:54
@mfazekas
mfazekas marked this pull request as ready for review October 20, 2026 23:04
@mfazekas
mfazekas merged commit 745af11 into main Oct 21, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant