Skip to content

Commit

Permalink
fix: handle progress being infinite (#740)
Browse files Browse the repository at this point in the history
## 📜 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
  • Loading branch information
matthieuMay authored Dec 19, 2024
1 parent 7aec4ed commit fdba1d2
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ class KeyboardAnimationCallback(

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

0 comments on commit fdba1d2

Please sign in to comment.