Repository navigation
fix: mitigate Linux webview renderer FD exhaustion during resource loading - #326272
Merged
Merged
Conversation
Contributor
|
This PR will be automatically cherry-picked to |
Contributor
There was a problem hiding this comment.
Pull request overview
Mitigates Linux renderer FD exhaustion by limiting concurrent host-backed webview resource streams.
Changes:
- Adds a 32-stream global semaphore with lifecycle-aware release handling.
- Synchronizes the service worker version bump.
- Adds a concurrent resource-loading integration test.
Show a summary per file
| File | Description |
|---|---|
webviewElement.ts |
Updates the expected service worker version. |
service-worker.js |
Implements response-body concurrency limiting and stream tracking. |
webview.test.ts |
Adds concurrent local-resource coverage. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 3
- Review effort level: Medium
Robo (deepak1556)
force-pushed
the
robo/webview_fd_mitigation
branch
2 times, most recently
from
July 17, 2026 04:30
11acfdd to
a347398
Compare
Martin Aeschlimann (aeschli)
previously approved these changes
Jul 17, 2026
…ading Codex extension surfaced a renderer forced exit after hitting EMFILE on Linux when a webview issued very large number of concurrent local resource fetches. Diagnosis - Codex extension can trigger roughly 625 concurrent webview resource requests. - Webview resource loading currently forwards each request to the host and begins transferring the returned body immediately. - Disk reads are chunked at 256 KiB, and Mojo uses shared-memory FDs for payloads above 64 KiB, so each in-flight resource body can consume file descriptors in the renderer while it is being streamed. - The sandboxed renderer runs with RLIMIT_NOFILE=1024 on Linux. - This is not specific to codex extensionn, any extension with enough concurrent resource bodies can accumulate to exhaust the renderer FD budget. This makes the problem specifically about the number of simultaneously active host-backed response bodies. A naive limiter around WebviewElement.loadResource() would not address the root cause because loadResource() returns as soon as the stream is transferred, while the FD pressure persists for the lifetime of the stream in the renderer. Introduce a service-worker-side global concurrency limit for host-backed webview resource response bodies. - Add a global limit of 32 active host-backed resource bodies in the webview service worker. - Acquire a permit before creating/posting the load-resource request so time spent waiting for a slot does not consume the existing 30 second RequestStore timeout. - Hold the permit for the full lifetime of the returned ReadableStream, and release it only when the stream reaches EOF, errors, or is cancelled. - Release exactly once on all non-stream results and on every early/error path, including timeout handling. - Preserve existing range request behavior, ETag/304 handling, CacheStorage behavior, Safari fallback streaming, and cancellation semantics. - For cacheable responses, keep the permit until both source transfer and the associated cache write complete, without delaying delivery of the response back to the webview. - Bump the service worker version and WebviewElement expected version together so clients pick up the updated worker. Tests - Add an API integration regression test that creates a webview, materializes many local resources, fetches them concurrently from inside the webview, and verifies the webview stays alive and all loads complete. Co-authored-by: Copilot <[email protected]>
Robo (deepak1556)
force-pushed
the
robo/webview_fd_mitigation
branch
from
July 17, 2026 18:48
a347398 to
62728f2
Compare
Robo (deepak1556)
marked this pull request as ready for review
July 17, 2026 19:05
Robo (deepak1556)
enabled auto-merge (squash)
July 17, 2026 19:06
Paul (pwang347)
approved these changes
Jul 17, 2026
Joe Politz (jpolitz)
added a commit
to jpolitz/pyret-lang
that referenced
this pull request
Jul 29, 2026
Joe says: Based on the typespec issue listed below, I'm pretty sure we hit some kind of racy flake in VScode itself (separate commits fix our own race issues). This commit forces our testing environment to use the same commit of vscode that typespec went back to in order to fix their issue. Claude says: @vscode/test-web downloads the LATEST stable VS Code build at test time, so every CI run floats on whatever Microsoft shipped last. VS Code 1.130.0 (commit 1b6a188127ee) was released 2026-07-22; on that build the vscode env intermittently dies at boot: the .arr tab opens, the web extension host starts, but resolveCustomTextEditor is never invoked -- no webview iframe, no error, no notification -- until the harness's 120s bound trips. Only the dev-extension jobs (vscode, both flavors) hit it; the ovsx jobs, whose extension installs as a packaged VSIX and so is registered before the workbench opens the file, never do. The suite was green for weeks on 1.129.1 (8a7abeba6e03) and this exact harness code has both green and red runs on 1.130.0, so the trigger is the build rollover, not a commit of ours. Independent confirmation: microsoft/typespec's vscode e2e suites (web and desktop) started hanging the same day, were disabled to unblock CI, and were re-enabled by pinning to this same 8a7abeba build: microsoft/typespec#11369 microsoft/typespec#11383 The 1.130 release notes mention nothing about custom editors or the web extension host, but the same race family exists upstream -- a file opened at launch can resolve before a contributed custom editor is registered, and a custom-editor open with no registered provider spins forever with no error: microsoft/vscode#325506 microsoft/vscode#96407 https://code.visualstudio.com/updates/v1_130 1.130.0 changes plausibly retiming startup: the MessagePort IPC layer now drops unparseable frames instead of erroring, and webview resource loading gained a global stream semaphore: microsoft/vscode#326172 microsoft/vscode#326272 The pin also makes this env deterministic, which "latest stable" never was. Revisit when a post-1.130.0 stable proves green; as of today no upstream issue tracks this regression, so ours may be the first report. Co-Authored-By: Claude Fable 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UWehNoCfHncXSWk6D3DFeQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Followup improvement for #326092
The issue surfaced a renderer forced exit after hitting EMFILE on Linux when a webview issued very large number of concurrent local resource fetches.
This makes the problem specifically about the number of simultaneously active host-backed response bodies. A naive limiter around
WebviewElement.loadResource()would not address the root cause becauseloadResourcereturns as soon as the stream is transferred, while the FD pressure persists for the lifetime of the stream in the renderer.Introduce a service-worker-side global concurrency limit for host-backed webview resource response bodies.
Tests