I try to develop add-ons to use the webcam in Anki for desktop.
It is already working fine on Windows and Linux, but on Mac I cannot display the screen or encounter crashes. Like this:
I’ve looked into the cause, it looks like Macs are security-conscious and apps need to be set up with camera permissions in advance, and Anki probably doesn’t allow this. (But I have not built Anki so I do not know if this is the exact cause or not).
For now a workaround is to start Anki from the terminal. The user can give permission for the camera to the terminal and the add-on will work fine.
If so, this change does not seem to be possible with add-on. Are there any plans to allow the use of the camera in Anki for Mac?
This is a minimal add-on for reproducing the problem. Use Qt5 or Qt6 to display the webcam video. If a crash occurs, you need to press Shift to restart Anki and disable the add-on:
As a heads up: I tested your addon in debian linux (oldstable) with gnome and anki doesn’t even ask for camera permission here. Your addon thus doesn’t work for me, I only get a blank white screen.
I tested it on Ubuntu 24 and it was giving me the same problem as the guy above, with the white screen, but I remembered that I installed Anki with Flatpak there
so I had to use these 2 commands in the terminal to make it work on Linux Ubuntu
sudo flatpak override net.ankiweb.Anki --device=all
flatpak install flathub com.github.tchx84.Flatseal
Thanks! That’s very helpful. I’m a little concerned about security if the user allows everything, so it looks like it would be good to have a code to allow only the camera and a code to revoke the permission. I’ll look into it later.
When I typed this into the terminal and started Anki, a popup automatically appeared asking if I wanted to allow the camera. /Applications/Anki.app/Contents/MacOS/anki
After that privacy & security will show that I have allowed the terminal. Until the popup is shown, nothing is displayed in privacy & security.
This only worked on my debugging device, so it has not been tested to work on other Mac devices.
Thanks for testing!
Would it be possible to add that change as is to the plist and have it included in the next Anki for desktop? If there is something wrong with the current test add-on code or camera connection setting, it may work fine if I fix the add-on code.