Repository navigation
Conversation
This was referenced Sep 5, 2026
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
WaitStableRAFcan block indefinitely when it is called on a background or frozen tab.Root cause
Element.WaitStableRAFderives a context-bound page before waiting for repaint:However, Page.WaitRepaint performs the evaluation through p.root:
Page.Context creates a shallow page clone. Its root field still points to the original root page, so the caller's context is not propagated to the page that evaluates requestAnimationFrame.
When a tab is hidden, backgrounded, frozen, or continuously changing, requestAnimationFrame may be throttled or never invoked. In that case, the returned promise remains pending and the caller's timeout cannot cancel the operation.
Fix
Preserve the caller's context when evaluating requestAnimationFrame on the root page:
This keeps the existing root-page behavior required for iframe support while ensuring that Page.Context, Page.Timeout, and cancellation remain effective.
Tests
The following regression tests were added:
The background-tab test was also run against the previous implementation. It failed with:
background WaitStableRAF remained blocked; this reproduces the pre-fix root-context regression
With the fix applied, all targeted tests pass:
Effect
Before this change, WaitStableRAF could remain blocked forever on a background or frozen tab, even when the caller supplied a timeout or cancellation context.
After this change, the operation reliably returns when its context expires, including while the target tab is inactive or when multiple tabs are repeatedly activated and deactivated.