Mid-frame view flushing can deadlock when the render thread synchronously waits for JavaScript

Aperta
#1,904 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@bkaradzic-microsoft ci sta già lavorando.

Dal 30/9/2026.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
cpp, javascript

Direzione di ricerca

Start in Core/Graphics/Source/DeviceImpl.cpp at upstream commit 3450373508, tracing FlushViewsIfNeeded(), PerformMidFrameViewFlush(), and FinishRenderingCurrentFrame(). Exercise the triggering sequence around the maxViews - 16 threshold and confirm the circular wait or establish the required host-side frame-pumping contract. Done means the flush no longer hangs, or unsupported synchronous dispatch fails explicitly and its contract is documented and enforced.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Summary

DeviceImpl::FlushViewsIfNeeded() can wait indefinitely when an embedding application synchronously waits for JavaScript rendering to finish before calling FinishRenderingCurrentFrame().

The current guard checks that at least one frame-completion scope is active, but an active scope does not establish that the render thread is available to service a mid-frame flush.

Triggering sequence
  1. The render thread dispatches rendering work to the JS thread and synchronously waits for it to complete, intending to finish the native frame afterward.
  2. With a frame-completion scope active, JS submits enough render-target passes to reach the mid-frame view-flush threshold (maxViews - 16).
  3. FlushViewsIfNeeded() sets m_flushRequested and waits on m_flushCompleteCV.
  4. The render thread cannot reach FinishRenderingCurrentFrame() to service that request until JS returns. JS cannot return until the flush completes.

This creates a circular wait:

Render thread: waiting for JS rendering to complete
JS thread:     waiting for render thread to service a view flush
Expected behavior

The flush should complete, or an unsupported frame-driving pattern should fail explicitly rather than hang. If synchronous dispatch is unsupported, the required host-side frame-pumping contract should be documented and enforced.

Evidence and scope

A repeatable rendering stall was observed when the workload crossed the flush threshold. The circular-wait explanation is based on source inspection; a debugger-confirmed pair of blocked thread stacks and a standalone public reproducer are not yet available.

The relevant implementation is DeviceImpl.cpp at upstream commit 3450373508, particularly FlushViewsIfNeeded(), PerformMidFrameViewFlush(), and FinishRenderingCurrentFrame().

Increasing the view capacity avoids this path for workloads that remain below the new threshold, but does not fix the underlying synchronization dependency.

Lingua principale
C++
Stelle
931
Fork
169
Merge medio
2g 17h
PR unite (30g)
66

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di BabylonJS/BabylonNative

Tutte le issue di BabylonJS/BabylonNative

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.