Skip to content

fix(dom,net): resolve Windows local asset deadlock and guarantee ResourceHandler drop safety - #959

Open
GoCoder7 wants to merge 1 commit into
DioxusLabs:mainfrom
techton7:fix/win-asset-deadlock
Open

GoCoder7 wants to merge 1 commit into
DioxusLabs:mainfrom
techton7:fix/win-asset-deadlock

Conversation

@GoCoder7

Copy link
Copy Markdown

Closes #958

Hi everyone,

1. Summary of Changes

This pull request resolves a render-blocking deadlock on Windows where loading local stylesheets or assets via compile-time absolute paths (e.g. asset!("browser.css")) leaves the application window permanently solid white (#FFFFFF).

Root Causes Addressed:

  1. Windows Drive Paths Parsed as URL Schemes: BaseDocument::resolve_url previously passed Windows absolute paths (e.g. D:\...\browser.css) directly to url::Url::parse(), which interpreted the drive letter as a scheme (url.scheme() == "d").
  2. Silently Dropped Resource Handlers: When blitz-net failed on scheme "d", it dropped the ResourceHandler without sending a response. Because ResourceHandler lacked a Drop implementation, pending_critical_resources.remove(...) was never called, permanently blocking layout and paint passes (render_skipped=true).
  3. Improper File URL Extraction: blitz-net used request.url.path() instead of to_file_path() for file:// URLs, which fails on Windows absolute drive letters.

2. Exact Scope & Seams Touched

Crate File Changes Description
blitz-dom packages/blitz-dom/src/document.rs +19 / 0 Detect Windows absolute paths in resolve_url and convert to valid file:/// URLs via Url::from_file_path.
blitz-dom packages/blitz-dom/src/net.rs +62 / -2 Implement Drop for ResourceHandler<T> with an AtomicBool guard to guarantee that dropped handlers emit an error ResourceLoadResponse and request a redraw, ensuring pending_critical_resources always clears. Added unit tests.
blitz-net packages/blitz-net/src/lib.rs +6 / -1 Use request.url.to_file_path() instead of request.url.path() for file:// requests on Windows.

3. Direct Empirical Proof (Two-Case Comparison)

To confirm that this deadlock is an independent root cause in Blitz, a controlled dual-run verification was executed on Windows hardware with the GPU backend held strictly constant (DirectX 12 enabled via upstream AnyRender PR #100):

Observation / Metric Case A: Original Blitz + DX12 Backend Case B: Fixed Blitz + DX12 Backend
resolved_url in <head> 'd:\business\...' (Scheme "d") 'file:///D:/business/...' (Scheme "file")
pending_critical_resources Stuck at 2 forever Cleared from 2 -> 0
load_resource invocations 0 (handler dropped silently) 2 (both stylesheets completed)
DOM resolve() early_return=true (aborted) Proceeded to normal layout
blitz-shell::redraw render_skipped=true (aborted) render_skipped=false (rendered)
Visual Window Output Solid White (#FFFFFF) Full Browser UI Rendered Crisply

This confirms that even with a fully working DX12 graphics backend, original Blitz alone is 100% sufficient to cause a permanent blank white window on Windows.


4. Separation from Upstream AnyRender

This PR is strictly confined to the Blitz repository's asset and document lifecycle:

  • The GPU swapchain presentation fix lives upstream in dioxuslabs/anyrender (Issue #99, PR #100).
  • This PR contains zero graphics backend or wgpu instance selection logic, ensuring a clean, orthogonal review.

5. Validation Summary

  1. Unit Tests Added:
    • dropped_handler_emits_error_response: Verifies that dropping an unfulfilled ResourceHandler automatically emits an error DocumentEvent::ResourceLoad.
    • responded_handler_does_not_emit_on_drop: Verifies that a handler that has already responded does not emit a duplicate response on drop.
    • Run via cargo test -p blitz-dom --lib net::tests (Passed cleanly).
  2. End-to-End Browser Run:
    • cargo run -rp browser launches on Windows and displays the new tab page, address bar, Blitz logo SVG, and search input box without freezing.

Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix render-blocking asset deadlock on Windows local resource loading

1 participant