Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-110812

Camera not working when using OpenGL Renderer (macOS, iOS)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • 6.5.0, 6.5.2, 6.6.0
    • 6.4.1, 6.4.2
    • Multimedia, WebView
    • None
    • iOS/tvOS/watchOS, macOS
    • 2e43d29e1 (dev), 3e23caf2d (6.5.0), 0a51a9a2e (6.5)

    Description

      On iOS and macOS, the QML Camera type does not work when the rendering backend is changed to OpenGL.

      • On macOS there's no camera output visible, but the camera seems to be active (e.g. green led light of camera is on).
      • On iOS the application crashes. 

      Note: The camera permission is correctly added with a custom Project-Info.plist, and everything works as soon as the setGraphicsApi line in the main.cpp is removed.

       

      main.cpp:

      #include <QGuiApplication>
      #include <QQmlApplicationEngine>
      #include <QQuickWindow>
      
      int main(int argc, char *argv[])
      {
        // change graphics api
        QQuickWindow::setGraphicsApi(QSGRendererInterface::OpenGLRhi);
      
        // default mainn.cpp to start QML app
        QGuiApplication app(argc, argv);
        QQmlApplicationEngine engine;
        const QUrl url(u"qrc:/Qt6QuickApp/main.qml"_qs);
        QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                         &app, [url](QObject *obj, const QUrl &objUrl) {
          if (!obj && url == objUrl)
            QCoreApplication::exit(-1);
        }, Qt::QueuedConnection);
        engine.load(url);
      
        return app.exec();
      } 

      Note: On macOS, the same issue happens also when the WebView module is added to the CMakeLists.txt configuration. (it seems the WebView module on macOS causes OpenGL as soon as it is added?)

       

      main.qml:

      import QtQuick
      import QtMultimedia
      
      Window {
        width: 640
        height: 480
        visible: true
        title: qsTr("Camera")
      
        CaptureSession {
          camera: Camera {
            id: camera
            active: true
          }
          videoOutput: output
        }
      
        VideoOutput {
          id: output
          anchors.fill: parent
        }
      } 

      Here's the crashlog from iOS:

      Main Thread Checker: UI API called on a background thread: -[UIView contentScaleFactor]
      PID: 7778, TID: 2651041, Thread name: QSGRenderThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
      Backtrace:
      4   appQt6QuickApp                      0x000000010575acd0 _ZNK10QIOSWindow16devicePixelRatioEv + 36
      5   appQt6QuickApp                      0x0000000106016644 _ZNK7QWindow16devicePixelRatioEv + 84
      6   appQt6QuickApp                      0x00000001062f73ac _ZN15QGles2SwapChain16surfacePixelSizeEv + 104
      7   appQt6QuickApp                      0x00000001054638cc _ZN15QSGRenderThread13syncAndRenderEv + 608
      8   appQt6QuickApp                      0x0000000105464f0c _ZN15QSGRenderThread3runEv + 260
      9   appQt6QuickApp                      0x0000000104919e6c _ZZN14QThreadPrivate5startEPvENK3$_0clEv + 588
      10  appQt6QuickApp                      0x0000000104918ed0 _ZN12_GLOBAL__N_122terminate_on_exceptionIZN14QThreadPrivate5startEPvE3$_0EEvOT_ + 28
      11  appQt6QuickApp                      0x0000000104918e60 _ZN14QThreadPrivate5startEPv + 108
      12  libsystem_pthread.dylib             0x00000001f12fd6cc _pthread_start + 148
      13  libsystem_pthread.dylib             0x00000001f12fcba4 thread_start + 8
      2023-01-31 11:26:19.767127+0100 appQt6QuickApp[7778:2651041] [reports] Main Thread Checker: UI API called on a background thread: -[UIView contentScaleFactor]
      PID: 7778, TID: 2651041, Thread name: QSGRenderThread, Queue name: com.apple.root.default-qos.overcommit, QoS: 0
      Backtrace:
      4   appQt6QuickApp                      0x000000010575acd0 _ZNK10QIOSWindow16devicePixelRatioEv + 36
      5   appQt6QuickApp                      0x0000000106016644 _ZNK7QWindow16devicePixelRatioEv + 84
      6   appQt6QuickApp                      0x00000001062f73ac _ZN15QGles2SwapChain16surfacePixelSizeEv + 104
      7   appQt6QuickApp                      0x00000001054638cc _ZN15QSGRenderThread13syncAndRenderEv + 608
      8   appQt6QuickApp                      0x0000000105464f0c _ZN15QSGRenderThread3runEv + 260
      9   appQt6QuickApp                      0x0000000104919e6c _ZZN14QThreadPrivate5startEPvENK3$_0clEv + 588
      10  appQt6QuickApp                      0x0000000104918ed0 _ZN12_GLOBAL__N_122terminate_on_exceptionIZN14QThreadPrivate5startEPvE3$_0EEvOT_ + 28
      11  appQt6QuickApp                      0x0000000104918e60 _ZN14QThreadPrivate5startEPv + 108
      12  libsystem_pthread.dylib             0x00000001f12fd6cc _pthread_start + 148
      13  libsystem_pthread.dylib             0x00000001f12fcba4 thread_start + 8
      2023-01-31 11:26:19.993603+0100 appQt6QuickApp[7778:2651041] fopen failed for data file: errno = 2 (No such file or directory)
      2023-01-31 11:26:19.993833+0100 appQt6QuickApp[7778:2651041] Errors found! Invalidating cache...
      2023-01-31 11:26:22.309952+0100 appQt6QuickApp[7778:2650259] *** -[AVCaptureVideoDataOutput setVideoSettings:] - videoSettings dictionary contains one or more unsupported (ignored) keys: (
          OpenGLCompatibility
      )
      2023-01-31 11:26:22.311251+0100 appQt6QuickApp[7778:2650259] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureVideoDataOutput setVideoSettings:] Unsupported pixel format type - use -availableVideoCVPixelFormatTypes'
      *** First throw call stack:
      (0x1a49de248 0x19ddaba68 0x1bd72eb90 0x10588a7cc 0x105874744 0x1058744c0 0x1058745d0 0x10588f608 0x10588e4a4 0x10588fd08 0x10588fc9c 0x10c018598 0x10c01a04c 0x10c02a800 0x10c02a344 0x1a4a6ea08 0x1a4a50368 0x1a4a551e4 0x1dd875368 0x1a6f04d88 0x1a6f049ec 0x10573fdc8 0x1c2d79948)
      libc++abi: terminating with uncaught exception of type NSException
      *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[AVCaptureVideoDataOutput setVideoSettings:] Unsupported pixel format type - use -availableVideoCVPixelFormatTypes'
      terminating with uncaught exception of type NSException 

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-110812
          # Subject Branch Project Status CR V

          Activity

            People

              dorisverria Doris Verria
              GTDev Günther Teufl
              Votes:
              9 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes