[BUG]: Permission denied when I record audio in card's webview with javascript
Checked for duplicates?
- [x] This issue is not a duplicate
Does it also happen in the desktop version?
- [X] This bug does not occur in the latest version of Anki
What are the steps to reproduce this bug?
add script like this
<script>
let mediaRecorder;
console.log('ready to record...', navigator.mediaDevices)
navigator.mediaDevices.getUserMedia({ audio: true }).then(stream => {
mediaRecorder = new MediaRecorder(stream);
mediaRecorder.start();
mediaRecorder.ondataavailable = event => {
console.log('recording...',event.data)
}
})
// ...pause function...
// ...play function ...
</script>
Expected behaviour
runs ok without any mistakes.
Actual behaviour
js error:
Error starting recording:NotAllowdError:Permission denied
```
### Debug info
```text
AnkiDroid Version = 2.18beta1 (c12b398c216dc2a2c2e2c98709c92132d19d105c)
Backend Version = 0.1.38-anki24.04.1 (24.04.1 ccd9ca1a8309b80bcb50ddc5d99c7ce63440bce9)
Android Version = 14 (SDK 34)
ProductFlavor = full
Manufacturer = OnePlus
Model = PGZ110
Hardware = mt6895
Webview User Agent = Mozilla/5.0 (Linux; Android 14; PGZ110 Build/UKQ1.230924.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/124.0.6367.54 Mobile Safari/537.36
ACRA UUID = 01cf13f4-6ae8-4cbb-95ca-0c19f11b9417
FSRS Enabled = false
Crash Reports Enabled = true
```
### (Optional) Anything else you want to share?
this code snippet runs ok in other android app's webview.
### Research
- [X] I am reporting a bug specific to AnkiDroid (Android app)
- [X] I have checked the [manual](https://ankidroid.org/docs/manual.html) and the [FAQ](https://github.com/ankidroid/Anki-Android/wiki/FAQ) and could not find a solution to my issue
- [X] (Optional) I have confirmed the issue is not resolved in the latest alpha release ([instructions](https://docs.ankidroid.org/manual.html#betaTesting))
Hello! 👋 Thanks for logging this issue. Please remember we are all volunteers here, so some patience may be required before we can get to the issue. Also remember that the fastest way to get resolution on an issue is to propose a change directly, https://github.com/ankidroid/Anki-Android/wiki/Contributing
Did you give AnkiDroid microphone permission?
@david-allison yes, I did.
When I used "Check pronunciation" for the first time, AnkiDroid also required the microphone permission , I can record audio through "Check pronunciation" as expected after I gave the permission.
However,I can't record audio through pure javascript though I already gave AnkiDroid the permission .
Perhaps the permissions of a webView are different from those of the app itself?
~~@krmanik FYI~~
Whoops - not API related, sorry for the ping
Potentially: https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)
@snecker Could you export a card with this problem and attach it as a .zip