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

Don't force unwrap userInfo keys #1599

Merged
merged 4 commits into from Aug 10, 2018
Merged

Don't force unwrap userInfo keys #1599

merged 4 commits into from Aug 10, 2018

Conversation

bsudekum
Copy link
Contributor

@bsudekum bsudekum commented Aug 9, 2018

Seeing a few rare crashes around this code. To be safe, we should not force unwrap these userInfo key/values.

/cc @mapbox/navigation-ios

Copy link
Contributor

@1ec5 1ec5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These changes seem quite speculative to me. Have we seen crashes that we’re sure are caused by these keys being of the wrong type (which would be a UIKit bug) or missing (which might also be a UIKit bug)?

@bsudekum
Copy link
Contributor Author

bsudekum commented Aug 9, 2018

@1ec5 it may not be a missing key but also we could be crashing due to a bad force cast.

@1ec5
Copy link
Contributor

1ec5 commented Aug 10, 2018

#0. Crashed: com.apple.main-thread
0  libswiftCore.dylib             0x1011c0abc _stdlib_destroyTLS + 247776
1  libswiftCore.dylib             0x10101ff74 (Missing)
2  MapboxNavigation               0x100747610 $S16MapboxNavigation22RouteMapViewControllerC16keyboardWillShow33_AB58FB88B49AF290C13A69A1EE3638C1LL12notificationySo14NSNotificationC_tF (RouteMapViewController.swift:959)
3  MapboxNavigation               0x100748048 $S16MapboxNavigation22RouteMapViewControllerC16keyboardWillShow33_AB58FB88B49AF290C13A69A1EE3638C1LL12notificationySo14NSNotificationC_tFToTm + 4310974536

@1ec5 1ec5 mentioned this pull request Aug 10, 2018
@@ -984,10 +984,12 @@ extension RouteMapViewController {
@objc fileprivate func keyboardWillShow(notification: NSNotification) {
guard navigationView.endOfRouteView != nil else { return }
guard let userInfo = notification.userInfo else { return }
let curve = UIViewAnimationCurve(rawValue: userInfo[UIKeyboardAnimationCurveUserInfoKey] as! Int)
let options = (duration: userInfo[UIKeyboardAnimationDurationUserInfoKey] as! Double,
curve: curve!)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ! is the problem, per #1600 (comment). Let’s whittle this PR down to just handling the case where curve is nil.

@1ec5 1ec5 added the - crash label Aug 10, 2018
@bsudekum
Copy link
Contributor Author

@1ec5 reworked this to use a default animation if the curve init function fails. Tested with 7, so it fails and falls back to easeIn, looks good.

@bsudekum bsudekum merged commit 7de2c53 into master Aug 10, 2018
@bsudekum bsudekum deleted the fix-keyboard branch August 10, 2018 20:00
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

Successfully merging this pull request may close these issues.

None yet

2 participants