Repository navigation
fix(android): accept null lineMetrics, clusterProperties and hitbox on ShapeSource - #4454
Merged
mfazekas merged 1 commit intoNov 23, 2026
Conversation
…n ShapeSource Unsetting these props sends null to the manager, which threw from Dynamic.asBoolean()/asMap(). Null now clears the stored value so the Mapbox default applies (default 44x44 hitbox for hitbox). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 23, 2026
mfazekas
approved these changes
Nov 23, 2026
mfazekas
left a comment
Contributor
There was a problem hiding this comment.
Thanks — verified on an Android release build: unsetting lineMetrics, clusterProperties and hitbox crashed on main and no longer does; remount applies defaults. Optional nit: lineMetrics.asBooleanOrNull() / map.asMapOrNull() from utils/extensions/Dynamic.kt would read a bit tighter.
This branch was previously 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
Follow-up to #4451, as suggested in its review. On Android, unsetting these props on a mounted
ShapeSourcestill crashes, because React Native sendsnullandRNMBXShapeSourceManagercallsDynamic.asBoolean()/asMap()on it:lineMetrics:Dynamic value from Object is not a booleanclusterProperties:Dynamic value from Object is not a ReadableMaphitbox:Dynamic value from Object is not a ReadableMaplineMetricsnow readsif (lineMetrics.isNull) null else lineMetrics.asBoolean(), andclusterProperties/hitboxcheckisNullbeforeasMap(). (The existingmapValue == nullguard afterasMap()could never fire, becauseasMap()throws first.) The stored value is cleared, so the property goes back to the Mapbox default the next time the source is built: the builder already skips null fields. Forhitbox,touchHitboxfalls back to the default 44x44.I also checked
hasPressListener, which callsasBoolean()directly. It isn't affected:ShapeSource.tsxalways sendsisFunction(this.props.onPress), and unsettingonPressin the reproducer doesn't throw. With this change, every prop onShapeSourcecan be unset safely.VectorSourceManager.setHitboxuses the sameasMap()pattern. I didn't reproduce it there, so it's left out of this PR. It already benefits fromRNMBXSource.setHitboxacceptingnull.Checklist
CONTRIBUTING.mdyarn generatein the root folder (no spec or doc change)/exampleapp./example)Screenshot OR Video
Tested on an Android emulator (Pixel 9, API 37) with a debug build of
/example, using the reproducer below in place ofBugReportExample.js. For each prop, on a fresh load, I toggled unset/set 5 times.Before (main):
onPress(hasPressListener)hitboxDynamic value from Object is not a ReadableMapatDynamicFromObject.asMap←RNMBXShapeSourceManager.setHitboxlineMetricsDynamic value from Object is not a booleanatDynamicFromObject.asBoolean←RNMBXShapeSourceManager.setLineMetricsclusterPropertiesDynamic value from Object is not a ReadableMapatDynamicFromObject.asMap←RNMBXShapeSourceManager.setClusterPropertiesAfter: all four props survive 5 toggles each, with no
DynamicFromObjectexception in logcat, and the layer still renders.Component to reproduce the issue you're fixing
BugReportExample.js
🤖 Generated with Claude Code