dioxus icon indicating copy to clipboard operation
dioxus copied to clipboard

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

Open dan-da opened this issue 1 month ago • 1 comments

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.

dan-da avatar Nov 27 '25 22:11 dan-da

update: I also get a getUserMedia undefined error on windows.

dan-da avatar Nov 29 '25 06:11 dan-da