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

In QML, using capture*() after switching between camera devices crashes the application

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 6.2.0 RC
    • Fix Version/s: 6.2.0, 6.2.1, 6.2, 6.3.0 Alpha
    • Component/s: Multimedia
    • Labels:
      None
    • Platform/s:
      macOS
    • Commits:
      d7c4152a9cf9ebac86b9b07e78e675cb0ed5c937 (qt/qtmultimedia/dev) acc8442c3261e7c3cf2b397515a202a24d12b343 (qt/qtmultimedia/6.2) f698f9375c9289fe01e883c7fbaba87c81b835f8 (qt/qtmultimedia/6.2.0)

      Description

      This happens when multiple cameras are available and when we want to switch between those. The next capture triggered after changing the camera device systematically crashes the application:

      [1] 2302 segmentation fault /Users/cyril/work/dev/tools/qt/6.2.0/macos/bin/qml -f main.qml

      A sample code (a bit long) to reproduce the issue is provided below:

      import QtQuick
      import QtQuick.Controls
      import QtMultimedia
      
      Window {
          id: root
      
          width: 1024
          height: 600
          visible: true
      
          MediaDevices { id: mediaDevices }
      
          CaptureSession {
              id: captureSession
              videoOutput: output
              camera: Camera {} 
              imageCapture: ImageCapture {
                  onImageSaved: function (id, path) {
                      image.source = path
                  }
              }
          }
      
          VideoOutput {
              id: output
              anchors.fill: parent
      
              Column {
                  ComboBox {
                      id: cameraComboBox
                      model: mediaDevices.videoInputs
                      textRole: "description"
                      displayText: captureSession.camera.cameraDevice.description
                      onActivated: function (index) {
                          captureSession.camera.cameraDevice = cameraComboBox.currentValue
                      }
                  }
      
                  Button {
                      text: qsTr("Shot!")
                      onClicked: {
                          captureSession.imageCapture.captureToFile()
                      }
                  }
              }
          }
          
          Window {
              visible: true
              x: root.x - width
              y: root.y
              width: 250
              height: 250
              Image {
                  id: image
                  anchors.fill: parent
                  fillMode: Image.PreserveAspectFit
              }
          }
      
          Component.onCompleted: {
              captureSession.camera.start()
          }
      }
      

        Attachments

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

          Activity

            People

            Assignee:
            laknoll Lars Knoll
            Reporter:
            c.lorquet Cyril Lorquet
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes