mapbox / mapbox-gl-native

Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
4.37k stars 1.33k forks source link

Readded style layers lose all paint properties #7437

Closed 1ec5 closed 7 years ago

1ec5 commented 7 years ago

If you remove a layer from a style and add it back in, all its former paint properties are reset to the default values.

To reproduce this issue in macosapp:

  1. Change the style to Streets.
  2. In the Layers sidebar, right-click a symbol layer such as country-layer-lg and go to Delete.
  3. Go to Edit ‣ Undo.

The layer comes back with the right layout properties but the wrong paint properties. For example, the readded symbol layer has the right textField, textSize, textFont, etc. but the wrong textHaloBlur:

before after

Essentially what macosapp does is to hold onto the selected layers for later insertion before removing them from the style. Given that the layout properties are persisted, I’d imagine the problem lies in core rather than at the SDK or application level.

/cc @boundsj

1ec5 commented 7 years ago

Moving to v3.5.0 because mbgl changes are needed.

jfirebaugh commented 7 years ago

-[MGLStyle layerFromMBGLLayer:] calls [MGL*StyleLayer initWithIdentifier:source:], which sets _pendingLayer to a new mbgl::style::*Layer. This seems like a bug. Among other things rawLayer and _pendingLayer will wind up pointing to different objects, which appears to be the cause of this bug.

1ec5 commented 7 years ago

Basically https://github.com/mapbox/mapbox-gl-native/blob/dfb737ee0fcae49a4cbe2d9fabbea939642d94d8/platform/darwin/src/MGLStyle.mm#L356 needs to be folded into the initializers for the various style layers. We did this more correctly in https://github.com/mapbox/mapbox-gl-native/blob/dfb737ee0fcae49a4cbe2d9fabbea939642d94d8/platform/darwin/src/MGLStyle.mm#L168 for wrapping sources.