Mid-frame view flushing can deadlock when the render thread synchronously waits for JavaScript
Maintainers usually reply within 1 day
@bkaradzic-microsoft is already working on this.
Since Sep 30, 2026.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- cpp, javascript
- Domain
- computer-graphics
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- The render thread dispatches rendering work to the JS thread and synchronously waits for it to complete, intending to finish the native frame afterward.
- With a frame-completion scope active, JS submits enough render-target passes to reach the mid-frame view-flush threshold (
maxViews - 16). FlushViewsIfNeeded()setsm_flushRequestedand waits onm_flushCompleteCV.- 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.
- Dominant language
- C++
- Stars
- 931
- Forks
- 169
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 66
Getting set up
- No Dockerfile or Docker Compose file
- No 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/BabylonNative
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
BabylonJS/BabylonNative#2138 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
BabylonJS/BabylonNative#2042 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
BabylonJS/BabylonNative#2052 ·
Maintainers usually reply within 1 day
-
testing
Difficulty 4/5 3-5 days Newbie friendliness 45/100
BabylonJS/BabylonNative#2136 ·
Maintainers usually reply within 1 day
-
Support useNDCHalfZRange (half-range NDC depth) so Babylon.js half-range depth visual tests can runOpen
Difficulty 4/5 3-5 days Newbie friendliness 48/100
BabylonJS/BabylonNative#2134 ·
Maintainers usually reply within 1 day
All issues in BabylonJS/BabylonNative
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