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. Camera example Freeze with QT6 on Ubuntu 22.04.1 when minimized or ApplicationDeactivate event.

Camera example Freeze with QT6 on Ubuntu 22.04.1 when minimized or ApplicationDeactivate event.

Scheduled Pinned Locked Moved Solved General and Desktop
15 Posts 2 Posters 859 Views
  • 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.
  • M Offline
    M Offline
    MStackoverflo
    wrote on 9 Nov 2023, 15:42 last edited by MStackoverflo 11 Sept 2023, 15:55
    #1

    Hi, I've seen I'm not the only one with the problem.

    What happens is that when there's a QVideoWidget, and the app is either minimized or disappears because we clicked on another app, the QVideoWidget freezes and never recovers. Everything else is still working. Ex.: Hover button shows animation, clicks are sent, etc... The QVideoWdiget updates a frame when a picture is taken.

    While the camera is running, I get this spammed in the application output tab, but I see the camera feed fine.
    When I take picture, I get a "image is empty" warning sometimes.

    qt.gui.imageio.jpeg: JPEG datastream contains no image
    qt.gui.imageio.jpeg: JPEG datastream contains no image
    Invalid texture upload for 0x55e799d1ef80 layer=0 mip=0
    

    I'm using a Virtual Machine with Ubuntu 22.04.1. with wayland as the compositor and QT6.6

    QTbug posts suggest it's a hardware acceleration problem, but I've tried with hardware acceleration turned off and I still get the issue.

    I've tried the example with EDIT QT5.15.2 and the problem does not occur, but the frame rate is terrible.

    Everything works as expected on Windows 11 and I don't get the qt.gui.imageio.jpeg: JPEG datastream contains no image problem.

    Anyone have a clue on why?

    J 1 Reply Last reply 9 Nov 2023, 15:47
    0
    • M Offline
      M Offline
      MStackoverflo
      wrote on 10 Nov 2023, 18:27 last edited by
      #14

      I made it work using XCB instead of Wayland. For some reason, QT has a problem with Wayland. QT can run using XCB even though Ubuntu desktop uses wayland.

      Before invoking QApplication in main, these line must be added :

      qputenv("QT_QPA_PLATFORM","xcb");
      qputenv("QT_MEDIA_BACKEND","gstreamer");
      

      libxcb packages must be installed prior.

      J 1 Reply Last reply 10 Nov 2023, 18:58
      0
      • M MStackoverflo
        9 Nov 2023, 15:42

        Hi, I've seen I'm not the only one with the problem.

        What happens is that when there's a QVideoWidget, and the app is either minimized or disappears because we clicked on another app, the QVideoWidget freezes and never recovers. Everything else is still working. Ex.: Hover button shows animation, clicks are sent, etc... The QVideoWdiget updates a frame when a picture is taken.

        While the camera is running, I get this spammed in the application output tab, but I see the camera feed fine.
        When I take picture, I get a "image is empty" warning sometimes.

        qt.gui.imageio.jpeg: JPEG datastream contains no image
        qt.gui.imageio.jpeg: JPEG datastream contains no image
        Invalid texture upload for 0x55e799d1ef80 layer=0 mip=0
        

        I'm using a Virtual Machine with Ubuntu 22.04.1. with wayland as the compositor and QT6.6

        QTbug posts suggest it's a hardware acceleration problem, but I've tried with hardware acceleration turned off and I still get the issue.

        I've tried the example with EDIT QT5.15.2 and the problem does not occur, but the frame rate is terrible.

        Everything works as expected on Windows 11 and I don't get the qt.gui.imageio.jpeg: JPEG datastream contains no image problem.

        Anyone have a clue on why?

        J Offline
        J Offline
        JoeCFD
        wrote on 9 Nov 2023, 15:47 last edited by JoeCFD 11 Sept 2023, 15:48
        #2

        @MStackoverflo On Ubuntu 22.04, default Qt version in the distribution is 5.15.3. Better to try 5.15.3. Qt5.12 is kind of old. I would not try Qt5.12 on Ubuntu 22.04. If you want to switch to Qt6, better to install Qt6.6 or above. Multimedia module has been reworked in Qt6.

        M 1 Reply Last reply 9 Nov 2023, 15:53
        0
        • J JoeCFD
          9 Nov 2023, 15:47

          @MStackoverflo On Ubuntu 22.04, default Qt version in the distribution is 5.15.3. Better to try 5.15.3. Qt5.12 is kind of old. I would not try Qt5.12 on Ubuntu 22.04. If you want to switch to Qt6, better to install Qt6.6 or above. Multimedia module has been reworked in Qt6.

          M Offline
          M Offline
          MStackoverflo
          wrote on 9 Nov 2023, 15:53 last edited by
          #3

          @JoeCFD Hi, the QT6 version I'm trying is indeed QT6.6. The QT5 version I was trying was 5.15.2, the one that is available in the unified installer. I will rectify my post.

          J 1 Reply Last reply 9 Nov 2023, 15:57
          0
          • M MStackoverflo
            9 Nov 2023, 15:53

            @JoeCFD Hi, the QT6 version I'm trying is indeed QT6.6. The QT5 version I was trying was 5.15.2, the one that is available in the unified installer. I will rectify my post.

            J Offline
            J Offline
            JoeCFD
            wrote on 9 Nov 2023, 15:57 last edited by JoeCFD 11 Sept 2023, 15:59
            #4

            @MStackoverflo Can you try Xorg(not wayland) first to see if the code works.
            If your code does not work, post it here if possible. I can try it with both 5.15.3 and 6.6 for you.

            M 1 Reply Last reply 9 Nov 2023, 16:08
            0
            • J JoeCFD
              9 Nov 2023, 15:57

              @MStackoverflo Can you try Xorg(not wayland) first to see if the code works.
              If your code does not work, post it here if possible. I can try it with both 5.15.3 and 6.6 for you.

              M Offline
              M Offline
              MStackoverflo
              wrote on 9 Nov 2023, 16:08 last edited by MStackoverflo 11 Sept 2023, 16:11
              #5

              @JoeCFD Hi, I tried with Xorg on Ubuntu by setting WaylandEnable=false in /etc/gdm3/custom.conf, but the QVideoWidget only shows one frame and freezes.

              The camera example is here :
              https://doc.qt.io/qt-6/qtmultimedia-camera-example.html
              https://doc.qt.io/qt-5.15/qtmultimedia-multimediawidgets-camera-example.html

              EDIT :
              I'm developing an APP that uses that example's code, which is why I'm seeking help.

              J 1 Reply Last reply 9 Nov 2023, 17:49
              0
              • M MStackoverflo
                9 Nov 2023, 16:08

                @JoeCFD Hi, I tried with Xorg on Ubuntu by setting WaylandEnable=false in /etc/gdm3/custom.conf, but the QVideoWidget only shows one frame and freezes.

                The camera example is here :
                https://doc.qt.io/qt-6/qtmultimedia-camera-example.html
                https://doc.qt.io/qt-5.15/qtmultimedia-multimediawidgets-camera-example.html

                EDIT :
                I'm developing an APP that uses that example's code, which is why I'm seeking help.

                J Offline
                J Offline
                JoeCFD
                wrote on 9 Nov 2023, 17:49 last edited by JoeCFD 11 Sept 2023, 17:49
                #6

                @MStackoverflo Just tested. Both work fine with a camera.

                M 1 Reply Last reply 9 Nov 2023, 18:00
                0
                • J JoeCFD
                  9 Nov 2023, 17:49

                  @MStackoverflo Just tested. Both work fine with a camera.

                  M Offline
                  M Offline
                  MStackoverflo
                  wrote on 9 Nov 2023, 18:00 last edited by
                  #7

                  @JoeCFD Nice. That means it may be a setup problem. Did you try on a Virtual Machine or original? Also, were you on ubuntu 22?

                  J 1 Reply Last reply 9 Nov 2023, 18:48
                  0
                  • M MStackoverflo
                    9 Nov 2023, 18:00

                    @JoeCFD Nice. That means it may be a setup problem. Did you try on a Virtual Machine or original? Also, were you on ubuntu 22?

                    J Offline
                    J Offline
                    JoeCFD
                    wrote on 9 Nov 2023, 18:48 last edited by
                    #8

                    @MStackoverflo Not in a virtual machine. I tried it on Lubuntu 22.04.

                    M 2 Replies Last reply 9 Nov 2023, 22:52
                    0
                    • J JoeCFD
                      9 Nov 2023, 18:48

                      @MStackoverflo Not in a virtual machine. I tried it on Lubuntu 22.04.

                      M Offline
                      M Offline
                      MStackoverflo
                      wrote on 9 Nov 2023, 22:52 last edited by
                      #9

                      @JoeCFD I confirm that I cannot make it work on Ubuntu 22 when installed on a hard-drive. I get the same results. I'm currently trying to build on Lubuntu. Were you using wayland on Ubuntu? Because the default install I get is LXQt and uses x11. What is your setup?

                      1 Reply Last reply
                      0
                      • J JoeCFD
                        9 Nov 2023, 18:48

                        @MStackoverflo Not in a virtual machine. I tried it on Lubuntu 22.04.

                        M Offline
                        M Offline
                        MStackoverflo
                        wrote on 9 Nov 2023, 23:03 last edited by
                        #10

                        @JoeCFD I try to run it on Lubuntu 22.04 LXQT with QT6.6 and it shows a blank black screen. I would like to know your setup. I have a fresh Lubuntu with sudo apt install build-essential libxcb*

                        J 1 Reply Last reply 9 Nov 2023, 23:11
                        0
                        • M MStackoverflo
                          9 Nov 2023, 23:03

                          @JoeCFD I try to run it on Lubuntu 22.04 LXQT with QT6.6 and it shows a blank black screen. I would like to know your setup. I have a fresh Lubuntu with sudo apt install build-essential libxcb*

                          J Offline
                          J Offline
                          JoeCFD
                          wrote on 9 Nov 2023, 23:11 last edited by
                          #11

                          @MStackoverflo So many packages. I am not sure what you mean by setup. I use X11.

                          M 1 Reply Last reply 9 Nov 2023, 23:21
                          0
                          • J JoeCFD
                            9 Nov 2023, 23:11

                            @MStackoverflo So many packages. I am not sure what you mean by setup. I use X11.

                            M Offline
                            M Offline
                            MStackoverflo
                            wrote on 9 Nov 2023, 23:21 last edited by
                            #12

                            @JoeCFD Ok, the problem seems to be related in some ways to QT with wayland. Thank you for your time, it is very appreciated.

                            The app I need to develop is for Ubuntu 22 users, so it uses wayland.

                            Anyone has a clue on this setup?

                            1 Reply Last reply
                            0
                            • M Offline
                              M Offline
                              MStackoverflo
                              wrote on 10 Nov 2023, 02:52 last edited by
                              #13

                              I used gstreamer backend instead of ffmpeg and I no longer get the following error :

                              qt.gui.imageio.jpeg: JPEG datastream contains no image
                              qt.gui.imageio.jpeg: JPEG datastream contains no image
                              Invalid texture upload for 0x55e799d1ef80 layer=0 mip=0
                              

                              Concerning video freeze, the window does not need to be minimized to freeze. If I slide another app over it to completely occlude it, it freezes. But, if there's even a small part showing, it doesn't freeze.

                              1 Reply Last reply
                              0
                              • M Offline
                                M Offline
                                MStackoverflo
                                wrote on 10 Nov 2023, 18:27 last edited by
                                #14

                                I made it work using XCB instead of Wayland. For some reason, QT has a problem with Wayland. QT can run using XCB even though Ubuntu desktop uses wayland.

                                Before invoking QApplication in main, these line must be added :

                                qputenv("QT_QPA_PLATFORM","xcb");
                                qputenv("QT_MEDIA_BACKEND","gstreamer");
                                

                                libxcb packages must be installed prior.

                                J 1 Reply Last reply 10 Nov 2023, 18:58
                                0
                                • M MStackoverflo has marked this topic as solved on 10 Nov 2023, 18:27
                                • M MStackoverflo
                                  10 Nov 2023, 18:27

                                  I made it work using XCB instead of Wayland. For some reason, QT has a problem with Wayland. QT can run using XCB even though Ubuntu desktop uses wayland.

                                  Before invoking QApplication in main, these line must be added :

                                  qputenv("QT_QPA_PLATFORM","xcb");
                                  qputenv("QT_MEDIA_BACKEND","gstreamer");
                                  

                                  libxcb packages must be installed prior.

                                  J Offline
                                  J Offline
                                  JoeCFD
                                  wrote on 10 Nov 2023, 18:58 last edited by JoeCFD 11 Oct 2023, 18:59
                                  #15

                                  @MStackoverflo you may check if you have installed all wayland-related gstreamer packages. for example: gstreamer-gl-wayland-1.0.
                                  and test some pipelines from command line. For example:
                                  gst-launch-1.0 -v videotestsrc ! waylandsink

                                  1 Reply Last reply
                                  1

                                  1/15

                                  9 Nov 2023, 15:42

                                  • Login

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