react-native icon indicating copy to clipboard operation
react-native copied to clipboard

Fix HeadlessJsTaskContext creating Handler on background thread

Open javache opened this issue 9 months ago • 3 comments

Summary: 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.

Differential Revision: D57378247

javache avatar May 15 '24 12:05 javache

This pull request was exported from Phabricator. Differential Revision: D57378247

facebook-github-bot avatar May 15 '24 12:05 facebook-github-bot

This pull request was exported from Phabricator. Differential Revision: D57378247

facebook-github-bot avatar May 15 '24 12:05 facebook-github-bot

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 19,526,129 -17
android hermes armeabi-v7a n/a --
android hermes x86 n/a --
android hermes x86_64 n/a --
android jsc arm64-v8a 22,896,050 +2
android jsc armeabi-v7a n/a --
android jsc x86 n/a --
android jsc x86_64 n/a --

Base commit: 524e3eec3e73f56746ace8bef569f36802a7a62e Branch: main

analysis-bot avatar May 15 '24 12:05 analysis-bot

This pull request has been merged in facebook/react-native@e67d5560cfd35f07ce74cfcc12555346a6f0e865.

facebook-github-bot avatar May 21 '24 13:05 facebook-github-bot

This pull request was successfully merged by @javache in e67d5560cfd35f07ce74cfcc12555346a6f0e865.

When will my fix make it into a release? | How to file a pick request?

github-actions[bot] avatar May 21 '24 13:05 github-actions[bot]