DioxusLabs / DioxusLabs/dioxus

`getUserMedia()` Fails on Linux Desktop (`NotAllowedError`) due to missing Wry Permission Handler

Open
#5,037 1 comment 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
39.1k
Forks
1.9k
Avg merge
4d 10h
Merged PRs (30d)
4

Description

### Dioxus Version
Observed in `0.7.1`

### OS
Linux (specifically tested on distributions using WebKitGTK as the Wry backend).

### Description

When developing a Dioxus Desktop application on Linux that requires camera access via JavaScript's `navigator.mediaDevices.getUserMedia()`, the request consistently fails with a `NotAllowedError`.

This occurs because the underlying WebKitGTK engine used by Wry defaults to denying media permissions unless the host application (Dioxus/Wry) explicitly grants the request via a `PermissionRequestHandler`.

Since the Dioxus API currently does not expose the necessary configuration hooks to inject a Wry/WebView permission handler, Linux developers are forced into two undesirable situations:
1. The camera function breaks entirely on Linux.
2. Developers must use slower, more complex native Rust camera capture solutions (`nokhwa`, `image`, `rqrr`) **only** for the Linux target, sacrificing the performance and simplicity of the unified WebView approach used for Windows, macOS, and Web/Mobile.

### Steps to Reproduce

1. Create a Dioxus Desktop application targeting Linux.
2. In an `App` component, use `document::eval` to execute `navigator.mediaDevices.getUserMedia({ video: true })`.
3. Run the application on a Linux machine (`cargo run --features desktop`).

### Expected Behavior

The JS promise should resolve, or a system permission dialog should appear, allowing camera access.

### Actual Behavior

The JavaScript promise is rejected immediately with the platform-specific error:

```
NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission.
```

### Proposed Solution

To maintain the promise of a unified codebase and ensure functionality across all desktop platforms, this issue needs to be addressed at the Dioxus configuration layer.

The ideal solution is to expose a mechanism to configure the underlying WebView's permission handling:

1. **Expose a `PermissionRequestHandler` Hook:** Allow users to define a custom handler via `dioxus::desktop::Config` that maps directly to Wry's `with_permissions_request_handler`.
OR
2. **Default to Allowing Media:** Since camera/mic access is often the core reason for using `getUserMedia` in desktop apps, Dioxus could internally configure the Wry builder for Linux targets to default to granting permissions for media requests (`allow()` for `MediaDevice`), thereby making media access functional out-of-the-box.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.