Skip to content

fix(browser): revert #640, so back/forward settle with their history commit again - #675

Merged
Hona merged 2 commits into
devfrom
browser-tools/revert-engine-wake
Nov 22, 2026
Merged

Hona merged 2 commits into
devfrom
browser-tools/revert-engine-wake

Conversation

@Hona

@Hona Hona commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

On dev-464, an agent's browser command right after back can fail with [browser.document_changed]. This PR reverts #640 entirely, in two commits. The first took out only its engine-message wake. The gate below then still showed 1 failure in 10 with uBlock Origin Lite, so the second reverts the fetched-command wake too.

What broke

The change

Proof

Sequence table: each first command, then a page command at once, 10 times each, in four configurations (no extension; uBlock Origin Lite; cross-origin frame; both).

  • Before: the release commit df906704e9 (dev-464) with the published engine 156.0.26-8. Posted in a comment.
  • After: this PR's CI build with the same engine. Expected 0 first-try failures in every cell. Posted in a comment.
  • tools\smoke.ps1: in a comment.

The real fix, which settles back/forward on the commit itself and brings the quick engine wake back, is #635. It will be measured before it is designed.

…rward settle with their commit

Reverts the engine-message wake of #640. Read the turn they arrived, the engine's messages let back/forward return before their history commit's DevTools events landed, so the agent's next command failed [browser.document_changed] (dev-464). Read at the window's next frame they land together again, about 16 ms later per reply. The fetched-command wake of #640 stays.
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown

PR test build retired — merged into dev. Install or auto-update OpenCode (Rune) from https://anoma.ly/release/opencode/desktop-rune/dev/macos-arm64-dmg.

…indow's next frame again

The gate after the first commit (engine-message wake only reverted; published engine 8): 0/10 failures everywhere without extensions, but with uBlock Origin Lite back -> snapshot still failed [browser.document_changed] 1/10 (dev-464: 7/10). With the fetched-command wake the next command starts in the turn it is fetched, before a late DevTools event of the history commit is read. So it is not innocent: this reverts the rest of #640 (6e5ddc8), browser_waker, set_message_waker and the worker's quiet wake included. Every engine message and fetched command is read at the window's next frame, as in dev-463.
@Hona Hona changed the title fix(browser): the engine's messages wake the window again, so back/forward settle with their commit fix(browser): revert #640, so back/forward settle with their history commit again Nov 22, 2026
@Hona

Hona commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Gate on the first commit (2384ab382f), published engine 156.0.26-8, 10 runs per cell (proof\browser-tools\seq\gate-675.md in operation-detox). Without extensions: 0/10 everywhere. With uBlock Origin Lite: back -> snapshot still failed 1/10, so the second commit reverts the fetched-command wake too. The gate runs again on 803ad1bb06.

#675 gate: a command at once after back / forward, 10 runs per cell

Engine 156.0.26-8 (published) on both sides; capture tickets, 22 Nov 12:26-12:37; run files gate-675-<g464|g675>-<xframe|both>.json beside this table.

  • n/m failed: the second command failed on its first try in n of the m runs that reached it.
  • setup ×k: the run's own setup (navigate away and back, or the back before a forward) failed first, so the run never reached the sequence: the same race on an earlier command.
  • first ×k: the first command itself (forward) failed.
  • retry: the failed command, called again at once until it succeeded (up to 5 s).

no extension, cross-origin frame

Sequence BEFORE dev-464 (08341fa7c1) AFTER #675 (2384ab3) first command ms, median (before / after)
back -> forward 1/6 failed [browser.document_changed] ×1, setup [browser.document_changed] ×4; retry succeeded 1/1, median 25 ms 0/10 36 / 1232
back -> snapshot 6/10 failed [browser.document_changed] ×6; retry succeeded 6/6, median 26 ms 0/10 45 / 1226
back -> evaluate 4/10 failed [browser.document_changed] ×4; retry succeeded 4/4, median 24 ms 0/10 44 / 1227
forward -> snapshot 5/5 failed setup [browser.document_changed] ×1, first [browser.document_changed] ×4, [browser.document_changed] ×5; retry succeeded 5/5, median 51 ms 0/10 31 / 1225

uBlock Origin Lite, cross-origin frame

Sequence BEFORE dev-464 (08341fa7c1) AFTER #675 (2384ab3) first command ms, median (before / after)
back -> forward 3/6 failed setup [browser.document_changed] ×4, [browser.document_changed] ×3; retry succeeded 3/3, median 47 ms 0/10 41 / 46
back -> snapshot 7/10 failed [browser.document_changed] ×7; retry succeeded 7/7, median 21 ms 1/10 failed [browser.document_changed] ×1; retry succeeded 1/1, median 92 ms 26 / 82
back -> evaluate 5/10 failed [browser.document_changed] ×5; retry succeeded 5/5, median 19 ms 0/10 34 / 41
forward -> snapshot 2/2 failed setup [browser.document_changed] ×1, first [browser.document_changed] ×7, [browser.document_changed] ×2; retry succeeded 2/2, median 35 ms 0/10 33 / 1229

@Hona

Hona commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Gate on 803ad1bb06 (#640 reverted entirely), published engine 156.0.26-8, 10 runs per cell: 0 first-try failures in every cell, both configurations; back/forward take ~1,230 ms again, as on dev-463 (which also shows 0/10 with uBlock Origin Lite). tools\smoke.ps1: 12/12 in 81.2 s.

#675 gate: a command at once after back / forward, 10 runs per cell

Engine 156.0.26-8 (published) on both sides; capture tickets, 22 Nov 12:26-12:37; run files gate-675-<g464|g675>-<xframe|both>.json beside this table.

  • n/m failed: the second command failed on its first try in n of the m runs that reached it.
  • setup ×k: the run's own setup (navigate away and back, or the back before a forward) failed first, so the run never reached the sequence: the same race on an earlier command.
  • first ×k: the first command itself (forward) failed.
  • retry: the failed command, called again at once until it succeeded (up to 5 s).

no extension, cross-origin frame

Sequence BEFORE dev-464 (08341fa7c1) #675 first commit (2384ab3) AFTER #675 (803ad1b, #640 reverted) dev-463 (before #640) first command ms, median (each build)
back -> forward 1/6 failed [browser.document_changed] ×1, setup [browser.document_changed] ×4; retry succeeded 1/1, median 25 ms 0/10 0/10 not run 36 / 1232 / 1229 / —
back -> snapshot 6/10 failed [browser.document_changed] ×6; retry succeeded 6/6, median 26 ms 0/10 0/10 not run 45 / 1226 / 1229 / —
back -> evaluate 4/10 failed [browser.document_changed] ×4; retry succeeded 4/4, median 24 ms 0/10 0/10 not run 44 / 1227 / 1229 / —
forward -> snapshot 5/5 failed setup [browser.document_changed] ×1, first [browser.document_changed] ×4, [browser.document_changed] ×5; retry succeeded 5/5, median 51 ms 0/10 0/10 not run 31 / 1225 / 1230 / —

uBlock Origin Lite, cross-origin frame

Sequence BEFORE dev-464 (08341fa7c1) #675 first commit (2384ab3) AFTER #675 (803ad1b, #640 reverted) dev-463 (before #640) first command ms, median (each build)
back -> forward 3/6 failed setup [browser.document_changed] ×4, [browser.document_changed] ×3; retry succeeded 3/3, median 47 ms 0/10 0/10 0/10 41 / 46 / 1229 / 1225
back -> snapshot 7/10 failed [browser.document_changed] ×7; retry succeeded 7/7, median 21 ms 1/10 failed [browser.document_changed] ×1; retry succeeded 1/1, median 92 ms 0/10 0/10 26 / 82 / 1235 / 1228
back -> evaluate 5/10 failed [browser.document_changed] ×5; retry succeeded 5/5, median 19 ms 0/10 0/10 0/10 34 / 41 / 1226 / 1228
forward -> snapshot 2/2 failed setup [browser.document_changed] ×1, first [browser.document_changed] ×7, [browser.document_changed] ×2; retry succeeded 2/2, median 35 ms 0/10 0/10 0/10 33 / 1229 / 1229 / 1224

@Hona
Hona merged commit b76cc0a into dev Nov 22, 2026
7 checks passed
@Hona
Hona deleted the browser-tools/revert-engine-wake branch November 22, 2026 03:29
Hona added a commit that referenced this pull request Nov 22, 2026
… are applied (#696)

* fix(browser): back/forward return once their commit's DevTools events are applied

dev-464 showed that an agent's next command after back/forward could fail [browser.document_changed]: the command returned before the history commit's DevTools events were applied, each of which bumps the tab's generation, so the next command was authorized against the old one (#640's quick wake made it frequent; #675 reverted it, and back/forward now wait the 1.2 s grace again). A trace of every navigation event (4 configurations x 20 runs) showed that each new document brings exactly its address, the main frame's Runtime.executionContextsCleared and, unless the engine runs extensions, its Page.frameNavigated, and no other bump; every failure had one of these after the return. back/forward now record the frame tracker's counts of those two events and return when the address has moved and both (with extensions, the first) have been applied and the tab is not loading. LOAD_SETTLE_GRACE stays the bound and the fallback (same-document or same-address entries). back/forward with no entry that way return at once, as official does.

* fix(browser): back/forward also wait for the new document's main context; no spin past the grace

READER-12 should-fixes on #696: (a) clearing removes the main frame's execution context and an evaluate before the new one exists fails document_changed; with extensions the context came up to 8 ms after the clearing in 30 of 67 navigating runs (none after the navigation without, 0 of 68): back/forward now also wait for it, in both. (b) ExecPhase::next_wake: once the grace has passed, a wait still loading wakes at its deadline (the load's own messages wake the poll) instead of at a past instant every poll.

* fix(browser): back/forward don't trust the tab's history ends, and wait for a main-frame navigation the engine is known to send

READER-12b's #696 follow-ups. F1/F3: the engine refreshes can_go_back/forward only when loading changes, so a click-made same-document entry could look absent and the no-entry shortcut would skip it; the shortcut is gone: with no entry the back does nothing and the wait ends at the grace, as before #696 (measured: no-entry 1,291 ms median on dev-469 and on #706). F2: whether to wait for the main frame's Page.frameNavigated no longer rests only on the app's view of extensions: a tab whose main-frame navigations have reached the app before waits for this one too.

* refactor(browser): when a load wait is over is a pure function, with its cases as a table

ORCHESTRATOR / READER-12b should-fix on #696: the condition that decides when a back/forward has landed moves out of step_wait_load into exec/settle.rs, tested as a table: cross-document commit + load end; same-document (pushState / hash) ends at the grace; no entry ends at the grace; an iframe navigation does not end it; a load seen that is not the history move does not end it (#706's guarantee); tab closed resolves; the deadline resolves at 15 s. The comment on a tab with no frame tracker yet now says what happens.

* fix(browser): the landing condition's tests leave the repo; settle.rs depends on std only

rune-desktop has no tests (AGENTS.md; guardrails Rule 8 failed #696 on 80da0ff for the #[test] / #[cfg(test)] lines). The table moves outside the repo (operation-detox harness\browser\settle-table.rs, which includes settle.rs by path). settle.rs now holds HistoryFrom and takes the wait's elapsed time and deadline as Durations, so it builds with std alone.
Hona added a commit that referenced this pull request Nov 22, 2026
…n (re-land #640) (#732)

#640 gave the engine's messages their own quiet waker, so each DevTools round trip of an agent's
browser command no longer waits for the window's next frame. #675 reverted it because back/forward
then ended before their history commit was applied. That early end was in the settle logic, fixed
since by #706 and #696 (back/forward now wait for the commit's own DevTools events), so the faster
wake comes back unchanged.

This reverts commit b76cc0a.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant