You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dom: request the next animation frame again when requestAnimationFrame was replaced - #347523
In main CI 495093, every unit job (Electron on Linux, Windows and macOS, Browser Chromium and WebKit) timed out. About 70 tests failed in a cascade across SessionsList, the Sessions workbench, CanvasEditor and other suites. Those tests had passed in their own PRs.
Mechanism
scheduleAtNextAnimationFrame coalesces all runners for a window behind one pending requestAnimationFrame. The per-window animFrameRequested flag stays set until that frame's callback runs.
A test that fakes requestAnimationFrame and restores it before the faked frame fires leaves the request pending forever. sinon's useFakeTimers() fakes it by default. After that, no animation frame runner runs again in the renderer: every scheduleAtNextAnimationFrame sees the flag already set and never requests a real frame. Every later test that waits on a frame times out.
In main CI's full single-renderer unit run, the first non-native call comes from AutomationsCardsWidget › run feedback survives acknowledgement and refresh until the new run session appears (#347444). It uses useFakeTimers(), and a list splice schedules a frame while the fake is installed. PR CI runs only the affected tests in 4 workers, so the poisoner and its victims never shared a renderer there. Flake Fixer instrumented dom.js locally to find the first non-native call.
Change
Remember which requestAnimationFrame made the pending request, and request a frame again, for the same queue, when a different one is installed. In the product the function never changes, so this costs one comparison per schedule.
All requests for a pending queue share one token. The first callback that fires runs the queue, whichever function made its request, and every other callback for that queue does nothing. So the queue never drains twice in one frame, and a native frame still runs it if it fires while a fake is installed or after the fake is removed.
In animationFrame.test.ts, on an isolated registered window, new tests cover four cases:
a fake that is restored with a frame pending, then a later schedule
native → fake → native with no later schedule
a native frame that fires while the fake is installed
two requests that fire in the same frame
a removed, unregistered iframe with a frame pending, followed by a later iframe. Unregistered windows share one queue. This is the likely cause of the intermittent WebKit OverlayWebview and WorkbenchSizeService clipping failures in main CI 495183, which passed again in 495188.
With the change: 49 passing in animationFrame.test.ts + dom.test.ts. On main: 46/3.
Against the real cascade: on 495093's head 225e6b5944, with only this dom.ts and the poisoning test unchanged, all vs/sessions/** browser unit tests in Chromium go from 29 failing to 8,077 passing and 0 failing.
…e was replaced
scheduleAtNextAnimationFrame requests one frame per window and waits for
it before requesting another. When a test fakes requestAnimationFrame
(sinon's useFakeTimers does by default) and restores it before the faked
frame fires, that request never completes, and no animation frame runner
runs again in the window. In main CI's single-renderer unit run, one
such test (an automation cards test from #347444) made about 70 later
tests across SessionsList, the Sessions workbench and others time out
until every unit job hit its 30-minute limit (495093).
Remember which requestAnimationFrame made the pending request, and
request again when a different one is installed. In the product the
function never changes, so this is one comparison per schedule.
Co-authored-by: Copilot <[email protected]>
Independent confirmation against the real cascade: on 225e6b5944 (main CI 495093's head), with only this PR's dom.ts applied and the poisoning automation-cards test unchanged, running all vs/sessions/** browser unit tests in Chromium goes from 29 failing to 8,077 passing and 0 failing.
The test-side trigger is removed separately in #347524. This change makes the shared animation frame runner recover from any future test that does the same.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Superseded animation-frame callbacks can drain newly queued work and cause duplicate runs per frame, while the recovery test risks leaving the shared scheduler stuck on failure.
This PR makes VS Code’s shared animation-frame scheduler recover when requestAnimationFrame is replaced while a frame is pending, preventing abandoned fake requests from blocking later tests.
Changes:
Track which function issued each window’s pending request and request another frame when that function changes.
Clear the tracking state when a window unregisters.
Add regression coverage for restoring the real function with a fake frame still pending.
File
Description
src/vs/base/test/browser/dom.test.ts
Tests recovery after a pending fake animation-frame request.
src/vs/base/browser/dom.ts
Adds per-window function tracking and replacement detection.
…ated window
Address review: re-requesting left the older request's callback live, so
when both fired in one frame the first could drain work queued for the
next frame. Each request now carries a token, and only the current one
runs the queue. The tests move to animationFrame.test.ts and use an
isolated registered window, so a regression can't leave the shared
runner stuck for later tests.
Co-authored-by: Copilot <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
A pending native frame can be discarded after a native-to-fake-to-native transition, leaving runners queued and tests hanging; the callback recovery path and regression coverage need updating.
…request unreachable
Address review: after native -> fake -> native with no schedule after the
restore, the native frame's callback was superseded by the faked request,
which never fires, so queued runners waited for the next schedule. A
superseded callback now requests a frame through the installed
requestAnimationFrame when the current request went through one that is
no longer installed. It still never runs the queue itself.
Co-authored-by: Copilot <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
A callback guard can discard the original native callback while a temporary fake is installed, leaving queued runners without a live callback and causing the original runner to hang.
No open issues 🎉
1 previously missed issue
In code that hasn't changed since last review
Native callback during fake installation can strand queued runners
src/vs/base/browser/dom.ts:488
If the original native callback fires while the temporary fake is still installed, this guard discards it because the pending request's function still matches the fake. Restoring the native function afterward, without another schedule, leaves both runners queued with no live callback, so awaiting the original runner hangs. Allow the first live callback to drain the pending queue while invalidating other callbacks for that queue (for example, with a shared queue-generation token), and add coverage where the native callback fires before restoration.
…st made it
Address review: with a token per request, a native frame that fired while
a fake was installed was treated as superseded, stranding the queue.
All requests for a pending queue now share one token: the first callback
that fires runs the queue and the others do nothing. This also covers
native -> fake -> native without a later schedule, so the re-request in
the runner is no longer needed.
Co-authored-by: Copilot <[email protected]>
Addressed the previously missed issue (native callback firing while the fake is installed) in 1b312ca, and simplified the change. Requests now share one token per pending queue rather than one per request. The first callback that fires for the queue runs it, whichever requestAnimationFrame made it, and every other callback for that queue does nothing. That covers:
a native frame firing while a fake is installed (new test runs when a native frame fires while requestAnimationFrame is faked, which fails on the previous commit),
native -> fake -> native with no later schedule (the runner's re-request is gone, since the native callback now runs the queue),
two requests firing in the same frame, where only the first drains (a superseded frame request does not run the queue).
animationFrame.test.ts + dom.test.ts: 48 passing on this head, 47/1 on the previous commit, 46/2 on main.
Unregistered windows have no window ID, so they share one animation frame
queue. A test iframe removed with a frame pending left that queue waiting
for a frame that never comes, so later iframes' runners never ran. That's
the likely cause of the intermittent WebKit OverlayWebview and
WorkbenchSizeService clipping failures in main CI 495183. The previous
change already covers it: the later iframe has a different
requestAnimationFrame, so a frame is requested again.
Co-authored-by: Copilot <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human assessment is needed to evaluate an animation-frame lifecycle concern that can retain an unregistered iframe’s JavaScript realm after its callbacks finish.
Address review: keeping it after the frame ran retained a removed
unregistered iframe's realm. It is only needed while a request is
pending.
Co-authored-by: Copilot <[email protected]>
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Human review is needed to assess a memory-retention risk where a strong reference keeps a detached iframe’s JavaScript realm alive because neither cleanup path runs.
Address review: a removed unregistered iframe whose frame never fires
kept its realm alive through this map until the next schedule. A
collected function can't match the installed one, so the next schedule
still requests a frame.
Co-authored-by: Copilot <[email protected]>
Closing this, since #347731 covers the same problem from the test side: each test iframe now gets its own window ID, so a removed iframe can't block animation frames for later tests. The aux-window pair has passed on every main CI run since #347731 merged, and vscode-engineering#4556 is closed. The other stuck-frame case, a test faking requestAnimationFrame with sinon, was fixed in that test by #347524. We can reopen this if that kind of hang shows up again.
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
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.
In main CI 495093, every unit job (Electron on Linux, Windows and macOS, Browser Chromium and WebKit) timed out. About 70 tests failed in a cascade across SessionsList, the Sessions workbench, CanvasEditor and other suites. Those tests had passed in their own PRs.
Mechanism
scheduleAtNextAnimationFramecoalesces all runners for a window behind one pendingrequestAnimationFrame. The per-windowanimFrameRequestedflag stays set until that frame's callback runs.A test that fakes
requestAnimationFrameand restores it before the faked frame fires leaves the request pending forever. sinon'suseFakeTimers()fakes it by default. After that, no animation frame runner runs again in the renderer: everyscheduleAtNextAnimationFramesees the flag already set and never requests a real frame. Every later test that waits on a frame times out.In main CI's full single-renderer unit run, the first non-native call comes from
AutomationsCardsWidget › run feedback survives acknowledgement and refresh until the new run session appears(#347444). It usesuseFakeTimers(), and a list splice schedules a frame while the fake is installed. PR CI runs only the affected tests in 4 workers, so the poisoner and its victims never shared a renderer there. Flake Fixer instrumenteddom.jslocally to find the first non-native call.Change
requestAnimationFramemade the pending request, and request a frame again, for the same queue, when a different one is installed. In the product the function never changes, so this costs one comparison per schedule.Validation
animationFrame.test.ts, on an isolated registered window, new tests cover four cases:OverlayWebviewandWorkbenchSizeServiceclipping failures in main CI 495183, which passed again in 495188.animationFrame.test.ts+dom.test.ts. On main: 46/3.225e6b5944, with only thisdom.tsand the poisoning test unchanged, allvs/sessions/**browser unit tests in Chromium go from 29 failing to 8,077 passing and 0 failing.Fixes microsoft/vscode-engineering#4555
Refs microsoft/vscode-engineering#4556