Skip to content

Prepare WebView callbacks for Send and Sync - #5501

Merged
Kenny Kerr (kennykerr) merged 1 commit into
masterfrom
webview-owner-threading
Nov 25, 2026
Merged

Kenny Kerr (kennykerr) merged 1 commit into
masterfrom
webview-owner-threading

Conversation

@kennykerr

Copy link
Copy Markdown
Collaborator

Make WebView callbacks non-agile and keep captures on their owning STA, with assertions for thread-affinity violations. No dispatcher or new locking; public callback signatures stay the same.

Includes the nested #[implement] hygiene fix needed by the adapters and native lifetime regressions. Prepares WebView for #5469; the global Send + Sync bound remains separate.

Copilot AI 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.

🔵 Needs a closer look

The unsafe Send/Sync adapter depends on STA marshaling, owner-thread release, and COM shutdown behavior requiring human validation because Windows/WebView2 and Reactor runtime regressions could not be executed here.

No open issues 🎉

What changed in this PR

Prepares windows-webview for the proposed Send + Sync requirement in #5469 while preserving public callback signatures. The global bound remains outside this PR.

Changes:

  • Makes callback adapters non-agile and adds checks that captures are accessed and destroyed on their owning single-threaded COM apartment.
  • Fixes identifier hygiene for nested #[implement] macro expansion.
  • Adds callback lifetime, cross-apartment, and Reactor teardown regressions, plus COM lifetime documentation.
File Description
crates/​tools/​webview/​src/​webview.txt Adds apartment-query APIs and constants to binding inputs.
crates/​tests/​libs/​webview/​src/​registry.rs Registers the native callback lifetime fixture.
crates/​tests/​libs/​webview/​src/​main.rs Drops the harness before checking live-object diagnostics.
crates/​tests/​libs/​webview/​src/​fixtures/​mod.rs Includes the callback lifetime fixture module.
crates/​tests/​libs/​webview/​src/​fixtures/​callback_lifetime.rs Tests native callback invocation and capture destruction.
crates/​tests/​libs/​reactor/​tests/​ui/​main.rs Runs the WebView ownership fixture.
crates/​tests/​libs/​reactor/​src/​webview.rs Tests callback ownership through Reactor window teardown.
crates/​tests/​libs/​reactor/​src/​lib.rs Registers the Reactor WebView fixture.
crates/​tests/​libs/​reactor/​readme.md Documents the WebView callback fixture.
crates/​tests/​libs/​reactor/​Cargo.toml Adds WebView with Reactor integration for testing.
crates/​tests/​libs/​implement/​tests/​query.rs Adds nested-macro interface-query coverage.
crates/​libs/​webview/​src/​webview.rs Propagates callback creation errors before registration.
crates/​libs/​webview/​src/​protocol.rs Guards resource-handler state with owner-thread checks.
crates/​libs/​webview/​src/​profile.rs Propagates browsing-data callback creation errors.
crates/​libs/​webview/​src/​owner.rs Introduces checked owner-thread storage and unit tests.
crates/​libs/​webview/​src/​options.rs Propagates environment callback creation errors.
crates/​libs/​webview/​src/​lib.rs Includes the owner-thread module.
crates/​libs/​webview/​src/​handler.rs Converts adapters and adds threading and lifetime regressions.
crates/​libs/​webview/​src/​environment.rs Propagates environment and controller callback creation errors.
crates/​libs/​webview/​src/​cookie.rs Propagates cookie callback creation errors.
crates/​libs/​webview/​src/​controller.rs Propagates controller and focus callback creation errors.
crates/​libs/​webview/​src/​bindings.rs Adds generated COM apartment-query bindings.
crates/​libs/​webview/​readme.md Documents COM initialization and object teardown requirements.
crates/​libs/​webview/​Cargo.toml Enables procedural macros for callback implementations.
crates/​libs/​implement/​src/​gen.rs Aligns generated identifier spans for nested macro expansion.

Review effort: Balanced

@kennykerr
Kenny Kerr (kennykerr) merged commit 631f9de into master Nov 25, 2026
51 checks passed
@kennykerr
Kenny Kerr (kennykerr) deleted the webview-owner-threading branch November 25, 2026 23:07
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.

2 participants