Commit c44e7e7
authored
fix:
## 📜 Description
Wrapped touch events in `try`/`catch`.
## 💡 Motivation and Context
The problem stems from the fact, that we are trying to cast
`ViewRootImpl` to `ViewGroup` (viewrootimpl cannot be cast to
android.view.viewgroup). Basically it happens when touch gets propagated
until `RootView` and wasn't handled earlier. Such thing can happen when:
- view is not fully laid out but it already handles a touch;
- view is not stretched to full screen and you touch area that doesn't
belong to `OverKeyboardView` (fixed in
#863)
I was aware about that issue (especially on Fabric) and decided not to
fix it - the main motivation was to stretch view to full screen on
Fabric. However now, when view gets stretched we still have a small race
condition when users click fast (i. e. view is not laid out but user
already pass a touch).
I don't know a proper fix for this problem, and for me it looks like it
can be OS scheduling/management which can not be fixed because I don't
have an access to it 😅
So in this PR I simply wrap the touch handling in `try`/`catch`. If
touch can not be handled then it's better to silently fail instead of
crashing the app.
Closes
#884
## 📢 Changelog
<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->
### Android
- wrapped `handleTouchEvent` calls inside `try`/`catch` block to prevent
a crash;
## 🤔 How Has This Been Tested?
Tested manually on Medium Phone API 35.
## 📸 Screenshots (if appropriate):
https://github.com/user-attachments/assets/9ffa684d-ddb7-46e5-b143-d526ab680d28
## 📝 Checklist
- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changedOverKeyboardView crash (#913)1 parent 581e377 commit c44e7e7
1 file changed
Lines changed: 19 additions & 4 deletions
File tree
- android/src/main/java/com/reactnativekeyboardcontroller/views/overlay
Lines changed: 19 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
21 | 24 | | |
22 | 25 | | |
23 | 26 | | |
| |||
140 | 143 | | |
141 | 144 | | |
142 | 145 | | |
143 | | - | |
144 | | - | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
145 | 154 | | |
146 | 155 | | |
147 | 156 | | |
148 | 157 | | |
149 | 158 | | |
150 | 159 | | |
151 | 160 | | |
152 | | - | |
153 | | - | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
154 | 169 | | |
155 | 170 | | |
156 | 171 | | |
| |||
0 commit comments