Skip to content

fix(browser): a same-document back/forward returns at its commit while extensions run, too - #762

Merged
Hona merged 1 commit into
devfrom
browser-tools/samedoc-ext
Nov 22, 2026
Merged

Hona merged 1 commit into
devfrom
browser-tools/samedoc-ext

Conversation

@Hona

@Hona Hona commented Nov 22, 2026

Copy link
Copy Markdown
Member

What

Follow-up to #742. A same-document browser.back / browser.forward (a pushState entry or an anchor) now returns at its commit while extensions run, too: it still waited the full 1.2 s grace there.

With extensions active the engine keeps Page.* events to itself (cdp_ledger, #274), so the main frame's Page.navigatedWithinDocument that #742 waits for never reaches the app. The page's own main execution context answers instead: a same-document entry keeps it, a new document destroys it. Once the tab's address moved, the app asks that context (pinned by its id, as browser.evaluate does) for location.href; the new address from it counts as the entry's commit. At most 6 asks per back/forward; a gone context, a throw or a different spelling of the address fall back to the grace as before.

Files: new rpc/exec/same_doc.rs; rpc/exec/nav.rs holds the probe in the wait; read.rs shares send_eval_cdp; settle.rs comment only. No engine input.

Measured before this change (#742's CI build, hidden desktop, published engine 156.0.26-10)

Case no extension uBlock Origin Lite
back over an anchor entry 19 ms median (was 1,222) 1,215 ms
back over a pushState entry 18 ms median (was 1,223) 1,217 ms

Checked

cargo check -p opencode-desktop on blade (exit 0).

Not proved in this PR

  • The uBlock column after this change: I measure it on a build that contains it and post the numbers here.

…e extensions run, too

With extensions active the engine keeps Page.* to itself, so #742's Page.navigatedWithinDocument never reaches the app and the wait ran to the 1.2 s grace. The page's main execution context answers instead: a same-document entry keeps it, a new document destroys it. Once the address moved, that context is asked for location.href; the new address from it is the commit. At most 6 asks; anything else ends at the grace as before.
@Hona
Hona merged commit 9cc299e into dev Nov 22, 2026
@Hona
Hona deleted the browser-tools/samedoc-ext branch November 22, 2026 23:00
@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.

@Hona

Hona commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Measured on this PR's CI build (exe 576daa66…, published engine 156.0.26-10, hidden desktop), 10 runs each: with uBlock Origin Lite + a cross-origin frame, back over an anchor entry 23 ms median (was 1,215), over a pushState entry 25 ms (was 1,217); without extensions 20 / 18 ms. 0/100 wrong page, next command ok 100/100. bfcache / no-store 25-29 ms; no entry still at the grace (1,271-1,297 ms).

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