Skip to content

Intercept parser and nested-frame resources through Service Workers #312

Closed
1 of 1 issue completed

Description

@wieslawsoltes

Parent: #308
Resource-plane epic: #266
Depends on: #310
Related CSS URL interception: #286 (separate)

Proven boundary

#310 routes resources connected by DOM mutation after the controlling Service Worker exists. Initial navigation parsing still loads parser-created external scripts and styles through the host loader, and a hydrated nested document loads its own parser resources without consulting the controller associated with that document/client generation. Unchanged VS Code creates the webview document and its extension prelude through these paths, so the resource plane remains incomplete even when dynamic element interception passes.

Scope

  • Route initial parser-blocking classic scripts and external stylesheets through the document's active controlling Service Worker before host fallback.
  • Route scripts, stylesheets, and images discovered while hydrating a same-origin nested frame through that nested document's active controller and client/navigation generation.
  • Preserve parser ordering: stylesheet application and script execution complete before dependent parser work, followed by one load or error event.
  • Preserve browser fallback semantics only for an unhandled FetchEvent. A handled rejection, invalid/oversized response, timeout, stopped worker, or retired navigation must fail closed.
  • Keep parser progress asynchronous while the worker may message the controlled client for bytes. Do not block the client task queue or retain an obsolete document/frame generation.
  • Reuse the request, destination, response body, admission, and queue bounds introduced by Add readable response and FetchEvent vertical #298/Add CacheStorage controlled fetch broker #303/Add TransformStream resource fallback #304/Intercept connected resources through Service Workers #310.

Acceptance

  • WPT-derived and Chromium contracts cover initial parser-created script and stylesheet ordering, nested-frame script/style/image hydration, Request.destination, URL/base resolution, one unhandled fallback, and handled rejection/error behavior.
  • Native contracts prove parser-dependent inline code observes the intercepted stylesheet/script results in browser order and a same-origin nested frame gets its own client identity and generation.
  • Cross-origin/out-of-scope, traversal-shaped, retired-generation, malformed, >64 MiB, late, and duplicate worker responses cannot reach host fallback after respondWith.
  • Navigation, frame removal, controller loss, unregister, and shutdown leave zero pending parser/frame resource requests and no retained document/client generation.
  • A 64 KiB warm intercepted parser resource completes dispatch-to-ready at p95 <= 100 ms. A 100-cycle document/frame hydrate-remove test retains <= 8 MiB V8 heap and <= 64 MiB RSS after warm-up; publish native and Chromium timings.
  • An unchanged Code-shaped nested webview prelude advances through initial external JS/CSS and a deterministic image without consumer-specific code. Full Markdown completion remains Stream and cache admitted Code OSS webview resources #266 until all resource-plane slices pass.
  • CSS url() interception/escape decoding stays in Decode CSS string and url() escapes before resource resolution #286 and a later Route connected web resources through controlling Service Workers #308 child. Do not change CSS metadata, parser, cascade, or generator paths.

Proposed stack entry

A focused PR based on feature/parser-resource-interception-266 / #310. Keep #308 open for CSS image URL interception and cumulative unchanged-product acceptance.

Activity

  1. wieslawsoltes commented on Sep 17, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Landed on main via #321 at d7720a63aa7cd22842771f66fc7df830c944c5f1 (native implementation stack #319, dynamic connected-resource prerequisite #310).

    Validation on the exact promotion source:

    • focused native CTest webscene_native_service_worker_parser_resources: passed;
    • native WebPlatformSubset controlled-parser-frame-resources: 4/4;
    • Chrome 153 oracle: 4/4;
    • native teardown repetition: 10/10 clean exits after one non-reproducing exit-139 observation.

    The landed contract covers controlled initial parser styles/scripts, nested-frame style/script/image hydration, request destinations and client identity, unhandled fallback, fail-closed handled failures, synchronous frame retirement, 100 hydrate/remove cycles, and bounded latency/heap/RSS. CSS url() resource interception remains separately owned.

  2. wieslawsoltes commented on Sep 18, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Reopened for the existing Linux parser-resource contract timeout in main NuGet run 35320520086.

    webscene_native_service_worker_parser_resources reaches the test executable but its filtered binary invocation does not complete (10.41 s). The same exact timeout is present on the closest completed predecessor bea90e8e in run 35288000024. The macOS contract passes in 1.74 s now and 1.69 s on that predecessor. Exact preceding main 348ea440 was canceled before a complete matrix, and 348ea440..1cf8bc52 contains no runtime/parser changes.

    This is therefore #312 contract/lifecycle ownership, not a new #343 regression and not a reason to open a duplicate issue. The Linux hang/retirement path needs isolated reproduction while preserving the existing parser/frame semantics and numeric lifecycle gates. The unrelated #238 CSS failures remain out of scope.

  3. wieslawsoltes commented on Sep 18, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Linux requalification dependency #355 is resolved via merged PR #357 at 69d929f6fd0ca030c1394c921bebedad603f84b3. The exact Linux package build now compiles the V8 native test target and reaches this issue's parser-resource test, which still reproduces the existing 10.41 s async invocation timeout. That retains #312 as the runtime/fixture owner and removes the intervening #347 GCC capture failure.

  4. wieslawsoltes commented on Sep 18, 2026

    @wieslawsoltes
    CollaboratorAuthor

    Completed by #354, merged as 15d55a4c07d742fc3ba5f4290dfa87b082a04b70.

    The Linux-only timeout was a contract-fixture scheduling defect: synchronous document.open/write/close on an about:blank frame reentered parser-blocking Service Worker handling, so the host could not schedule the retirement-completion evaluation. The corrected contract navigates a controlled frame document, removes it from the pending request callback, and yields between lifecycle cycles. Production runtime behavior was unchanged.

    Exact-head evidence:

    • Linux X64 CI and macOS ARM64 CI passed.
    • Portable V8 and Native Linux document/compiler + installed-SDK contracts passed.
    • Local focused test passed 20/20 invocations × 100 cycles: p95 median 10.85 ms, max 12.44 ms; V8 heap delta 0; RSS delta max 62.05 MiB under the 64 MiB bound.
    • The prior Chromium 4/4 parser/nested-frame contract remains applicable.

    Child #355 supplied the independent Linux compilation portability repair and is already closed without the planned label.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions