Skip to content

Implement Worker, transferable MessagePort, and iframe contexts for Code OSS #81

Description

@wieslawsoltes

Current worker and messaging checkpoint — 20 September 2026

Exact current source heads are WebScene 98077f23, AppScene 5a0d9a9, and unchanged Code OSS 645f29cc. The latest complete package uses WebScene bd366836 and now proves a real editor Worker $computeLinks request/reply plus the browser extension-host iframe, transferred MessagePort, Ready, and Initialized handshake while UI timers continue.

This removes the prior macOS package blocker. The issue remains open for its stated module-load failure, termination/navigation, forced-GC, sustained throughput/memory, and Linux/Windows package gates; #288 owns the active-port forced-GC matrix. No new Worker implementation is scheduled until those exact gates expose a reduced failure.

Problem

The packaged Code OSS 1.137.0 native smoke renders and passes editor create/type/render/undo through AppScene/WebScene, and its bundled Node extension host connects successfully. Runtime diagnostics still report:

The web worker extension host is started in a same-origin iframe!
Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes.

WebScene currently does not provide the iframe/Worker/transferable MessagePort path expected by upstream Code OSS browser extension and Monaco language-worker code. Main-thread fallback reduces responsiveness and does not cover extensions that require worker isolation.

Required design

  • Implement dedicated worker execution contexts using the existing V8 task/runtime ownership model.
  • Support the Worker constructor, script/module loading through the admitted resource contract, postMessage, MessageChannel, transferable MessagePort, structured clone, termination, error/messageerror events, and shutdown/navigation cancellation.
  • Implement the narrow iframe browsing-context behavior required by the Code OSS worker extension-host bootstrap, with same-origin enforcement and explicit rejection for unsupported navigation.
  • Keep worker execution off the UI thread and enforce bounded queues, memory accounting, resource size limits, and origin policy.
  • Do not emulate successful isolation by running worker code synchronously in the document realm.
  • Preserve the bundled Node extension host as the supported native desktop path while browser-worker coverage is developed.

Quality and performance gates

  • Add cross-platform native contracts for ordering, transfer ownership, port close, worker termination, module-load failure, and navigation/shutdown races.
  • Add bounded queue and sustained message-throughput benchmarks with published budgets and memory/result-pool leak checks.
  • Add selected Worker/HTML/structured-clone web-platform tests with explicit exclusions.
  • Run a packaged Code OSS test that starts a Monaco language worker and a browser extension worker, verifies a request/response, and confirms the UI thread remains responsive.

Acceptance

  • Code OSS no longer logs main-thread language-worker fallback.
  • The browser extension-host iframe and transferred ports initialize without application source changes.
  • Worker failures remain observable and cannot bypass resource/origin admission.
  • Linux, macOS, and Windows package jobs and performance gates pass.

Current dependency status — 18 September 2026

Structural CSS PR #245 merged as 4040058e, so its former collision is retired. #288's first active-listener reachability fix merged through PR #296 as 716aaf82; #288 remains open for dedicated Worker, ServiceWorker, and iframe identity/reachability, transfer/release, inactive-port collection, navigation, termination, and teardown acceptance.

This issue owns Worker, structured clone, transferable MessagePort, and the browser extension-host worker bootstrap. General iframe navigation, realms, CSP, document replacement, and teardown belong solely to #267 under #264. Final unchanged Code OSS Worker/Monaco/browser-extension acceptance consumes #267 rather than duplicating it.

The remote Ready→Initialized scheduler slice merged through #289/PR #347. Its remaining product proof belongs to the next current-package #252 run; do not add another scheduler fix here without a new reduced failure.

Activity

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

    vscode-oss/plannedPlanned for the AppScene/WebScene VS Code OSS integration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions