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
Conversation
There was a problem hiding this 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)?
@1ec5 it may not be a missing key but also we could be crashing due to a bad force cast. |
|
@@ -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!) |
There was a problem hiding this comment.
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 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. |
Seeing a few rare crashes around this code. To be safe, we should not force unwrap these userInfo key/values.
/cc @mapbox/navigation-ios