Skip to content

feat: Add macOS WebView debugging documentation and plugin support#7

Open
billy-and-the-oceans wants to merge 1 commit intodirvine:mainfrom
billy-and-the-oceans:feature/macos-native-webview-support
Open

feat: Add macOS WebView debugging documentation and plugin support#7
billy-and-the-oceans wants to merge 1 commit intodirvine:mainfrom
billy-and-the-oceans:feature/macos-native-webview-support

Conversation

@billy-and-the-oceans
Copy link
Copy Markdown

Summary

This PR adds documentation and code hints to help macOS users with WebView debugging, since WKWebView doesn't expose Chrome DevTools Protocol (CDP).

Problem

On macOS:

  • WKWebView uses Safari Web Inspector via private XPC (webinspectord)
  • No public API exists for programmatic WebKit debugging
  • execute_js and take_screenshot fail because no CDP port is found

Solution

We created tauri-plugin-native-webview which provides IPC commands that work around this limitation:

Plugin Command Description
plugin:native-webview|snapshot Native WKWebView screenshot (works when hidden)
plugin:native-webview|eval_js Execute JS with return values
plugin:native-webview|debug_info Get window state

Changes

  • README.md: Added comprehensive "macOS WebView Debugging" section with:

    • Installation instructions for the plugin
    • Usage examples via call_ipc_command
    • Feature comparison table
  • src/tools/debug.rs:

    • Updated find_debug_port error message to guide users to plugin on macOS
    • Added suggest_native_plugin() helper for future auto-detection
  • src/tools/window.rs:

    • Added docstring noting plugin alternative for hidden screenshots
    • Enhanced error message with plugin suggestion on macOS

Plugin Repository

The plugin source is at: https://github.com/fuwa-cloud/tauri-plugin-native-webview

(Will be published to crates.io)

Testing

  • Built and tested on macOS 14.x
  • Plugin tested with Bamba (Visual MIDI DAW) on Tauri v2.9.5
  • Native snapshot works when window is minimized/hidden

Test plan

  • Build passes on macOS
  • README documentation renders correctly
  • Error messages are helpful when CDP isn't available
  • Integration test with plugin-enabled app (manual)

🤖 Generated with Claude Code

On macOS, WKWebView doesn't expose Chrome DevTools Protocol (CDP),
which means execute_js and screenshot tools don't work. This commit:

- Adds comprehensive documentation in README about the tauri-plugin-native-webview
  solution for macOS WebView debugging
- Updates error messages in debug.rs to guide users to the plugin when CDP fails
- Adds docstring hints in window.rs about using the plugin for hidden screenshots
- Adds suggest_native_plugin() helper for future auto-detection

The plugin provides:
- Native WKWebView screenshots (works when window is hidden)
- JS evaluation with return values via IPC
- Debug info via Tauri APIs

Users can use call_ipc_command with plugin commands:
- plugin:native-webview|snapshot
- plugin:native-webview|eval_js
- plugin:native-webview|debug_info

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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