Skip to content

fix(cef): report page loads only for the webview's own page - #4

Merged
peterchinman merged 1 commit into
macro-cef-desktop-capturefrom
peterchinman/macro-6706-desktop-cef-page-load-handler-skip-browsers-the-webview-doesnt-own-and-the-placeholder-page
Nov 25, 2026
Merged

peterchinman merged 1 commit into
macro-cef-desktop-capturefrom
peterchinman/macro-6706-desktop-cef-page-load-handler-skip-browsers-the-webview-doesnt-own-and-the-placeholder-page

Conversation

@peterchinman

Copy link
Copy Markdown

Why

TauriCefLoadHandler::on_load_start and on_load_end fire Tauri's on_page_load for loads that are not the webview's own page, unlike every other handler on TauriCefBrowserClient:

  • The INITIAL_LOAD_URL placeholder. Every browser is created at this data: page before its real navigation (webview.rs). display.rs and request_handler.rs skip it; the load handler did not, so plugins saw a Started/Finished pair for a data: URL whose origin serializes to "null". This is the bug that is live on macOS.
  • Browsers the webview does not own. In a Chrome style browser, a DevTools window opened with F12 or Inspect is created with the opener's client (ChromeBrowserDelegate::CreateDevToolsBrowser), so its devtools:// page reached on_page_load as the webview's page. The display, command, life span and IPC paths already check has_browser_id. On macOS this does not happen today: browsers are Alloy style there, which has no F12 accelerator and no Inspect entry, and show_dev_tools(None, ...) creates the DevTools browser without a client. The check is kept for Windows and Linux and to match the other handlers.

What

  • TauriCefLoadHandler takes the webview's FrameNavigationState.
  • Both callbacks report a load only for the main frame of the owned browser and never for INITIAL_LOAD_URL, through one reports_page_load predicate.
  • on_load_start still emits DocumentCommitted for every commit before the check, so the frame observer is unchanged and the browser identity is bound before it is read.
  • Unit tests cover the owned main frame, an unowned browser, an unbound state, the placeholder and subframes.

Stacked on macro-cef-desktop-capture (macro-cef plus 4b8a46f, the commit Macro pins), so this diff is only the fix.

TauriCefLoadHandler fired Tauri's on_page_load for two kinds of load that
are not the webview's page:

- The INITIAL_LOAD_URL placeholder every browser is created at before its
  real navigation. The display and request handlers already skip it.
- Browsers the webview does not own. CEF routes a DevTools window opened
  with F12 or Inspect in a Chrome style browser through the opener's
  client; every other handler on the client checks has_browser_id.

Plugins that read on_page_load saw a data: URL, or a DevTools page, as the
webview's current page. Both on_load_start and on_load_end now require the
main frame of the owned browser and skip the placeholder. The frame
observer still sees every commit.
@macro-application

Copy link
Copy Markdown

@peterchinman
peterchinman merged commit 30e735a into macro-cef-desktop-capture Nov 25, 2026
12 of 18 checks passed
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