Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Problem with Camera component on macOS 10.14.2
Forum Updated to NodeBB v4.3 + New Features

Problem with Camera component on macOS 10.14.2

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
13 Posts 4 Posters 3.5k Views 4 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Cyrille de Brebisson
    wrote on 31 Jan 2019, 14:17 last edited by
    #1

    Hello,

    QT v 5.12.1
    I have a project with a "Camera" component.
    I have updated my os to the latest MacOS 10.14.2.

    Since then, my app crashes at startup time. If I comment out the Camera definition line in my qml code:

    Camera { id: camera; deviceId: "nocamera";  }
    

    Then the app does NOT crash at startup time...

    Do you have any idea what might be going wrong here?

    Thanks,
    Cyrille

    J 1 Reply Last reply 31 Jan 2019, 14:22
    0
    • C Cyrille de Brebisson
      31 Jan 2019, 14:17

      Hello,

      QT v 5.12.1
      I have a project with a "Camera" component.
      I have updated my os to the latest MacOS 10.14.2.

      Since then, my app crashes at startup time. If I comment out the Camera definition line in my qml code:

      Camera { id: camera; deviceId: "nocamera";  }
      

      Then the app does NOT crash at startup time...

      Do you have any idea what might be going wrong here?

      Thanks,
      Cyrille

      J Offline
      J Offline
      J.Hilk
      Moderators
      wrote on 31 Jan 2019, 14:22 last edited by
      #2

      Hi @Cyrille-de-Brebisson

      question, did you add the camera permission to your info.plist ?

      Do you get any feedback from QtCreator/ the console?


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      1 Reply Last reply
      0
      • C Offline
        C Offline
        Cyrille de Brebisson
        wrote on 31 Jan 2019, 14:28 last edited by Cyrille de Brebisson
        #3

        Hello,

        Nope, I have not added anything anywhere (besides multimedia in my QT line).
        I am not getting any warnings or anything from QT creator/console.

        I am more of a windows programmer and have no idea what an info.plist is :-)

        Where/how do I do this?

        Thanks
        Cyrille

        J 1 Reply Last reply 31 Jan 2019, 14:40
        0
        • C Cyrille de Brebisson
          31 Jan 2019, 14:28

          Hello,

          Nope, I have not added anything anywhere (besides multimedia in my QT line).
          I am not getting any warnings or anything from QT creator/console.

          I am more of a windows programmer and have no idea what an info.plist is :-)

          Where/how do I do this?

          Thanks
          Cyrille

          J Offline
          J Offline
          J.Hilk
          Moderators
          wrote on 31 Jan 2019, 14:40 last edited by
          #4

          @Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:

          Hello,

          Nope, I have not added anything anywhere (besides multimedia in my QT line).
          I am not getting any warnings or anything from QT creator/console.

          I am more of a windows programmer and have no idea what an info.plist is :-)

          My condolences ;-)

          Take a look here more or less mandatory read from apple for MacOS/iOS developer

          https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html

          When creating a Mac-app and qmake is run, an Info.plist file is generated with appropriate default values

          If permission for camera is not set inside that, your application may crash.

          Take a look at this part of the docu:
          http://doc.qt.io/qt-5/ios-platform-notes.html

          Those are notes for iOS but they should be more or less identical for MacOS development/management of Info.plist


          Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


          Q: What's that?
          A: It's blue light.
          Q: What does it do?
          A: It turns blue.

          C 1 Reply Last reply 31 Jan 2019, 14:50
          0
          • J J.Hilk
            31 Jan 2019, 14:40

            @Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:

            Hello,

            Nope, I have not added anything anywhere (besides multimedia in my QT line).
            I am not getting any warnings or anything from QT creator/console.

            I am more of a windows programmer and have no idea what an info.plist is :-)

            My condolences ;-)

            Take a look here more or less mandatory read from apple for MacOS/iOS developer

            https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Introduction/Introduction.html

            When creating a Mac-app and qmake is run, an Info.plist file is generated with appropriate default values

            If permission for camera is not set inside that, your application may crash.

            Take a look at this part of the docu:
            http://doc.qt.io/qt-5/ios-platform-notes.html

            Those are notes for iOS but they should be more or less identical for MacOS development/management of Info.plist

            C Offline
            C Offline
            Cyrille de Brebisson
            wrote on 31 Jan 2019, 14:50 last edited by
            #5

            @J.Hilk said in

            My condolences ;-)
            For being a windows programmer, or for having to work on mac :)

            I will be reading the documentation....

            It would be great if things like that could be automated in QT creator in the future!

            Have a good day,
            Cyrille

            J 1 Reply Last reply 31 Jan 2019, 14:56
            0
            • C Cyrille de Brebisson
              31 Jan 2019, 14:50

              @J.Hilk said in

              My condolences ;-)
              For being a windows programmer, or for having to work on mac :)

              I will be reading the documentation....

              It would be great if things like that could be automated in QT creator in the future!

              Have a good day,
              Cyrille

              J Offline
              J Offline
              J.Hilk
              Moderators
              wrote on 31 Jan 2019, 14:56 last edited by
              #6

              @Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:

              @J.Hilk said in

              My condolences ;-)

              For being a windows programmer, or for having to work on mac :)

              I would say for being a Windows programmer, but that would be hypocrisy, most of my work is done from a windows PC as well.
              But the change from Windows to Mac can be rought, but very few want to go back to Windows, once they have roughly the same understandung on how to handle the OS's.
              :-)

              It would be great if things like that could be automated in QT creator in the future!

              most of it is done in the automatic generated Info.plist file, but stuff changes and QtCreator may not always up to the challenge right away.


              Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


              Q: What's that?
              A: It's blue light.
              Q: What does it do?
              A: It turns blue.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 31 Jan 2019, 23:11 last edited by
                #7

                Hi,

                Are you by any chance running Mojave ?

                Apple does introduce new rules / security features from time to time which requires some manual work that might not always be easily manipulated. For example, using QtMultimedia doesn't mean you will be using the microphone nor the camera so you can't automatically add the permission requirements for that.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • C Offline
                  C Offline
                  Cyrille de Brebisson
                  wrote on 1 Feb 2019, 06:13 last edited by
                  #8

                  Hello,

                  I understand...

                  I was more thinking of easy, GUI driven permission list editor that would be in QT creator and allow easy editing of such things without having to "undersand" plists...

                  This same editor would take the info and be able to use them to generate the equivalent files for other OS as well if/as appropriate...

                  That would be cool

                  This is just a QT creator feature suggestion. I am fully aware of how hard/problematic, how much work it is following with ever changing software vendors...
                  Cyrille

                  J 1 Reply Last reply 1 Feb 2019, 06:16
                  0
                  • C Cyrille de Brebisson
                    1 Feb 2019, 06:13

                    Hello,

                    I understand...

                    I was more thinking of easy, GUI driven permission list editor that would be in QT creator and allow easy editing of such things without having to "undersand" plists...

                    This same editor would take the info and be able to use them to generate the equivalent files for other OS as well if/as appropriate...

                    That would be cool

                    This is just a QT creator feature suggestion. I am fully aware of how hard/problematic, how much work it is following with ever changing software vendors...
                    Cyrille

                    J Offline
                    J Offline
                    J.Hilk
                    Moderators
                    wrote on 1 Feb 2019, 06:16 last edited by
                    #9

                    @Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:

                    I was more thinking of easy, GUI driven permission list editor that would be in QT creator and allow easy editing of such things without having to "undersand" plists...

                    It's called Xcode ;-)

                    If you have it installed use that to modify the info.plist it's the easiest way.


                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    1 Reply Last reply
                    0
                    • C Offline
                      C Offline
                      Cyrille de Brebisson
                      wrote on 1 Feb 2019, 10:29 last edited by
                      #10

                      Hello,

                      Well, I have Xcode... There is no choice as QT will not install without it....

                      Anyhow, back to the problem, here is what I have done and found.

                      I have copied the auto generated Info.plist file in my project folder. Added QMAKE_INFO_PLIST= Info.plist in my .pro file and added the following 2 lines in said file:

                      <key>NSCameraUsageDescription</key>
                      <string>Needs camera for display of mirror option</string>
                      

                      I have run qmake and build and here is the behavior that I am seeing:

                      • Run the app from QT creator still does not work (crash).
                      • Run the app in debug mode (click on debug, not on run) and the application DOES work.
                      • Run the app by double clicking on the app bundle generated by QT DOES work. However!
                        • The application starts and the OS asks for camera permission (which I gave).
                        • The application can NOT access the camera (it does not work).
                        • When I close and restart the application (double click on the app). The application is NOW able to access the camera

                      Any clue why a simple click on run causes the app to still crash?

                      Thanks,
                      Cyrille

                      J 1 Reply Last reply 1 Feb 2019, 10:41
                      0
                      • C Cyrille de Brebisson
                        1 Feb 2019, 10:29

                        Hello,

                        Well, I have Xcode... There is no choice as QT will not install without it....

                        Anyhow, back to the problem, here is what I have done and found.

                        I have copied the auto generated Info.plist file in my project folder. Added QMAKE_INFO_PLIST= Info.plist in my .pro file and added the following 2 lines in said file:

                        <key>NSCameraUsageDescription</key>
                        <string>Needs camera for display of mirror option</string>
                        

                        I have run qmake and build and here is the behavior that I am seeing:

                        • Run the app from QT creator still does not work (crash).
                        • Run the app in debug mode (click on debug, not on run) and the application DOES work.
                        • Run the app by double clicking on the app bundle generated by QT DOES work. However!
                          • The application starts and the OS asks for camera permission (which I gave).
                          • The application can NOT access the camera (it does not work).
                          • When I close and restart the application (double click on the app). The application is NOW able to access the camera

                        Any clue why a simple click on run causes the app to still crash?

                        Thanks,
                        Cyrille

                        J Offline
                        J Offline
                        J.Hilk
                        Moderators
                        wrote on 1 Feb 2019, 10:41 last edited by J.Hilk 2 Jan 2019, 10:41
                        #11

                        @Cyrille-de-Brebisson said in Problem with Camera component on macOS 10.14.2:

                        Hello,

                        Well, I have Xcode... There is no choice as QT will not install without it....

                        technically you only need the command line tools, you can get those without the whole Xcode program.

                        Any clue why a simple click on run causes the app to still crash?

                        after adding QMAKE_INFO_PLIST= Info.plist did you rerun qmake ? that the the new modified info.plist is copied into the app bundle?


                        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                        Q: What's that?
                        A: It's blue light.
                        Q: What does it do?
                        A: It turns blue.

                        1 Reply Last reply
                        0
                        • Martin DelilleM Offline
                          Martin DelilleM Offline
                          Martin Delille
                          wrote on 5 Feb 2019, 14:46 last edited by
                          #12

                          I'm facing the same problem.

                          Here is what I did to edit my Info.plist file:

                          QMAKE_POST_LINK += plutil -replace NSCameraUsageDescription -string \"My usage description.\" $${TARGET}.app/Contents/Info.plist
                          

                          Unfortunately I always have a crash.

                          Strangely, if I start a debug session, I have a macOS dialog asking if my app can have the camera access and it work then.

                          1 Reply Last reply
                          1
                          • C Offline
                            C Offline
                            Cyrille de Brebisson
                            wrote on 5 Feb 2019, 15:26 last edited by
                            #13

                            Hello,

                            Very nice solution!

                            Cyrille

                            1 Reply Last reply
                            0

                            1/13

                            31 Jan 2019, 14:17

                            • Login

                            • Login or register to search.
                            1 out of 13
                            • First post
                              1/13
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved