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

[iOS] crash updating polyline source shape #10924

Closed
RomainQuidet opened this issue Jan 15, 2018 · 11 comments
Closed

[iOS] crash updating polyline source shape #10924

RomainQuidet opened this issue Jan 15, 2018 · 11 comments
Labels
iOS Mapbox Maps SDK for iOS needs information

Comments

@RomainQuidet
Copy link
Contributor

Platform: iOS
Mapbox SDK version: 3.6

Steps to trigger behavior

  1. Create a polyline source, add it to the current style
  2. Create a MGLShapeCollectionFeature with one or more polylines
  3. Set the polyline source shape with the shape collection

Expected behavior

Polylines are displayed

Actual behavior

Crash.
Help needed to understand where it does come from.
Is it linked to issue #8882 ?

Incident Identifier: 10711CE0-17E6-49CB-8823-EE07E1419A25
CrashReporter Key: 0091987D-EA79-4CCB-ABD0-F93F29734434
Hardware Model: iPhone9,3
Process: Mappy [536]
Path: /var/containers/Bundle/Application/D304BB50-7DA6-4D06-AB56-046F35B7E1DA/Mappy.app/Mappy
Identifier: com.mappy.Mappy
Version: 6.1802.0 (6.1802.0.12)
Code Type: ARM-64
Parent Process: ??? [1]

Date/Time: 2018-01-11T19:22:43Z
Launch Time: 2018-01-11T19:18:05Z
OS Version: iPhone OS 11.2.2 (15C202)
Report Version: 104

Exception Type: SIGSEGV
Exception Codes: SEGV_ACCERR at 0x78
Crashed Thread: 0

Thread 0 Crashed:
0 Mappy 0x0000000105a8e848 mbgl::style::GeoJSONSource::Impl::setGeoJSON(mapbox::util::variant<mapbox::geometry::geometry, mapbox::geometry::feature, mapbox::geometry::feature_collection<double, std::__1::vector> > const&) + 20
1 Mappy 0x0000000105a8e584 mbgl::style::GeoJSONSource::setGeoJSON(mapbox::util::variant<mapbox::geometry::geometry, mapbox::geometry::feature, mapbox::geometry::feature_collection<double, std::__1::vector> > const&) + 20
2 Mappy 0x000000010589d56c MGLGeoJSONOptionsFromDictionary(NSDictionary<NSString*, objc_object*>*) + 3396
3 Mappy 0x0000000105852a38 -[MFMapView addPolylineLayersFrom:] (MFMapView.m:1370)

@RomainQuidet
Copy link
Contributor Author

line 1370 from MFMapView is doing:

MGLShapeCollectionFeature *shapesFeatures = [MGLShapeCollectionFeature shapeCollectionWithShapes:self.polylinesFeatures];
self.polylinesSource.shape = shapesFeatures;

@LukasPaczos LukasPaczos added the iOS Mapbox Maps SDK for iOS label Jan 15, 2018
@RomainQuidet
Copy link
Contributor Author

RomainQuidet commented Jan 16, 2018

@boundsj We'd appreciate some help here as it is a bug that happens often on production (3% crash rate...), but we are not able to reproduce it manually. Thanks for any advice or clue!

@jmkiley
Copy link
Contributor

jmkiley commented Jan 16, 2018

Hi @RomainQuidet -
I have not had luck repro'ing this with v3.7.3. Do you switch styles after creating the source? A minimal test case that reproduces this issue with the latest version of the SDK would be greatly appreciated (I understand that manually reproducing this is tricky).

@RomainQuidet
Copy link
Contributor Author

Hi,
As we can not reproduce manually this issue, moving to v3.7.3 will be a blind move.
We do not change style while updating the shape. Each time we update the style, we recreate a source and the shape features.

@RomainQuidet
Copy link
Contributor Author

What information do you need?

@jmkiley
Copy link
Contributor

jmkiley commented Jan 18, 2018

Hi @RomainQuidet -

Do you add the source to the new style? If you do not, the workarounds that are suggested in #8882 may be helpful:

Workarounds for this issue include recreating and adding the source and layer stack each time a style loads or only adding the source/layer to a specific style and also using APIs like -[MGLStyle sourceWithIdentifier:] instead of keeping references to sources in objects in the application space.

Otherwise, a minimal test case that reproduces this issue would be great!

@RomainQuidet
Copy link
Contributor Author

Hi,
Each time we change the style, we recreate the source and layers.
What I don't understand is how we can not reproduce this bug during our alpha and beta tests, but 3% of our users are crashing with this ...
I really want to find a test case, but for the moment I can't.

@jmkiley
Copy link
Contributor

jmkiley commented Jan 19, 2018

Hi @RomainQuidet -

It looks like you may be seeing #8882. Would you be able to share the code that handles layers and sources either here or with our support team?

@RomainQuidet
Copy link
Contributor Author

RomainQuidet commented Jan 22, 2018

Hi,

We create polylines features, and store them in an array in order to reuse them in case of style change

MGLPolylineFeature *polylineFeature = [MGLPolylineFeature polylineWithCoordinates:polyline.coordinates count:polyline.pointCount];
NSString *polylineId = [self polylineIdentifier:polyline];
polylineFeature.attributes = [NSDictionary dictionaryWithObject:polylineId forKey:kMappyPolylinesIdentifier];
[self.polylinesFeatures addObject:polylineFeature];

Then we add a layer to our style

NSString *layerId = [NSString stringWithFormat:@"%@-%@", kMappyPolylineLayerPrefixIdentifier, polylineId];
MGLLineStyleLayer *layer = [[MGLLineStyleLayer alloc] initWithIdentifier:layerId source:polylinesSource];
[self.actualMapView.style addLayer:layer];

and we update the source shape

MGLShapeCollectionFeature *shapesFeatures = [MGLShapeCollectionFeature shapeCollectionWithShapes:self.polylinesFeatures];
polylinesSource.shape = shapesFeatures;

The crash occures when we update the source shape.

@jmkiley
Copy link
Contributor

jmkiley commented Jan 25, 2018

Hey @RomainQuidet -

Could you confirm where you are calling the code in the above comment? Also, are you recreating the source and layer in mapView:didFinishLoadingStyle? Setting a style occurs asynchronously, so this can be a tricky crash to track down.

Another option may be to use the source identifier to access the source from the style directly (rather than storing it as a class property). You can do this by using [MGLStyle sourceWithIdentifier:].

@RomainQuidet
Copy link
Contributor Author

We made a try and used the api [MGLStyle sourceWithIdentifier:] to get the source instead of keeping a reference on it on production. It killed the bug.
I'm confused because each time a new style is applied, we recreate the source and add our polyline to it. I don't understand this bug.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
iOS Mapbox Maps SDK for iOS needs information
Projects
None yet
Development

No branches or pull requests

4 participants