Repository navigation
Replies: 1 comment
|
Thank you for the proposal, the branch and the clear write-up. I checked the leak with Chrome 156, and it holds. It is released in v0.24.0 as I wrote the change again in a smaller form:
See example 31 in |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I would like to suggest a new context option,
WithoutRuntimeEnable(). Thechange is ready on a branch, with tests and docs. Pull requests are limited to
collaborators, so I describe it here first.
main: main...dpanic:without-runtime-enableThe branch has two commits. The first one is a small fix that stands on its
own:
runPolltakes the read lock offrameMuand then callsenclosingFrame, which takes the same read lock again. APollin a framecan then hang when a frame event waits for the write lock. The second commit
adds the option.
Why
The first
Runof a context sendsRuntime.enable. While the Runtime domainis enabled, Chrome serializes each argument of a console call for the
protocol, and a page can see this work. For example, a page logs an error
with
console.debug, and the serialization runsError.prepareStackTraceora getter on the name of the error. A page that does not run under the
protocol sees neither. So any page can tell that a program drives it.
Most actions do not need the command.
Runtime.evaluateandRuntime.callFunctionOnwork without it. The queries andPollneed it onlyto learn the execution context of each frame.
What this changes
WithoutRuntimeEnable(). With it,attachTargetdoes not send
Runtime.enable.commands in the same order as before.
Pollget the execution context of a framefrom
Page.createIsolatedWorld. The target keeps one world for each frame,and drops it when the frame navigates or detaches, or when the document is
updated. A reply that arrives after a drop is used for that call and is not
kept.
200 ms, and not every 5 ms. When the context of the action ends, the last
error goes to the error log func.
runPollno longer takesframeMuaroundenclosingFrame, which takes thesame read lock again.
Limits of the option
Consolegets only the entries of thebrowser log.
Listen,EventsandWithListenerget no Runtime events.Runtime.addBindingto the page. SoExposeFuncreturns no error, but the page gets nowindow.<name>.PollandPollFunction, and the execution context of aWaitFuncfunc, are in an isolated world. They see the DOM and not theglobals of the page.
Evaluatestill runs in the main world.The decision file
docs/decisions/2026-11-17-attach-without-runtime-enable.mdis marked Proposed.
docs/API.md(example 31),docs/MIGRATION.mdanddocs/PROGRESS.mddescribe the option.Tests
noruntime_test.goruns the same checks with and without the option in areal browser: queries and
Pollin the top document and in an iframe,after a navigation, a page that detects
Runtime.enable, and the console,exception and binding events.
for each interval, the error of the context, one log line), a failure that
a navigation drops, and a reply that races a drop. No test sleeps.
go test -p 1 -count=1 ./...passes with the same results as on main, plusthe new tests.
go test -race -count=20passes for the new tests.go vetpasses for Linux, Windows and macOS.
the ones that use the limits above:
Console,Listen,WithListener,ExposeFunc, andPollpredicates that read a page global.Should
ExposeFuncreturn an error on a context with this option? It is asmall change, and I left it out until there is a decision.
If you want the change, I can open a pull request when that is possible, or
you can take the branch as it is. I am glad to change the name of the option,
the name of the world (
__chromedp_query) or anything else.All reactions