JS thread deadlocks in NativeEngine::SubmitCommands when an engine is disposed and a new one created quickly

オープン
#773 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@CedricGuillemet がすでに取り組んでいます。

2026年12月2日 から。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
47/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, react-native
領域
backend, mobile

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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

  1. A component calls useEngine() and renders <EngineView camera={…} /> with a non-trivial scene (shadows, glow,
    GUI).
  2. Unmount it and mount a fresh instance (new useEngine(), new EngineView) 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.

主要言語
C++
スター
437
フォーク
72
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

BabylonJS/BabylonReactNative のほかの issue

BabylonJS/BabylonReactNative の issue をすべて見る

似ている issue

C++ の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。