Skip to content

[Bug]: clock.pause_at() hangs when the page has an active requestAnimationFrame loop #3137

Description

@galipruzansky

Version

1.59.0 (playwright-python), Chromium 147.0.7727.15, macOS (also reproduces with the default headless shell)

Steps to reproduce

importasynciofromplaywright.async_apiimportasync_playwrightPAGE="<script>function tick(){requestAnimationFrame(tick)}requestAnimationFrame(tick)</script>"asyncdefmain():
asyncwithasync_playwright() aspw:
browser=awaitpw.chromium.launch(headless=True)
page=awaitbrowser.new_page()
awaitpage.clock.install()
awaitpage.set_content(PAGE)
awaitasyncio.sleep(0.3)
forcyclein (1, 2):
fake_now=int(awaitpage.evaluate("Date.now()"))
awaitasyncio.wait_for(page.clock.pause_at(fake_now), timeout=10)
print(f"cycle {cycle}: pause_at OK")
awaitpage.clock.resume()
awaitasyncio.sleep(0.3)
awaitbrowser.close()
asyncio.run(main())

Expected behavior

Both pause_at calls return promptly — each pauses at the page's current fake time.

Actual behavior

The first install -> pause_at -> resume cycle works; the second pause_at never resolves (hangs indefinitely; the wait_for above times out):

cycle 1: pause_at OK
cycle 2: pause_at HANGS (>10s)

Reproduces identically on the default headless shell and channel="chromium". Removing the requestAnimationFrame loop from the page makes both cycles pass.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions