Repository navigation
js: let a page end the settle loop early by posting "done" (M6, engine#346) - #347
Merged
Merged
Conversation
…e#346) go-wasmcontainers' own automation-interface ask, part of the WebGPU-readiness roadmap: "Fetch + RenderDocument + JSLog + the DOM... provided a render can wait for the page to post 'done', meaning async completion with a timeout." Adds Engine.EnableDoneSignal (default false, no behaviour change for any existing caller). When set, a page can call __webengineDone(value); the settle loop breaks out as soon as it fires instead of running out the full pass/JSTimeout budget, and Session.Done() reports the value back. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
M6 of the go-wasmcontainers WebGPU-readiness roadmap (M1 shipped as #341). The peer's own ask: "Fetch + RenderDocument + JSLog + the DOM... provided a render can wait for the page to post 'done', meaning async completion with a timeout." No WebDriver/CDP protocol needed, and no new goroutine — this rides entirely on the existing settle loop and
JSTimeout/deadman budget.Engine.EnableDoneSignal bool(defaultfalse, no behaviour change for any existing caller — not even an extra global name exists).js/window.go'sinstall()installs a global__webengineDone(value)a page's own script can call once its async work is finished (first call wins; later calls are no-ops).settle_scripts.go'ssettle()pass loop now breaks as soon assess.Done()reports the signal fired, instead of running outmaxSettlePasses/JSTimeout.Session.Done() (value interface{}, ok bool)(js/session.go) reports the signal and the page's own value, exported via goja the same wayEval's return value is.Closes #346.
Test plan
go build ./...,go vet ./...cleanenginejs_test.go's newTestEnableDoneSignalStopsSettleEarlyreusesTestSettleFixpointCap's own self-replicating script chain: with the option on, the loop stops right after__webengineDone()fires (data-d="2"); with it left off, the identical page still reachesdata-d="4"— proving the feature is a true no-op for existing callers.js/js_test.go's newTestSessionDoneSignalcoversSession.Done()directly: a call with a value, no call at all, a call with no argument (goja'sUndefined(), not Gonil), and — with the option off — the same call throwingReferenceError.🤖 Generated with Claude Code