Skip to content

Prevent window.postMessage traffic from starving due timers #293

Description

@wieslawsoltes

Parent scheduler issue: #287
Remote handshake attribution: #289
Workspace acceptance: #252
Runtime collision/dependency: draft PR #292

Problem

WebScene drains window.postMessage tasks after the Worker/ServiceWorker/MessagePort/WebSocket rotation but before any due timer. A message handler that refills its own window-message queue can therefore prevent a zero-delay timer from running indefinitely, even after the asynchronous-message fairness fix proven locally for #287.

This matches the unchanged Code OSS remote extension-host bootstrap. Its protocol writer requests a timer-coalesced 1,071,424-byte initialization send, while iframe/window messaging remains active. The timer request is retained immediately, but native WebSocket.send is not entered for several seconds.

Reduced evidence

On exact WebScene main 1bd8596e3dc07a3281204504acad379eb1f6bc78 plus local unpushed #287 candidate b75d37958ef7ce3f73a5b08de6b0516b0f8f57eb, the product-shaped 20-cycle oracle adds one self-refilling window.postMessage source alongside Worker, MessagePort, WebSocket, FileReader, and the 1,071,425-byte body:

  • protocol flush maximum: 3229.87 ms
  • p95: 96.456 ms
  • window-message tasks before the delayed flush: 700,000
  • Worker: 0; MessagePort: 1; WebSocket: 1; FileReader: 0
  • window-message queue remains self-refilling rather than growing without bound

Without the window source, the same candidate reports maximum 0.204 ms and p95 0.157 ms. The packaged unchanged-Code trace independently measured protocol-send request → native WebSocket.send entry at 3698 ms, followed by a 0.783 ms send and 0.834 ms microtask. The close agreement identifies task arbitration rather than wire throughput.

Evidence: /private/tmp/webscene-289-b75d3795-window-message-oracle.log (SHA-256 d2f77ef271fe8863b36370e77feba57c730939bcf7844e8a6f955777fcc5416d) and /private/tmp/vscode-252-product-b75d3795.log (SHA-256 f58b40413fe5dd30567d0d6a3d207b668fd07bea96b594aae9c5568509a38252).

Scope

Make due timers fair with the window.postMessage task source while preserving FIFO ordering, origin/source/transfer semantics, bounded queue limits, and the four-source Worker/ServiceWorker/MessagePort/WebSocket rotation. Do not alter transferred MessagePort lifetime ownership or add Code OSS special cases.

Draft #292 touches the same runtime dispatcher. Its DOM-listener retirement work is semantically independent, but this implementation must wait for #292 to merge or split, then rebase without regressing #281's four-source rotation.

Acceptance

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

    bugSomething isn't workingvscode-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