WebView Quirks
Initial Response
When this skill is first invoked without a specific question, respond only with:
Ready to chase an engine difference. Tell me what breaks and on which OS.
A Tauri app is not one browser. It is three engines: WKWebView (Safari's engine) on macOS, WebView2 (Chromium) on Windows, WebKitGTK on Linux. "It works in Chrome DevTools" says only that it works on Windows.
Electron ships one Chromium on every OS, so the engine rules (WQ-01 to WQ-06, WQ-12, WQ-13's engine part) don't apply there. The build and dev-server rules (WQ-07 to WQ-10) and WQ-11 do.
Hard Rules
- Name the engine before fixing. Get the OS and engine (user agent from the diagnostic snippet) before changing code.
- Feature-detect, never sniff.
@supports,"x" in window,CSS.supports(). Platform branches only for shell-level differences, and from the shell's platform API. - Fix the cause on the engine that needs it. A Linux-only rendering workaround must not degrade macOS and Windows.
The Symptom Table
| Problem | Solution | Rule |
|---|---|---|
| Works on one OS only | Test plan per engine | WQ-01 |
| Blur/filters crawl on Linux | Drop or reduce on WebKitGTK | WQ-02 |
| Blank window or crash on Linux | DMABUF workaround | WQ-03 |
| Drag-and-drop sorting dead on Windows | Turn off shell file-drop handling | WQ-04 |
| Timers or animations stop in hidden windows | Background throttling policy | WQ-05 |
| API missing on macOS only | Feature-detect, polyfill | WQ-06 |
| Build fails with "window is not defined" | No browser globals at module scope | WQ-07 |
| API routes / image optimization missing in the build | Static bundle only | WQ-08 |
| The dev window opens blank | The URL the shell loads is fixed | WQ-09 |
| Dev server reloads during every Rust build | Ignore src-tauri/target | WQ-10 |
| Window focus/size logic wrong | Ask the shell | WQ-11 |
| Odd WebView2 behavior after adding browser arguments | Keep the default flags | WQ-12 |
| Dark mode ignored or half-applied on Linux | Don't trust the media query alone | WQ-13 |
The Fixes
WQ-01 Test in every engine
Minimum: macOS (WKWebView), Windows (WebView2), and the Linux distribution you support (WebKitGTK version matters). Safari Technology Preview approximates WKWebView; it is not the same as running the app.
WQ-02 Blur and filters on Linux
WebKitGTK has run filter: blur() and filter animations through slow CPU paths (WebKit bugs 240865, 252948, 264966); large blurs can drop to seconds per frame. On Linux: remove decorative blur, animate opacity instead of filter: opacity(), and replace backdrop-filter with a solid translucent color.
:root[data-platform="linux"] .glass { backdrop-filter: none; background: var(--panel-bg); }
Set data-platform from the shell's platform API at startup.
WQ-03 Linux rendering workaround
On some Linux GPU/driver combinations, WebKitGTK's DMABUF renderer shows a blank window or crashes. The documented workaround is the environment variable WEBKIT_DISABLE_DMABUF_RENDERER=1, at the cost of the faster path. Apply it only on Linux (launcher script or std::env::set_var before the builder runs) and only if users hit it. See Tauri's "Linux graphics issues" page.
WQ-04 HTML5 drag and drop on Windows
When the shell handles file drops (dragDropEnabled, on by default), HTML5 drag and drop inside the page doesn't work on Windows. If the UI uses HTML5 DnD (sortable lists, kanban), turn it off for that window and handle dropped files with the HTML5 API instead:
{ "app": { "windows": [{ "dragDropEnabled": false }] } }
Turning it off hands OS file drops back to the engine, which opens the dropped file in the window unless the page guards against it. Add the document-level drop guard from DN-23 at the same time.
WQ-05 Background throttling
Engines throttle timers and requestAnimationFrame in hidden or minimized windows; WKWebView can suspend the view entirely after a few minutes. If work must continue while hidden (a timer, a recording, a sync), move it to Rust. Tauri's backgroundThrottling window policy changes this on macOS only; it is unsupported on Windows and Linux, so it can't be the whole fix.
WQ-06 Late APIs on macOS
WKWebView follows Safari's release schedule and the user's macOS version. Check support for the oldest macOS you ship, feature-detect, and provide a fallback.
WQ-07 No browser globals at module scope
SSG/SSR-capable frameworks (Next.js, React Router, Start, Astro, SvelteKit) prerender in Node. Top-level window, document or @tauri-apps/api usage throws at build time. Access them inside effects/onMount, or await import() them.
WQ-08 Static bundle only
Tauri serves files; there is no server. SSR, API routes, server actions, ISR and next/image optimization don't exist. Next.js needs output: "export" and images.unoptimized: true. Server logic moves to Rust commands.
WQ-09 The URL the shell loads is fixed
In development the shell loads one fixed URL: Tauri's build.devUrl, or whatever Electron's main process passes to loadURL. If the dev server behind that URL picks another port because the default is taken, the window opens blank. Fix that server's port and make it fail instead of moving (strictPort: true in Vite).
This rule is only about the server the shell actually loads. Find it first: in Electron, read the loadURL call. A dev server the shell never opens (a web-only preview, a frontend served by a local daemon) is not a finding.
WQ-10 Ignore the Rust build in the dev watcher
server: { watch: { ignored: ["**/src-tauri/target/**"] } }
WQ-11 Ask the shell
document.hasFocus(), screen.* and devicePixelRatio describe the web view, not the native window (focus across native windows, monitor scale, fullscreen state). Use the shell's window API for window decisions.
WQ-12 Keep the default browser arguments
On Windows, Tauri starts WebView2 with --disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection. Setting additionalBrowserArgs replaces that string, so those Edge features come back. Merge your flags into the defaults instead of replacing them:
{
"app": {
"windows": [{
"additionalBrowserArgs": "--disable-features=msWebOOUI,msPdfOOUI,msSmartScreenProtection,YourFeature --your-flag"
}]
}
}
Put all disabled features in one --disable-features list. Webviews with different browser arguments must also use different data directories. Windows only.
WQ-13 Linux dark mode
On Linux, prefers-color-scheme doesn't reliably follow the GTK or desktop dark setting, and WebKitGTK only draws dark form controls for pages that declare color-scheme (DN-17). An app that themes only from the media query can stay light on a dark desktop, or end up with dark pages and light controls.
- Declare
color-schemeonhtmlfor both themes (DN-17). - Offer a Light / Dark / System theme setting in the app, so Linux users can fix it themselves.
- For System, read the theme from the shell (
getCurrentWindow().theme()andonThemeChanged()in Tauri) and fall back to the media query. Verify on GNOME and KDE with the dark setting on; shell theme support on Linux depends on the desktop.
Output
| Rule | File | Change | Verified |
|---|
Engine issues are verified on the engine. Say which OS each fix still needs.