Files
skylar taylor-barrick e3e76fd0f0 Wait for the GPU warm-up before a test or headless process ends (#620) (#4697)
* LR-BEHAV-GPU: no GPU warm-up is still loading the driver when a test or headless process ends (issue #620)

The first frame starts the GPU device warm-up on a thread of its own. A process
that ended a few milliseconds later, as every test does under nextest, could
exit while that thread was inside the Vulkan loader's dlopen of the driver,
running libLLVM's initializers: a SIGSEGV after the test had passed, or a hang.
Only the window's exit (LightcraftApp::shutdown) waited for GPU work.

warm_up now counts as in flight from the moment it is called, before its thread
exists, and wait_warm_up waits for it. Dropping a LightcraftApp waits for it,
bounded, unless shutdown already ran.

* LR-BEHAV-GPU: warm_up counts as in flight before it marks itself started (issue #620)

A second warm_up call racing the first could find it marked started and return
before the first had entered the gate, so a host dropping its app right after
that second call saw no warm-up in flight. The gate is now entered first, a
call that starts nothing drops its entry, and a closed gate starts nothing.

* LR-BEHAV-GPU: the app waits for the GPU warm-up when dropped on native builds only (issue #620)

The web build has no warm-up thread (warm_up and wait_warm_up do nothing there),
and the web host replaces the app's UI state by moving it out of the app, which
a Drop impl forbids (E0509 in the wasm check).

* LR-BEHAV-GPU: a deterministic test for the app's warm-up wait on drop (issue #620)

Fred's review of #4697: the first regression test could pass without
exercising the wait — ready() || !enabled() also holds when the warm-up
finished or never started, and no pending warm-up was ever established.

The gpu crate exposes doc-hidden test support, hold_warm_up_for_test(),
entering the same gate the real warm_up enters: a substitute warm-up the
caller holds. The test proves it is in flight (wait_warm_up(ZERO) is
false), builds an app that never ran a frame on another thread (the app
is not Send — its host-service callbacks are not — so it is built there),
and verifies with channel synchronization that dropping the app does not
return while the hold is kept, and returns once it is released. Without
the wait in Drop for LightcraftApp it fails at that assertion; with it,
it passes. No GPU, no device, no timing beyond a one-second observation
window whose proof is the release.

---------

Co-authored-by: skylartaylor <skylartaylor@users.noreply.github.com>
2026-12-02 08:34:26 -06:00
..
2026-10-31 02:31:16 +00:00
2026-12-02 10:10:59 +01:00