Repository navigation
fix(android): recover the location puck from a non-finite bearing - #4445
Open
ajtrasatti wants to merge 1 commit into
Open
ajtrasatti wants to merge 1 commit into
ajtrasatti wants to merge 1 commit into
Conversation
ajtrasatti
force-pushed
the
fix/android-non-finite-puck-bearing
branch
from
November 8, 2026 20:09
83da888 to
d1350fe
Compare
The Maps SDK location component keeps the last puck bearing it receives, including NaN or Infinity. The next time the puck layer is added, for example when LocationPuck settings change or its images load, addPersistentStyleLayer throws "IllegalArgumentException: Parse error at offset 165: Missing a colon after a name of object member." and the app crashes (mapbox/mapbox-maps-android#2340). RNMBXNativeUserLocation now applies its settings through LocationPuckGuard. When adding the puck layer fails, it resets the location component through LocationComponentManager, which drops the puck state holding the bad bearing, and applies once more. The reset holds the location provider while giving up location that is on (rnmapbox#4225) and is skipped while the map is stopped (mapbox/mapbox-maps-android#2017). If the reset is skipped or the retry fails too, the component stays disabled and the next puck apply resets it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ajtrasatti
force-pushed
the
fix/android-non-finite-puck-bearing
branch
from
November 8, 2026 20:20
d1350fe to
421043d
Compare
ajtrasatti
marked this pull request as ready for review
November 8, 2026 20:55
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On Android, re-applying
LocationPucksettings after the puck has received a NaN or Infinity bearing crashes the app atStyleManager.addPersistentStyleLayerwithIllegalArgumentException: Parse error at offset 165: Missing a colon after a name of object member.This is the Maps SDK bug mapbox/mapbox-maps-android#2340 and still reproduces with Maps SDK 11.33.0.RNMBXNativeUserLocationnow applies its settings throughLocationPuckGuard. When adding the puck layer fails, it resets the location component throughLocationComponentManagerand retries once, if location is requested and the map is running. Otherwise, or if the retry fails, it disables the component and resets it on the next puck apply while location is requested and the map is running. The reset holds the location provider (#4225); unrelated exceptions still propagate.Checklist
CONTRIBUTING.mdyarn generatein the root folder (no JS or API changes)/exampleapp./example) (bug fix; the reproducer is below)Testing
/examplerelease builds (New Architecture, Maps SDK 11.33.0) on an Android 11 x86 emulator, with the reproducer below:mainFATAL EXCEPTION … Parse error at offset 165Failed to add the location puck, disabled the location component …Mechanism and limits
LocationPuckManagerkeeps the last bearing it receives, NaN included, and its animator then stays at NaN. Re-applying puck settings re-adds the puck layer with that bearing.com.mapbox.bindgen.Value.toJson()swallows Gson's "Numeric values must be finite" and returns the half-written JSON, which ends in"bearing"at offset 165. The native parser rejects it.CustomLocationProviderreplays the NaN when the component re-registers, so the retry fails and the puck stays hidden until the heading is finite.Camerafollow modes andLocationComponentManagersettings changes still re-add the puck outside the guard. The proper fix is filtering non-finite values in the Maps SDK, as v10.20.0 did.Validation
./gradlew :rnmapbox_maps:testDebugUnitTestfromexample/android: 27/27, includingLocationPuckGuardTest(retry, stopped map, pending reset, unrelated exceptions) andLocationComponentResetTest(when the provider is held)./exampleassembleRelease -PreactNativeArchitectures=x86, API 30 Google APIs emulator, results in the table above.Component to reproduce the issue you're fixing
BugReportExample.js — tap "NaN heading", then "Change puck"