$ show tauri-apps/wry
wry is a production-grade Rust library that provides a unified API to embed webviews across Windows (WebView2), macOS/iOS (WKWebView), Linux (WebKitGTK), and Android (WebView). It serves as the core webview component for the Tauri framework, enabling desktop and mobile applications with hybrid UIs. The architecture uses platform-specific backends selected via conditional compilation, all exposing a consistent interface through the `WebViewBuilder` and `WebView` types. The library supports custom protocols, synchronous and asynchronous IPC between Rust and JavaScript, drag-and-drop, permission handling, download management, proxy configuration, transparent backgrounds, and GPU rendering (wgpu, OpenGL). The codebase demonstrates strong engineering practices: a clear builder pattern, comprehensive error handling (including platform-specific error variants), performance benchmarks (binary size, memory, syscalls), and extensive CI covering multiple OS/architecture targets. Mobile support requires environment variables for Android and a `cargo-mobile2` bootstrap for iOS. The library is actively maintained with frequent releases and dependency updates, though it has a high MSRV (1.85) and some security audit ignores due to toolchain constraints.
The LLM identified 2 files worth highlighting for reuse:
Provides a thread-safe message queue (`MainPipe`) for communication between the Rust JNI thread and the Android main thread. Handles commands (`CreateWebView`, `Eval`, `LoadUrl`, etc.) sent as enum variants serialized via a pipe. The pattern is reusable for any Android library that needs to process asynchronous commands from Rust to Java/Kotlin, offering a clean separation of concerns and avoiding global mutable state.
Implements a URI rewriting mechanism to support custom protocols on Windows and Android, where native custom protocol registration is limited or behaves differently. The `rewrite_uri` function transforms incoming request URIs (e.g., `http://wry.localhost/...`) into a form that the platform's WebView can handle correctly. This pattern demonstrates a non-obvious workaround for cross-platform quirks and can be extracted for other projects requiring custom URI schemes with limited platform support.