-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
media permission denied [bug] #4434
Comments
please share the full |
start script:
1、open media -> select reject -> console.log(err); 2、open media -> console.log(err); Immediate failure. Unable to reacquire permissions. Permission can be reset in the edge browser. But webview2 can`t. Reset site permissions in edge browser. |
users can delete |
I don't think that is a proper solution, it certainly isn't user-friendly to request the user to do the above to reset permission state. |
@Interpause You can handle that for your users in rust too. Edit: Since this issue was just linked to from a really extensive issue a short additional note: In case someone wonders why we don't work around the missing permissions api by hooking into the PermissionRequested event (which by itself would be kinda annoying imo), the reason is: it doesn't work, see MicrosoftEdge/WebView2Feedback#2672 |
Hello, we recently added the new experimental Permission Management APIs. Can you check if this meets your needs? MicrosoftEdge/WebView2Feedback#2427 (comment) Thanks! |
Hi @FabianLars , now that both of those WebView2Feedback issues have been resolved and the Permission Management APIs have been released, is it possible to hook into these APIs to reset permission state while the WebView2 app is open? The Rust solution won't work for us, as we can't expect our users to close down the app and delete the EBWebView directory themselves. |
if you're using v2, yes (in v1 the webview bindings are too old). Then you can use the mentioned SetPermissionState in with_webview (via the bindings). If all this is new to you, it would look something like this, just to get a feel for it. |
I also have OCD, it took me several days to find it tauri version v2 use webview2_com::Microsoft::Web::WebView2::Win32::{
ICoreWebView2Profile4, ICoreWebView2_13, COREWEBVIEW2_PERMISSION_KIND_MICROPHONE,
COREWEBVIEW2_PERMISSION_STATE_DEFAULT,
};
use windows::core::{Interface, PCWSTR};
/**
*
* Reset microphone permissions
*/
#[tauri::command]
fn reset_permission(origin: &str, app: AppHandle) {
let webview = app.get_webview_window("main").unwrap();
let mut origin = origin.to_string();
origin.push('\0');
let origin = origin.encode_utf16().collect::<Vec<u16>>();
webview
.with_webview(move |webview| unsafe {
let core = webview.controller().CoreWebView2().unwrap();
let core = Interface::cast::<ICoreWebView2_13>(&core).unwrap();
let profile = core.Profile().unwrap();
let profile = Interface::cast::<ICoreWebView2Profile4>(&profile).unwrap();
let origin = PCWSTR::from_raw(origin.as_ptr());
profile
.SetPermissionState(
COREWEBVIEW2_PERMISSION_KIND_MICROPHONE,
origin,
COREWEBVIEW2_PERMISSION_STATE_DEFAULT,
None,
)
.unwrap();
})
.unwrap();
} |
@WeiChens Thank you very much 😊 In my case I used For completeness sake: await invoke('reset_permission', { origin: window.origin });
const devices = await navigator.mediaDevices.enumerateDevices();
console.log('Weeeee', devices); |
@WeiChens cannot find type |
Import it then, your code editor should hopefully do it for you. |
@FabianLars thank u for response, i already fix this yesterday using Info.plist params without code rust |
Describe the bug
Unable to call camera,unauthorized.
No related items found in devtools.
Reproduction
No response
Expected behavior
No response
Platform and versions
Stack trace
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: