Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Fixed a crash on iOS 16.5 when native alert is getting shown.
💡 Motivation and Context
The original exception occurred because of this error:
progress
wasinf
because in:keyboardHeight
variable was0
. When we were trying to divide any number by0
in swfit we getInf
value, and this value can not be serialised to JS equivalent.The reason why this value becomes
0
is the fact that we have next chain of calls:Based on output from above I had 3 options on how to fix the error:
1. Add
.isFinite
checkGood option, but it will prevent sending
onMove
event, though according to values fromCADisplayLink
movement actually happens. So we will kind of ignore actual information and it's not something that satisfy me, because it may produce other bugs in the future.2. Update
keyboardHeight
inkeyboardWillHide
This variant also prevents a crash, but
progress
value inonMove
sometimes can be higher than1
(in my tests sometimes it was 1.3+). And it also seems like it gives incorrect calculation, because it's strange to see progress > 1, when keyboard simply hides 🤷♂️3. Don't set
keyboardHeight
to0
To come back to
1.4.x
behaviour, we don't need to resetkeyboardHeight
to0
. But I've added this code intentionally in1.5.0
, because in KV observer we are checking that keyboard should be open and not animating:I've added this check, because I've attached KV observer before any keyboard movement. The reason why I've added it in
UIWindow.didBecomeVisibleNotification
/UIWindow.didBecomeHiddenNotification
was the fact, that these methods were called only one time (keyboard events can be fired multiple times). But I've addedhasKVObserver
variable in #146 so it's safe to callsetupKVObserver
/removeKVObserver
multiple times.So in this PR I've decided to stick to this approach - don't reset
keyboardHeight
to0
+ setup KV listeners in different lifecycle methods.Should close #175
📢 Changelog
iOS
setupKVObserver
/removeKVObserver
tokeyboaardDidAppear
/keyboardWilHide
lifecycle;keyboardHeight
to0
(this value acts aspersisteKeyboardHeight
on Android);🤔 How Has This Been Tested?
Tested on:
📸 Screenshots (if appropriate):
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-06-19.at.14.55.33.mp4
Simulator.Screen.Recording.-.iPhone.14.Pro.-.2023-06-19.at.14.45.26.mp4
📝 Checklist