Skip to content

Commit fdba1d2

Browse files
authored
fix: handle progress being infinite (#740)
## 📜 Description Add a numerical safety test to keyboard animation progress ## 💡 Motivation and Context It solves a random crash in production where progress is infinite Fixes #739 #737 #735 ## 📢 Changelog ### Android - added `isInfinite` check along with `isNaN`; ## 🤔 How Has This Been Tested? Releasing it to production via a patch package the error report disappeared ## 📝 Checklist - [x] CI successfully passed - [x] I added new mocks and corresponding unit-tests if library API was changed
1 parent 7aec4ed commit fdba1d2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class KeyboardAnimationCallback(
251251

252252
var progress = 0.0
253253
try {
254-
progress = abs((height / persistentKeyboardHeight)).let { if (it.isNaN()) 0.0 else it }
254+
progress = abs((height / persistentKeyboardHeight)).let { if (it.isNaN() || it.isInfinite()) 0.0 else it }
255255
} catch (e: ArithmeticException) {
256256
// do nothing, just log an exception send progress as 0
257257
Logger.w(TAG, "Caught arithmetic exception during `progress` calculation: $e")

0 commit comments

Comments
 (0)