Skip to content

fix(browser): back/forward settle on the history commit, not a 1.2 s grace - #635

Closed
Hona wants to merge 8 commits into
devfrom
browser-tools/history-settle
Closed

Hona wants to merge 8 commits into
devfrom
browser-tools/history-settle

Conversation

@Hona

@Hona Hona commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

back and forward took 1,231,000 and 1,233,000 µs with almost no spread, against official's 72,000 and 77,000 (timing table, 22 Nov, notes\for-owner-engine.md section (j)). That is LOAD_SETTLE_GRACE (1.2 s) in exec/nav.rs.

  • Cause: a history entry restored from the back/forward cache commits without ever reporting loading. So saw_loading stayed false and the wait ran out the grace, which exists for a navigation that never starts.
  • Fix: back/forward remember the tab as it was: URL, document counter, and canGoBack/canGoForward. When any of them changes, the history navigation has committed. The wait then settles as soon as the tab is not loading, as it does after a load it saw.
    • The grace stays as the fallback for a history entry that changes nothing.
    • Official does the same: it waits for the navigation to begin and then for !contents.isLoading() (packages/gui-plugins/src/browser/chromium.ts:1724-1746 at ba5bbef8).
  • Not changed: navigate, reload and tabs.open (their waits already settle on the load they see).

Re-measured back/forward on this PR's CI build in a timing ticket: in the PR comments.

Also fixes a regression from #640 (in dev-464)

…grace

A history entry restored from the back/forward cache commits without ever reporting loading, so back and forward waited out LOAD_SETTLE_GRACE (1,231 ms against official's 72 ms in the timing table). They now settle once the tab's URL, document or history ends change and it is not loading, as official waits for the navigation and then !isLoading (chromium.ts:1724-1746 at ba5bbef8); the grace stays as the fallback.
@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

PR test build retired — this pull request is closed.

Hona added 7 commits November 22, 2026 06:14
…d title; no-op history ends return at once

READER-12 on #635: the address change of a page restored from the back/forward cache came before its loading-state update, so the history wait could settle with the old canGoBack/canGoForward and title. The engine now reads them from the browser and its visible navigation entry with the address (ENGINE_REVISION 8, unpublished). back/forward with no entry that way return the tab at once, as official does (chromium.ts:1728-1733), instead of waiting out the grace.
…document

Windowed runs showed forward failing as browser.document_changed: back settled on the address before its DevTools navigation events landed, and when they did the tab's generation moved under the next, already authorized, call. A history wait now also waits until the frame tracker no longer holds the old address for the main frame.
…grace, and skips it with extensions

READER-12 #635-B1: an engine running extensions keeps Page.* events to itself, so the frame tracker never saw the new address and back/forward ran to the 15 s deadline. The tracker is now waited on only inside the fast settle (the 1.2 s grace still ends it), not at all when the engine runs extensions (BrowserHost::extensions_active), and the wait wakes at the grace while it holds.
…with extensions too

READER-12 #635-B2: an engine running extensions drops Page.* events but not Runtime.executionContextsCleared, which bumps the tab's generation when it lands; skipping the frame-tracker wait with extensions let back return before it, so the next command failed document_changed (seen on dev's #640 build with uBlock Origin Lite). back/forward now wait until the tab's generation moves past the one they started at, with or without extensions; without extensions the main frame's tracked URL moving on settles it too (a same-document entry clears no contexts). LOAD_SETTLE_GRACE still ends any wait.
…ount, not the tab generation

READER-12 #635-B3: the tab's generation also moves when sync_tabs sees the new address, before any DevTools event, and both the contexts clearing and the main frame navigating bump it. The frame tracker now counts the main frame's Runtime.executionContextsCleared and Page.frameNavigated; back/forward snapshot both and wait for the contexts to clear (with extensions, which drop Page.*), or for both (without), or, for a same-document entry, which sends neither, for the tracked address to move to the new one. LOAD_SETTLE_GRACE still ends any wait.
@Hona

Hona commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Parked as draft (ORCHESTRATOR, 22 Nov): #675 reverts #640's engine-message wake for the next release. This PR's settle logic will be rebuilt from a measured event order (a trace build: tab update, main Runtime.executionContextsCleared, Page.frameNavigated, Page.navigatedWithinDocument, frame-tree reply and first successful evaluate in the new document; back/forward/reload/same-document; four configurations; 20 runs each), not from reasoning. a9356bd (READER-12's counter design) is not for merge until then.

@Hona

Hona commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Superseded by #696 (the condition measured by the #676 trace; proof\browser-tools\order\track-b.md). Closing without merge.

@Hona Hona closed this Nov 22, 2026
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