JS thread deadlocks in NativeEngine::SubmitCommands when an engine is disposed and a new one created quickly
@CedricGuillemet is already working on this.
Since Dec 2, 2026.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 47/100
Research direction
Start in NativeEngine.cpp at SubmitCommands (around line 4005), then trace DeviceContext.cpp's AcquireFrameCompletionScope and the ReactNativeEngine.dispose/reset path described in the report. Reproduce by rapidly unmounting and remounting EngineView after its first frame, and inspect how asynchronous resetView interacts with rendering. Done means the new engine renders reliably after repeated quick remounts.
Written by the indexing model from the issue text.
Description
Environment: @babylonjs/react-native 2.0.7 (Babylon Native f4d9efb), React Native 0.81.6 (legacy architecture), Hermes, Xcode 27.1, iOS 27.0 Simulator (iPhone 17), macOS 27.0.1.
Steps
- A component calls
useEngine()and renders<EngineView camera={…} />with a non-trivial scene (shadows, glow,
GUI). - Unmount it and mount a fresh instance (new
useEngine(), newEngineView) several times in quick succession.
Re-mounting within about 1 s of the previous scene's first frame is enough.
Expected: the new engine renders.
Actual: the app freezes at 0% CPU. No crash report is written. The JS thread blocks forever:
Babylon::NativeEngine::SubmitCommands(Napi::CallbackInfo const&) NativeEngine.cpp:4005
Babylon::Graphics::DeviceContext::AcquireFrameCompletionScope() DeviceContext.cpp:67
Babylon::Graphics::FrameCompletionScope::FrameCompletionScope(DeviceImpl&) DeviceContext.cpp:47
Babylon::Graphics::DeviceImpl::IncrementPendingFrameScopes() DeviceImpl.cpp:525
std::condition_variable::wait(std::unique_lock<std::mutex>&)
This reproduces in both Debug and Release. Likely cause: ReactNativeEngine.dispose() → reset() →
BabylonModule.resetView() runs asynchronously, so it can land after the new view has re-enabled rendering. The new
engine then submits into a device that never starts another frame.
Workaround: keep one engine and one EngineView for the app lifetime and dispose only scenes. An extra scene with
autoClear = false keeps frames flowing when no "real" scene is shown.
- Dominant language
- C++
- Stars
- 437
- Forks
- 72
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from BabylonJS/BabylonReactNative
-
Docs: New Architecture is not supported; GUI text needs a fontPossibly taken @CedricGuillemet claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BabylonJS/BabylonReactNative#777 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 54/100
BabylonJS/BabylonReactNative#776 ·
-
Playground Metro fails to start: exclusionList is not a functionPossibly taken @CedricGuillemet claimed this today. Open
Difficulty 3/5 1-2 days Newbie friendliness 58/100
BabylonJS/BabylonReactNative#775 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 48/100
BabylonJS/BabylonReactNative#774 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 25/100
BabylonJS/BabylonReactNative#667 ·
All issues in BabylonJS/BabylonReactNative
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
gofractally/psibase#2379 ·
Maintainers usually reply within 3 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
simnJS/AnyPS5#735 · 1 comment ·
Maintainers usually reply within 1 day
-
needs-format
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Niko1221/Strata#7719 · 1 comment ·
Maintainers usually reply within 4 days