Repository navigation
Require prepared resources for child frame rendering - #495
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (13)
✨ Finishing Touches📝 Generate docstrings
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🔵 Needs a closer look
It reworks error-recovery control flow across many files in the GPU render-thread hot path, and its correctness depends on runtime/GPU behavior that cannot be fully verified here.
0 open findings
What changed in this PR
This PR hardens the wgpu child-frame rendering path. Previously, render_child_frame_prepared accepted optional composition scratch leases and panicked (via .expect) if a translucent or resizing child reached the draw without its required leases. The PR replaces that with a PreparedChildFrame proof type whose private fields force construction through a validating new constructor that checks lease presence, scratch dimensions, and resize-attachment aliasing. Preparation failures now propagate as FrameRenderFailure through the full and retained render paths so the runtime restores renderer scale/size, keeps the frame dirty, and retries without presenting—replacing a hard panic with graceful recovery. This fits into the render-thread's existing FrameRenderFailure retry model and adds no new dependencies.
Changes:
- Introduce
PreparedChildFrame(validated, consumed by draw) andChildPreparationError; drop the preflighted-scratch field fromChildResizePicture. - Thread
Result<(), FrameRenderFailure>throughscene→chrome→full_render/retained_static→render_pass/mod, restoring renderer state and marking dirty on failure. - Move root font-binding restoration so it runs even when a later child fails preparation; add regression tests for missing/wrong-size/aliased scratch and retry-recovery.
| File | Description |
|---|---|
renderer/child_frames.rs |
Adds PreparedChildFrame/ChildComposition/ChildPreparationError, the validating new, and refactors render_child_frame_prepared to consume the prepared value. |
renderer/mod.rs |
Exports the new ChildPreparationError and PreparedChildFrame types. |
render_pass/scene.rs |
Builds the prepared child, propagates preparation failure as WindowNotReady, and relocates root font restoration ahead of the error return. |
render_pass/chrome/mod.rs, full_render.rs, retained_static.rs, mod.rs |
Return/propagate FrameRenderFailure; restore scale/size and mark dirty on failure. |
renderer/.../child_frames_test.rs, tests/offscreen_frame/opacity_test.rs |
Unit coverage for opaque/fractional/wrong-size/aliased preparation outcomes. |
render_pass/scene/tests.rs + boundary/owner test files |
Update call sites to .unwrap() the new Result; add missing-scratch retry/recovery regression. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Child rendering currently accepts optional composition scratch and panics if a translucent or resizing child reaches the draw without the required leases. Require a
PreparedChildFrameinstead: its private constructor checks required leases, scratch dimensions, and resize aliases while borrowing the child payload and resources. Rendering consumes the prepared value.Propagate preparation failures through full and retained render paths so the runtime restores renderer state, keeps the frame dirty, and retries without presentation. Restore root font bindings even when a later child fails preparation. This uses ordinary Rust types and adds no dependencies.
Validation:
tmp/imgmsg/fixturesfiles are absent from this checkout.git diff --checkpassed.