Commit e67d556
Fix HeadlessJsTaskContext creating Handler on background thread (#44582)
Summary:
Pull Request resolved: #44582
D54496604 fixed lifecycle methods for JavaTimerManager, which now reveals another bug. Because this codepath ends up creating a `HeadlessJsTaskContext` which in turn creates a `Handler`, ReactInstance destruction doesn't complete cleanly.
```
2024-05-15 17:42:52.935 12681 27113 W fb4a.BridgelessReact: ReactHost{1}.getOrCreateDestroyTask(): React destruction failed. ReactInstance task faulted. Fault reason: Can't create handler inside thread Thread[pool-51-thread-1,5,main] that has not called Looper.prepare(). Destroy reason: FbReactInstanceHolder.destroyReactManager(): FbReactInstanceLogoutCleaner.clearReactInstanceData()
```
The fix is to not create our own Handler, but instead use the shared methods in UiThreadUtil.
Changelog: [Android][Fixed] Fixed error thrown during ReactInstance teardown
Reviewed By: cortinico
Differential Revision: D57378247
fbshipit-source-id: a31dc8e35b5418a71b83c301973f12350f2ee01b1 parent fd8eb48 commit e67d556
1 file changed
Lines changed: 5 additions & 13 deletions
File tree
- packages/react-native/ReactAndroid/src/main/java/com/facebook/react/jstasks
Lines changed: 5 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | 10 | | |
12 | 11 | | |
13 | 12 | | |
| |||
52 | 51 | | |
53 | 52 | | |
54 | 53 | | |
55 | | - | |
56 | 54 | | |
57 | 55 | | |
58 | 56 | | |
| |||
194 | 192 | | |
195 | 193 | | |
196 | 194 | | |
197 | | - | |
198 | | - | |
199 | | - | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
200 | 198 | | |
201 | 199 | | |
202 | 200 | | |
| |||
210 | 208 | | |
211 | 209 | | |
212 | 210 | | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
| 211 | + | |
220 | 212 | | |
221 | | - | |
| 213 | + | |
222 | 214 | | |
223 | 215 | | |
0 commit comments