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

Crash when setting lineGradient in MGLLineStyleLayer in Release mode. #2493

Closed
MaximAlien opened this issue Jul 28, 2020 · 3 comments · Fixed by #2500
Closed

Crash when setting lineGradient in MGLLineStyleLayer in Release mode. #2493

MaximAlien opened this issue Jul 28, 2020 · 3 comments · Fixed by #2500
Assignees
Labels
bug Something isn’t working
Milestone

Comments

@MaximAlien
Copy link
Contributor

MaximAlien commented Jul 28, 2020

Mapbox Navigation SDK version: 1.0.0-beta.1

Crash occurs when placing destination marker on a map. It's reproducible only in Release mode when running example project and only when using iPhone 5s, Xs, Xr, Xs Max devices (maybe other as well). I cannot reproduce crash when running example on iPhone 11 Simulator. Here's stack trace:
Example_2020-07-27-162644_MacBook-Pro.txt

Crashed Thread:        0  Dispatch queue: com.apple.main-thread

Exception Type:        EXC_CRASH (SIGABRT)
Exception Codes:       0x0000000000000000, 0x0000000000000000
Exception Note:        EXC_CORPSE_NOTIFY

Application Specific Information:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'
terminating with uncaught exception of type NSException
abort() called
CoreSimulator 725.10 - Device: iPhone Xs Max (03DF22DF-2111-47B1-96F9-50E03D8FABDA) - Runtime: iOS 12.2 (16E226) - DeviceType: iPhone Xs Max

Application Specific Backtrace 1:
0   CoreFoundation                      0x00000001038e86fb __exceptionPreprocess + 331
1   libobjc.A.dylib                     0x0000000102e94ac5 objc_exception_throw + 48
2   CoreFoundation                      0x0000000103836ddc _CFThrowFormattedException + 194
3   CoreFoundation                      0x0000000103813ae5 -[__NSArrayM insertObject:atIndex:] + 1269
4   Mapbox                              0x0000000102484cfb -[NSExpression(MGLAdditions) mgl_jsonInterpolationExpressionObject] + 1923
5   Mapbox                              0x0000000102482ad2 -[NSExpression(MGLAdditions) mgl_jsonExpressionObject] + 10432
6   Mapbox                              0x000000010249bdab _ZN24MGLStyleValueTransformerIN4mbgl5ColorEU8__strongP7UIColorS1_S4_E15toPropertyValueINS0_5style22ColorRampPropertyValueEEENSt3__19enable_ifIXsr3std7is_sameIT_S8_EE5valueESB_E4typeEP12NSExpression + 71
7   Mapbox                              0x00000001024acd33 -[MGLLineStyleLayer setLineGradient:] + 104
8   MapboxNavigation                    0x000000010037ece3 $s16MapboxNavigation0B7MapViewC19mainRouteStyleLayer10identifier6sourceSo07MGLLinegH0CSS_So9MGLSourceCtF + 1139
9   MapboxNavigation                    0x000000010039637e $s16MapboxNavigation0B7MapViewC4show_8legIndexySay0A10Directions5RouteCG_SitFTf4ndn_n + 990
@MaximAlien MaximAlien added bug Something isn’t working - crash labels Jul 28, 2020
@1ec5 1ec5 added this to the v1.0.0 milestone Jul 28, 2020
@1ec5
Copy link
Contributor

1ec5 commented Jul 28, 2020

If you can reproduce this crash with a debugger attached, it would be helpful to print out the expression that we’re trying to set here:

mainRouteLayer.lineGradient = NSExpression(format: "mgl_interpolate:withCurveType:parameters:stops:($lineProgress, 'linear', nil, %@)", routeGradientStops.line)

The stack trace seems to show that a nil crept into the routeGradientStops.line. #2423 tracks rewriting this property.

/cc @captainbarbosa @avi-c @d-prukop

@1ec5
Copy link
Contributor

1ec5 commented Jul 29, 2020

#2500 has a workaround that casts the Dictionary<CGFloat: UIColor> to a NSDictionary with no lightweight generic parameters.

This is a very weird bug. NSExpression(format:arguments:) would cause any type information to be erased when passing in the stop Dictionary, so it should be no different than passing in an NSDictionary. I think this issue would be worth reporting to Apple if we can isolate it to something in the toolchain, but first we’d need to rule out a bug in the map SDK’s -[NSExpression(MGLAdditions) mgl_jsonInterpolationExpressionObject], specifically around here:

https://github.com/mapbox/mapbox-gl-native-ios/blob/6d7054f26d8f1ddd8a6b51e1f06b8a2745b74fe1/platform/darwin/src/NSExpression%2BMGLAdditions.mm#L1368-L1371

/cc @mapbox/maps-ios

@1ec5
Copy link
Contributor

1ec5 commented Aug 24, 2020

Fixed in #2500, which was merged to the release-v1.0-pre-registry branch and subsequently merged to master.

@1ec5 1ec5 closed this as completed Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn’t working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants