Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Removing a style layer before adding the same layer should not cause a crash #8053

Closed

Description

@boundsj

From #7962 (comment):

On iOS/macOS, -[MGL*StyleLayer removeFromMapView:] clears its internal state before telling mbgl to remove the layer from the style. If the layer isn’t part of the style, -removeFromMapView: will bail, resulting in an unusable MGLStyleLayer object. The following code would crash:

MGLBackgroundStyleLayer *fillLayer = [[MGLBackgroundStyleLayer alloc] initWithIdentifier:@"bg"];
[style removeLayer:fillLayer]; // no-op
// …
[style addLayer:fillLayer]; // MGLRedundantLayerException
I think the correct behavior would be to ensure that _pendingLayer ends up with whatever either _pendingLayer or rawLayer had at the beginning of this method.

I think we can address this by moving the pointer / property assign statements in between the early returns of the methods and setting them to values that they would have had when the Objective-C layer object was created in the first place (#7962 (comment))

cc @1ec5

Activity

  1. added
    iOS
    macOS
    on Feb 14, 2017
  2. added this to the ios-v3.5.0 milestone on Feb 14, 2017
  3. self-assigned this
    on Feb 14, 2017
  4. boundsj commented on Feb 23, 2017

    @boundsj
    ContributorAuthor

    This was fixed in #7962.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

crashiOSmacOSruntime styling

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions