Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QML/Qt App, Camera, MacOs Mojave, Crash.



  • OK. Weird problem. My application just crashes when I run it "normally" via Qt Creator.

    To clarify. I have added a custom Info.plist that adds the NSCameraUsageDescription key.

    • If I run the app from the CLI e.g. "open qml_camera_test1.app" it will launch fine (on first launch I get the "do you want to let the app use the camera" spiel from MacOs)
    • If I execute $BLAH/build-qml_camera_test1-Desktop_Qt_5_12_0_clang_64bit-Debug/qml_camera_test1.app/Contents/MacOS/qml_camera_test1 on the terminal I get a message that the terminal would like to use the camera (WTF!) but the app still runs fine - although I now fear I've allowed the terminal unfettered access to the camera.
    • If I run the app via Apple+Y e.g. the debugger it runs fine.
    • If I Apple+R e.g. run from Qt Creator my app simply crashes.

    Any ideas please?



  • OK. I'm a little closer to sussing this out. What I'm saying here might not be true it's just my investigation.

    Running from the Terminal gave me my clue. When the camera app is launched from Terminal it is a child process of the Terminal. This is why I get a dialogue asking "Do you want to allow Terminal access to the camera".

    Under the debugger ANYTHING goes and I reckon macOS isn't checking a lot of privileges because, well, it's the debugger.

    When launched (Apple+R) from Creator I think the application is a child process of Qt Creator (or possibly the child or a child).

    Qt Creator does not have camera permissions so the OS just shuts down the offending application.

    Onwards and sideways.



  • Wow. That took some fiddling.

    • Make sure that Qt Creator has Camera permissions enabled under System Preferences -> Security & Privacy -> Privacy -> Camera
    • Shut down all instances of Qt Creator and then start again - macOS only seems to set these permissions on the app when it starts. The clue here was that when I changed the setting in sys prefs the OS asked me if I wanted to close the app now or later

    That's it. It seems to be working AOK - which has seriously improved my work flow!


Log in to reply