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

Lane.init(json:) crash #290

Closed
bsudekum opened this issue Sep 5, 2018 · 5 comments
Closed

Lane.init(json:) crash #290

bsudekum opened this issue Sep 5, 2018 · 5 comments

Comments

@bsudekum
Copy link

bsudekum commented Sep 5, 2018

#0. Crashed: com.apple.main-thread
0  MapboxDirections               0x101575da0 specialized Lane.init(json:) (MBLane.swift:23)
1  MapboxDirections               0x1015744c8 specialized Intersection.init(json:) (MBIntersection.swift:85)
2  MapboxDirections               0x101591004 closure #1 in RouteStep.init(finalHeading:maneuverType:maneuverDirection:drivingSide:maneuverLocation:name:coordinates:json:) + 4339650564
3  MapboxDirections               0x10159b340 specialized RouteStep.init(finalHeading:maneuverType:maneuverDirection:drivingSide:maneuverLocation:name:coordinates:json:) (MBRouteStep.swift:596)
4  MapboxDirections               0x1015926e8 RouteStep.init(json:options:) (MBRouteStep.swift:636)
5  MapboxDirections               0x101585c64 RouteLeg.init(json:source:destination:options:) (MBRouteLeg.swift:62)
6  MapboxDirections               0x101583684 partial apply for closure #1 in Route.init(json:waypoints:options:) (MBRoute.swift)
7  MapboxDirections               0x101583a38 specialized Sequence.map<A>(_:) (MBRoute.swift:30)
8  MapboxDirections               0x1015814c4 Route.init(json:waypoints:options:) (MBRoute.swift:30)
9  MapboxDirections               0x10158db28 specialized RouteOptions.response(from:) (MBRouteOptions.swift:169)
10 MapboxDirections               0x10158a55c RouteOptions.response(from:) (MBRouteOptions.swift)
11 MapboxDirections               0x10155f204 specialized closure #1 in Directions.calculate(_:completionHandler:) (MBDirections.swift:178)
12 MapboxDirections               0x101561690 partial apply for closure #1 in Directions.calculate(_:completionHandler:) + 4339455632
13 MapboxDirections               0x101566334 partial apply for closure #2 in closure #1 in Directions.dataTask(with:data:completionHandler:errorHandler:) (MBDirections.swift:285)
14 MapboxDirections               0x10155aebc _T0Ieg_IeyB_TR (MBDirections.swift)
15 libdispatch.dylib              0x180f90aa0 _dispatch_call_block_and_release + 24
16 libdispatch.dylib              0x180f90a60 _dispatch_client_callout + 16
17 libdispatch.dylib              0x180fd1d80 _dispatch_main_queue_callback_4CF$VARIANT$armv81 + 964
18 CoreFoundation                 0x181647070 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
19 CoreFoundation                 0x181644bc8 __CFRunLoopRun + 2272
20 CoreFoundation                 0x181564da8 CFRunLoopRunSpecific + 552
21 GraphicsServices               0x183549020 GSEventRunModal + 100
22 UIKit                          0x18b581758 UIApplicationMain + 236
23 Redact                           0x100f05b70 main (RedactedView.swift:16)
24 libdyld.dylib                  0x180ff5fc0 start + 4

/cc @1ec5 @frederoni

@frederoni
Copy link
Contributor

Do you know approximately which two waypoints you used to request this route?

@bsudekum
Copy link
Author

bsudekum commented Sep 5, 2018

@frederoni Negative

@frederoni
Copy link
Contributor

No success in trying to reproduce this. I've tried requesting a route from SF → NY → Seattle → Miami → San Diego. However, there seems to be a data issue where the modifier is not equal to any of
[uturn, sharp right, right, slight right, straight, slight left, left, sharp left] and we forcefully unwrap the LaneIndication.

@1ec5, any ideas?

@1ec5
Copy link
Contributor

1ec5 commented Sep 6, 2018

SF → NY → Seattle → Miami → San Diego

This route would largely travel over freeways, which rarely have turn lanes tagged in OpenStreetMap. I suppose you could request a route that avoids freeways (motorways) to have a better chance of reproducing this crash.

not equal to any of
[uturn, sharp right, right, slight right, straight, slight left, left, sharp left]

none also results in a non-nil (if empty) LaneIndication option set, by the way:

https://github.com/mapbox/MapboxDirections.swift/blob/5d0ed2dc8d5c9cbff446c9aa12919a92c4dda494/MapboxDirections/MBLaneIndication.swift#L29-L30

The Directions API documentation no longer specifies which indications values we can expect, but OSRM can produce any of these lane indications. The two values we don’t handle (which were never documented in the past) are merge to left and merge to right, corresponding to the merge_to_left and merge_to_right values in OpenStreetMap, respectively. OSRM does have some special cases around merge lanes, but I’ve never seen an example of the Directions API including such lanes in a response.

This way leads to an intersection with merge_to_left on the rightmost lane. (I found it using this query that excludes none indications, which tend to cause the Directions API to omit lane indications entirely for the intersection in question.) This route reveals no problems, and the route JSON doesn’t seem to include any lane data – OSRM probably omitted it due to an unexpected merge_to_left lane where OSRM wanted to make a right turn. (This is a relatively rare counterpoint to Project-OSRM/osrm-backend#4965, by the way.)

I’m not sure we can do anything more for this crash, other than a speculative fix that makes this initializer failable:

https://github.com/mapbox/MapboxDirections.swift/blob/5d0ed2dc8d5c9cbff446c9aa12919a92c4dda494/MapboxDirections/MBLane.swift#L20-L21

/cc @danpat

@1ec5
Copy link
Contributor

1ec5 commented Jan 7, 2020

The Directions API is now dropping the merge_to_left lane indication, so the crash should no longer occur. As of #382, an unrecognized lane indication would throw an error during decoding, but the application could catch the error instead of crashing.

@1ec5 1ec5 closed this as completed Jan 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants