Skip to content

Conversation

@karlseguin
Copy link
Collaborator

@karlseguin karlseguin commented Sep 3, 2025

There's friction between the CDP polling for data and the page polling for data.

This was previously "improved", by making it so that CDP polling would also active the page polling, and making the page somewhat aware that CDP might need polling.

This has been completely reworked.

1 - If there's a page with no CDP (./lightpanda fetch), then the page is free to exit as soon as all work is done
2 - If there's a page with CDP, the page is the only one doing the polling.
3 - If there's no page with CDP, CDP is doing the polling (which is ok, because, without a page, the only data we can get is a CDP message).

This removes the friction and allows the page to poll/timeout smartly, as it has the most context (e.g. information about scheduled tasks).

While this makes the page slightly CDP aware, this PR also removes the page.request_intercepted field, which poorly served a similar purpose. So, as far as CDP-pollution is concerned, it's a wash.

Slightly unrelated, requestAnimationFrame is now automatically placed in the low priority work queue. Unlike setInterval or other background tasks which are inherently repetitive, requestAnimationFrame is repetitive only because the typical use case is for requestAnimationFrame to call requestAnimationFrame. This circumvents our the high -> low priority migration we apply to repeating tasks, meaning that requestAnimationFrame would keep a page from being "done".

This appears to be what chrome is doing. I don't know why we weren't before.
Further reducing bouncing between page and server for loop polling. If there is
a page, the page polls. If there isn't a page, the server polls. Simpler.
@karlseguin karlseguin merged commit f393eb7 into main Sep 3, 2025
13 of 14 checks passed
@karlseguin karlseguin deleted the http_always_monitor_cdp branch September 3, 2025 12:35
@github-actions github-actions bot locked and limited conversation to collaborators Sep 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants