Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. No microphone permission prompt on MacOS after upgrade to Qt 6.8.3

No microphone permission prompt on MacOS after upgrade to Qt 6.8.3

Scheduled Pinned Locked Moved Solved General and Desktop
microphonemacospermissionsdeployment
12 Posts 3 Posters 519 Views 3 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.
  • S Offline
    S Offline
    szumial
    wrote last edited by
    #3

    @JKSH Before I try, do you have any experience with this permission system? I see a comment in the bug you linked:

    The permissions rely on callbacks driven by GCD/CF, so you’ll need to run with the CoreFoundation event dispatcher. Set the QT_EVENT_DISPATCHER_CORE_FOUNDATION env var to 1.

    And the discussion mentions having to use QGuiApplication for the permission prompts to appear. I do in fact use it and I have just tried starting my app with the above mentioned env var set. Unfortunately no success.

    What worked when testing is a rebuild with Qt 6.5.3 again which works flawlessly with the same codebase.

    JKSHJ 1 Reply Last reply
    0
    • S szumial

      @JKSH Before I try, do you have any experience with this permission system? I see a comment in the bug you linked:

      The permissions rely on callbacks driven by GCD/CF, so you’ll need to run with the CoreFoundation event dispatcher. Set the QT_EVENT_DISPATCHER_CORE_FOUNDATION env var to 1.

      And the discussion mentions having to use QGuiApplication for the permission prompts to appear. I do in fact use it and I have just tried starting my app with the above mentioned env var set. Unfortunately no success.

      What worked when testing is a rebuild with Qt 6.5.3 again which works flawlessly with the same codebase.

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote last edited by
      #4

      @szumial said in No microphone permission prompt on MacOS after upgrade to Qt 6.8.3:

      @JKSH Before I try, do you have any experience with this permission system?

      I have a limited amount of experience with the permission system on macOS. Not enough to troubleshoot/fix the issue if it still persists with Qt 6.10.1.

      I'm just trying to help find the smallest reproducer possible, which could help the relevant folks find a fix more quickly.

      I see a comment in the bug you linked:

      The permissions rely on callbacks driven by GCD/CF, so you’ll need to run with the CoreFoundation event dispatcher. Set the QT_EVENT_DISPATCHER_CORE_FOUNDATION env var to 1.

      And the discussion mentions having to use QGuiApplication for the permission prompts to appear. I do in fact use it and I have just tried starting my app with the above mentioned env var set. Unfortunately no success.

      The environment variable is not needed if you have a QGuiApplication.

      The report that I linked described issues with (QCoreApplication AND (QLocationPermission OR QBluetoothPermission)). There are no issues with (QGuiApplication OR QBluetoothPermission), which is why I suggested testing that.

      What worked when testing is a rebuild with Qt 6.5.3 again which works flawlessly with the same codebase.

      It sounds like a regression (which receive more urgent attention from the Qt Company's engineers).

      If you can confirm that the simple project works fine with Qt 6.5.3 but not 6.10.1, then you have a good basis for opening a bug report (please include details of how to reproduce your pipeline for investigations)

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      1 Reply Last reply
      0
      • S Offline
        S Offline
        szumial
        wrote last edited by
        #5

        I need to stick to LTS versions, hence 6.8.3 is the Qt version of choice. I have noticed that in my Qt dir, there is a Plugins directory with a subdirectory named permissions. This catalog contains static libraries such as libdarwinmicrophonepermission. Since these are static, macdeployqt will not distribute them with my app bundle. Do you think there might be some linking issue with these?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote last edited by SGaist
          #6

          Hi,

          The suggestion of testing with 6.10.1 is not that you move your current production to that version, just that you build your application with it to see if the regression is still there.
          AFAIK, these static plugins should get linked into your application automatically.
          If you are using qmake, you can try setting:

          QTPLUGINS += permissions
          

          and if cmake:

          qt_import_plugins(myapp
              INCLUDE_BY_TYPE permissions
          )
          

          (mainly taken from the documentation as I haven't had to fiddle with these permissions for a long time).

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

          S 1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            The suggestion of testing with 6.10.1 is not that you move your current production to that version, just that you build your application with it to see if the regression is still there.
            AFAIK, these static plugins should get linked into your application automatically.
            If you are using qmake, you can try setting:

            QTPLUGINS += permissions
            

            and if cmake:

            qt_import_plugins(myapp
                INCLUDE_BY_TYPE permissions
            )
            

            (mainly taken from the documentation as I haven't had to fiddle with these permissions for a long time).

            S Offline
            S Offline
            szumial
            wrote last edited by szumial
            #7

            @SGaist thanks for the reply! I am glad that you somehow always pop up with useful hints in any thread I post :)

            I will rebuild it adding QTPLUGINS += permissions in my pipeline. I can test it with Qt 6.10.1 as well, since aqtinstall does list this version as available. I will report back once I have the results.

            Let's consider other possible issues I should track:

            • the CI uses a provisioning profile from Apple - could it be that 6.8.3 needs it somehow updated?
            • the app bundle built with 6.8.3 comes with frameworks which include Info.plist files, but also PrivacyInfo.xcprivacy files, while 6.5.3 does not distribute them - I don't use one for my app, but unless I am wrong (because locally-built / VM-build apps work fine), it should not affect the permissions.
            • I am explicitly using the native multimedia backend (darwin) and I opt to not distribute ffmpeg with my app (old compatibility reasons) - don't know if that could affect if (it does not with 6.5.3)

            Edit:
            Testing with Qt 6.10.1 proved the microphone permissions is not requested, same as with 6.8.3.
            Adding QTPLUGINS += permissions does not change anything, microphone permission prompt still missing.

            I have browsed the documentation on Qt 6.6 changes in the Multimedia module and found out the following:

            The Qt Multimedia library no longer requests audio or video permissions, but only checks if they are provided or not. The client applications must request the permissions using the C++ or QML permissions API.

            I came to a conclusion that my app works when built with Qt 6.5.3 because it is the audio input configuration which touches the microphone at startup which automatically requests microphone permissions and shows the prompt. Since the Qt 6.6 change, there is need to use the permissions API. Hence I have coded the following logic called in the constructor of my audio management class:

            void AudioClass::requestMicrophonePermission()
            {
                QMicrophonePermission microphonePermission;
            
                switch (qApp->checkPermission(microphonePermission))
                {
                case Qt::PermissionStatus::Undetermined:
                    qApp->requestPermission(microphonePermission, this, &AudioManager::microphonePermissionGranted);
                    return;
                case Qt::PermissionStatus::Denied:
                    qDebug() << "Microphone permission denied.";
                    return;
                case Qt::PermissionStatus::Granted:
                    return;
                }
            }
            
            void AudioClass::microphonePermissionGranted()
            {
                qDebug() << "Microphone permission granted.";
            }
            

            I have tried calling it both before and after initializing the audio input in Qt 6.8.3 and unfortunately it never displays the microphone permission prompt on MacOS. Since using QPermissions did not fix the issue I have resorted to integrating a small objective-C++ helper into my application and it does work when I opt to use the following native imports:

            #import <AppKit/AppKit.h>
            #import <AVFoundation/AVFoundation.h>
            #import <ApplicationServices/ApplicationServices.h>
            #import <CoreGraphics/CoreGraphics.h>
            

            @SGaist do you think it is possible there is a bug in the permissions API of Qt that does not allow MacOS's TCC to handle permission prompts correctly?

            SGaistS 1 Reply Last reply
            1
            • S szumial

              @SGaist thanks for the reply! I am glad that you somehow always pop up with useful hints in any thread I post :)

              I will rebuild it adding QTPLUGINS += permissions in my pipeline. I can test it with Qt 6.10.1 as well, since aqtinstall does list this version as available. I will report back once I have the results.

              Let's consider other possible issues I should track:

              • the CI uses a provisioning profile from Apple - could it be that 6.8.3 needs it somehow updated?
              • the app bundle built with 6.8.3 comes with frameworks which include Info.plist files, but also PrivacyInfo.xcprivacy files, while 6.5.3 does not distribute them - I don't use one for my app, but unless I am wrong (because locally-built / VM-build apps work fine), it should not affect the permissions.
              • I am explicitly using the native multimedia backend (darwin) and I opt to not distribute ffmpeg with my app (old compatibility reasons) - don't know if that could affect if (it does not with 6.5.3)

              Edit:
              Testing with Qt 6.10.1 proved the microphone permissions is not requested, same as with 6.8.3.
              Adding QTPLUGINS += permissions does not change anything, microphone permission prompt still missing.

              I have browsed the documentation on Qt 6.6 changes in the Multimedia module and found out the following:

              The Qt Multimedia library no longer requests audio or video permissions, but only checks if they are provided or not. The client applications must request the permissions using the C++ or QML permissions API.

              I came to a conclusion that my app works when built with Qt 6.5.3 because it is the audio input configuration which touches the microphone at startup which automatically requests microphone permissions and shows the prompt. Since the Qt 6.6 change, there is need to use the permissions API. Hence I have coded the following logic called in the constructor of my audio management class:

              void AudioClass::requestMicrophonePermission()
              {
                  QMicrophonePermission microphonePermission;
              
                  switch (qApp->checkPermission(microphonePermission))
                  {
                  case Qt::PermissionStatus::Undetermined:
                      qApp->requestPermission(microphonePermission, this, &AudioManager::microphonePermissionGranted);
                      return;
                  case Qt::PermissionStatus::Denied:
                      qDebug() << "Microphone permission denied.";
                      return;
                  case Qt::PermissionStatus::Granted:
                      return;
                  }
              }
              
              void AudioClass::microphonePermissionGranted()
              {
                  qDebug() << "Microphone permission granted.";
              }
              

              I have tried calling it both before and after initializing the audio input in Qt 6.8.3 and unfortunately it never displays the microphone permission prompt on MacOS. Since using QPermissions did not fix the issue I have resorted to integrating a small objective-C++ helper into my application and it does work when I opt to use the following native imports:

              #import <AppKit/AppKit.h>
              #import <AVFoundation/AVFoundation.h>
              #import <ApplicationServices/ApplicationServices.h>
              #import <CoreGraphics/CoreGraphics.h>
              

              @SGaist do you think it is possible there is a bug in the permissions API of Qt that does not allow MacOS's TCC to handle permission prompts correctly?

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote last edited by
              #8

              @szumial I would think so, or at least the additional steps you need to make should be documented.

              Did you already check the bug report system regarding 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
              0
              • S Offline
                S Offline
                szumial
                wrote last edited by
                #9

                @SGaist I made it work with the following objective-c++ code:

                #include "PermissionRequestor.h"
                #import <AVFoundation/AVFoundation.h>
                
                ...
                
                void PermissionRequestor::requestMicrophonePermission()
                {
                	[AVCaptureDevice requestAccessForMediaType:AVMediaTypeAudio completionHandler:^(BOOL granted)
                	 {
                		 QMetaObject::invokeMethod(this, [this, granted]
                		{
                			emit microphonePermissionResult(granted);
                		}, Qt::QueuedConnection);
                	 }];
                }
                

                Regarding the bug report system - are you suggesting I submit a bug report (never done that before, but would be glad to do so for future improvements)?

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote last edited by
                  #10

                  Thanks for the sample !

                  As for the bug report system, yes, that is what I mean.
                  If something already exists, don't hesitate to comment on the ticket. Otherwise, create a new one.

                  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
                  0
                  • S Offline
                    S Offline
                    szumial
                    wrote last edited by
                    #11

                    Done. Bug reported here.

                    I am marking this as resolved for now. For anyone interested, please observe the linked bug report.

                    1 Reply Last reply
                    2
                    • S szumial has marked this topic as solved
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote last edited by
                      #12

                      Thanks !

                      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
                      0

                      • Login

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