Skip to content

fix(webkitgtk): only inject IPC bridge with handler - #1839

Merged
Legend-Master merged 2 commits into
tauri-apps:devfrom
zackees:fix/conditional-ipc-bridge
Sep 29, 2026
Merged

Legend-Master merged 2 commits into
tauri-apps:devfrom
zackees:fix/conditional-ipc-bridge

Conversation

@zackees

@zackees zackees commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

The WebKitGTK backend conditionally registered the native IPC handler, but unconditionally injected the browser-facing window.ipc bridge. This leaves a browser-visible host bridge on webviews that intentionally configure no IPC handler.

This makes script injection conditional on the same IPC-handler configuration and adds a focused regression test.

Coordinated with forge-ci/kernal-api#18 and tauri-apps/tauri#16010.

@github-actions

github-actions Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Package Changes Through 7546f15

There are 1 changes which include wry with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
wry 0.57.0 0.57.1

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@Legend-Master Legend-Master left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/webkitgtk/mod.rs Outdated
Comment on lines +66 to +70
const IPC_INIT_SCRIPT: &str = "Object.defineProperty(window, 'ipc', { value: Object.freeze({ postMessage: function(x) { window.webkit.messageHandlers['ipc'].postMessage(x) } }) })";

fn ipc_init_script(ipc_enabled: bool) -> Option<&'static str> {
ipc_enabled.then_some(IPC_INIT_SCRIPT)
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is much more added complexity than needed, let's keep it simple by removing this and the tests. Just keep the ipc_handler.is_some check is enough.

@zackees
zackees force-pushed the fix/conditional-ipc-bridge branch 2 times, most recently from 9582740 to 8a00ed6 Compare September 16, 2026 15:59
@zackees

zackees commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

It's been signed

@zackees

zackees commented Sep 18, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review! Both requests are addressed:

  • Removed the IPC_INIT_SCRIPT const, ipc_init_script() helper, and the tests — it's now just the ipc_handler.is_some() check (763bd6c).
  • All commits on the branch are signed.

@zackees
zackees force-pushed the fix/conditional-ipc-bridge branch from 763bd6c to 15a6309 Compare September 18, 2026 20:44
@Legend-Master
Legend-Master merged commit cab3eac into tauri-apps:dev Sep 29, 2026
20 checks passed
Ranrar added a commit to Ranrar/wry that referenced this pull request Oct 20, 2026
Sync with upstream dev (926dd15, 14 commits). Linux-related upstream
fixes are ported to the gtk4/webkit6 backend:

- webkitgtk: log script eval errors under the `tracing` feature (tauri-apps#1868),
  adapted from run_javascript to webkit6 evaluate_javascript for both
  pending init scripts and eval()
- webkitgtk: keep a separate failure flag for each download (tauri-apps#1893),
  moved inside NetworkSession::connect_download_started
- webkitgtk: only inject the window.ipc bridge when an IPC handler is
  set (tauri-apps#1839)

Conflict resolution:
- bench/tests/Cargo.toml: keep winit + gtk4 deps instead of upstream's
  tao 0.37 bump (tao pulls in gtk3)
- webview2: combine sync imports (Arc, AtomicBool) with upstream's
  once_cell -> std LazyLock migration (tauri-apps#1861)
- webkitgtk/{mod,web_context}.rs: keep gtk4/webkit6 code over upstream
  edits to the gtk3/webkit2gtk code

Android, macOS and CI changes merged without conflicts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants