[Bug]: Occasional exception when setting layer style property
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 2.9k
- Forks
- 947
- Avg merge
- 6d 37m
- Merged PRs (30d)
- 1
Description
Mapbox Implementation
Mapbox
Mapbox Version
default
Platform
Android
@rnmapbox/maps version
#main
Component to reproduce
This isn't standalone, but here is the basic structure.
<MapView>
<Camera />
<ShapeSource id={"nav-source"}>
<SymbolLayer
id={"nav-icon"}
style={{
iconImage: ["get", "arrow"],
iconOffset: [0, -4],
}}
/>
</ShapeSource>
</MapView>
Observed behavior and steps to reproduce
It's very hard to reproduce, but once in a while I get an error like the following on Android:
ERROR Mapbox error Exception failed during setIconImage: Set layer property "icon-image" failed:
Layer nav-icon is not in style
[get, arrow] {"level": "error", "message": "Exception failed during setIconImage: Set layer property \"icon-image\" failed:
It's not exclusively icon-image - If I comment out that property, the error falls back to the next one, in this case icon-offset.
I'm not able to deliberately reproduce the error. (In particular, I tried changing the layer ID just before setProperty() is called, but the effect is that it simply doesn't display the layer - no exception throws.)
Notes / preliminary analysis
I've been down in the Android SDK code for a while. The error is clearly surfacing here, but the actual function call is happening in the generated file here.
I don't follow why a layer would occasionally fail to get added to style, but it sure seems like a race condition.
Any ideas about how to track this one down? Alternatively, I'm wondering if you'd be open to a PR that wraps this line in a try/catch, or potentially regenerates RCTMGLStyleFactory with try blocks around all the setters - the interim goal being to throw a warning instead of an error.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the setter at android/src/main/java-v10/com/mapbox/rctmgl/components/styles/layers/RCTMGLSymbolLayer.kt lines 31-32 into the generated RCTMGLStyleFactory. Compare that path with Mapbox’s Layer.kt and generated SymbolLayer.kt references, then investigate whether the intermittent missing-layer error can be reproduced on Android. Done should include an identified cause and a confirmed behavior for failed style-property updates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin, react-native
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 28/100