Skip to content

Comments

feat: expose wry permission handler API in tauri#14865

Open
F0RLE wants to merge 1 commit intotauri-apps:devfrom
F0RLE:feat/permission-handler
Open

feat: expose wry permission handler API in tauri#14865
F0RLE wants to merge 1 commit intotauri-apps:devfrom
F0RLE:feat/permission-handler

Conversation

@F0RLE
Copy link

@F0RLE F0RLE commented Jan 31, 2026

Summary

This PR exposes the wry permission handler API through Tauri's public interface, enabling applications to programmatically handle permission requests from the webview.

Motivation

Currently, certain web APIs like getDisplayMedia() on Linux (via WebKitGTK) fail because they require an explicit permission grant that cannot be handled by the default webview behavior. This results in "NotAllowedError" or "Screen sharing was cancelled" errors.

By exposing on_permission_request, developers can intercept these requests and provide the necessary Allow or Deny response programmatically. This is essential for building screen sharing, video conferencing, and other permission-sensitive features in Tauri apps.

Changes

  • tauri-runtime: Added PermissionKind (mirroring wry) and PermissionResponse enums. Added DisplayCapture to support screen sharing.
  • tauri-runtime-wry: Implemented the permission handler integration in create_webview, mapping runtime types to wry types.
  • tauri: Added on_permission_request method to WebviewBuilder and WebviewWindowBuilder as a public API.

Dependencies

This PR depends on the changes in tauri-apps/wry#1654.

Example Usage

tauri::WebviewWindowBuilder::new(app, "main", tauri::WebviewUrl::App("index.html".into()))
  .on_permission_request(|_webview, kind| {
    match kind {
      tauri::webview::PermissionKind::DisplayCapture => tauri::webview::PermissionResponse::Allow,
      tauri::webview::PermissionKind::Microphone => tauri::webview::PermissionResponse::Allow,
      _ => tauri::webview::PermissionResponse::Default,
    }
  })
  .build()?;

@F0RLE F0RLE requested a review from a team as a code owner January 31, 2026 22:47
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Jan 31, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Feb 1, 2026

Package Changes Through 5662578

There are 9 changes which include tauri with minor, @tauri-apps/cli with minor, tauri-cli with minor, tauri-utils with patch, tauri-build with patch, tauri-macos-sign with patch, tauri-bundler with minor, tauri-runtime-wry with minor, tauri-runtime with minor

Planned Package Versions

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

package current next
tauri-utils 2.8.1 2.8.2
tauri-macos-sign 2.3.2 2.3.3
tauri-bundler 2.7.5 2.8.0
tauri-runtime 2.9.2 2.10.0
tauri-runtime-wry 2.9.3 2.10.0
tauri-codegen 2.5.2 2.5.3
tauri-macros 2.5.2 2.5.3
tauri-plugin 2.5.2 2.5.3
tauri-build 2.5.3 2.5.4
tauri 2.9.5 2.10.0
@tauri-apps/cli 2.9.6 2.10.0
tauri-cli 2.9.6 2.10.0

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


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

@F0RLE
Copy link
Author

F0RLE commented Feb 1, 2026

This PR depends on tauri-apps/wry#1654. CI will fail until that PR is merged and a new wry version is released.

@F0RLE F0RLE force-pushed the feat/permission-handler branch from 5662578 to 3a3f629 Compare February 20, 2026 17:33
Exposes the with_permission_handler API from wry through Tauri's public
interface, allowing Tauri applications to programmatically handle webview
permission requests.

New public types in 	auri-runtime:
- PermissionKind - 17 variants matching wry's API, with Hash and Display.
  Display uses kebab-case (e.g. display-capture, pointer-lock).
- PermissionResponse - Allow, Deny, Default (default), Prompt. With Hash.

WebviewBuilder::on_permission_request accepts a closure called whenever
the webview requests a browser permission (media, geolocation, etc.).

Platform support mirrors wry:
- Windows (WebView2): Full coverage of all 12 permission kinds.
- macOS / iOS (WKWebView): Camera and microphone, secure Default behavior.
- Linux (WebKitGTK): UserMedia, Geolocation, Notifications, PointerLock.
  DisplayCapture fallback for WebKitGTK < 2.42.
- Android: Experimental support via JNI bridge.

Signed-off-by: F0RLE <lrshka.klim7766@gmail.com>
@F0RLE F0RLE force-pushed the feat/permission-handler branch from 5db0f39 to 7bc20f4 Compare February 20, 2026 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

1 participant