Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Occasional exception when setting layer style property #3020

Open
naftalibeder opened this issue Aug 29, 2023 · 2 comments
Open

[Bug]: Occasional exception when setting layer style property #3020

naftalibeder opened this issue Aug 29, 2023 · 2 comments

Comments

@naftalibeder
Copy link
Collaborator

naftalibeder commented Aug 29, 2023

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.

@mfazekas
Copy link
Contributor

@naftalibeder thanks much for the report. Do you have before/after ID on that particular layer?! Also do you have change the style of the map, that removes then readds all the layers.

Is this an existing layer on the style or is it handled by rnmapbox?

I'd debug such issue with adding a breakpoint in the native layer, and also logging where layer get's added/removed. And if we call setPropery before adding the layer or after removing it.

Making this into a warning is acceptable but not great, but it would be much more valueble to do some investigation and try to find out what's going on.

@rnmapbox rnmapbox deleted a comment from github-actions bot Aug 29, 2023
@naftalibeder naftalibeder reopened this Aug 29, 2023
@rnmapbox rnmapbox deleted a comment from github-actions bot Aug 29, 2023
@salsowelim
Copy link

I have the same issue.

@mfazekas mfazekas added the waiting Non planned issues label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants