Problem
Enabling the compiled CSS cache in the Code OSS host exposes a startup-order race in webscene_engine. The constructor starts worker_ in its member initializer list, then configures the process CSS compilation-cache directory in the constructor body. The worker can begin loading and parsing the document before constructor setup is complete.
On the macOS 12 deployment-target build used by AppScene, the packaged VS Code OSS workbench remains in continuous visible rendering after startup:
- visible idle presentations: 119.010/sec
- visible idle CPU: 1.089%
- scene generation and publication continue at display refresh rate
The prior runtime and a build where the worker starts after cache setup both settle:
- visible idle presentations: 0/sec
- hidden idle presentations: 0/sec
- visible idle CPU: 0.042%
A macOS 26-target rebuild happened to mask the race, so deployment target and compiler timing affect reproduction.
Root cause
worker_ begins during member initialization. Process-wide CSS cache setup happens later in the constructor body, despite the class invariant that the worker should only observe fully configured state. Bypassing CSS event-cache replay still reproduces 119.048 presentations/sec, ruling out replay semantics.
Proposed fix
Default-construct the final std::jthread member. In the constructor body:
- Configure the CSS compilation-cache directory.
- Mark constructor setup complete.
- Assign/start
worker_.
Add a worker-entry invariant guard so future ordering regressions fail closed.
Regression coverage
- Repeatedly construct configured engines with a nonempty cache directory and execute a worker task.
- Assert the worker never observes partially configured engine state.
- Keep the packaged performance gates:
idle.visiblePresentationsPerSecond <= 5
idle.hiddenPresentationsPerSecond <= 2
- Validate with
CMAKE_OSX_DEPLOYMENT_TARGET=12.0, where the race reproduces reliably.
Acceptance
- Native lifecycle regression passes.
- Existing native runtime, CSS parser/cache, WPT, and package gates pass.
- Code OSS reaches 0 idle visible/hidden presentations per second after warmup.
- No change to CSS cache contents or public ABI.
Problem
Enabling the compiled CSS cache in the Code OSS host exposes a startup-order race in
webscene_engine. The constructor startsworker_in its member initializer list, then configures the process CSS compilation-cache directory in the constructor body. The worker can begin loading and parsing the document before constructor setup is complete.On the macOS 12 deployment-target build used by AppScene, the packaged VS Code OSS workbench remains in continuous visible rendering after startup:
The prior runtime and a build where the worker starts after cache setup both settle:
A macOS 26-target rebuild happened to mask the race, so deployment target and compiler timing affect reproduction.
Root cause
worker_begins during member initialization. Process-wide CSS cache setup happens later in the constructor body, despite the class invariant that the worker should only observe fully configured state. Bypassing CSS event-cache replay still reproduces 119.048 presentations/sec, ruling out replay semantics.Proposed fix
Default-construct the final
std::jthreadmember. In the constructor body:worker_.Add a worker-entry invariant guard so future ordering regressions fail closed.
Regression coverage
idle.visiblePresentationsPerSecond <= 5idle.hiddenPresentationsPerSecond <= 2CMAKE_OSX_DEPLOYMENT_TARGET=12.0, where the race reproduces reliably.Acceptance