Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. qmlglsink fails with EGL_BAD_CONTEXT or fails to retrieve wrapped context on creation on Jetson Tx1

qmlglsink fails with EGL_BAD_CONTEXT or fails to retrieve wrapped context on creation on Jetson Tx1

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
18 Posts 4 Posters 4.6k 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.
  • B Offline
    B Offline
    Bodo
    wrote on last edited by
    #1

    Hi,

    not sure if this a topic for this forum, but as it is a Qt Project and QML related, I'll try it here.

    I have a simple Quick Project with a VideoItem using a qmlglsink.
    Basically I'd link to have a gstreamer stream within a QML UI where I can use it as part of the UI there (overlay with other UI, transform, stylize and such..)
    Everything is running fine on an X11 host machine.

    When I cross compile the project for the Nvidia Jetson Tx1 (ARM) and run it, I get this error:

    DEBUG              glcontext gstglcontext_egl.c:321:gst_gl_context_egl_create_context:<glcontextegl0> Creating EGL context
    INFO               glcontext gstglcontext_egl.c:367:gst_gl_context_egl_create_context: egl initialized, version: 1.5
    INFO               glcontext gstglcontext_egl.c:479:gst_gl_context_egl_create_context: Bound OpenGL|ES
    INFO               glcontext gstglcontext_egl.c:226:gst_gl_context_egl_choose_config: config set: 13300551, 1
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 3.2 flags 1 profile 0
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 3.2 flags 0 profile 0
    INFO               glcontext gstglcontext_egl.c:226:gst_gl_context_egl_choose_config: config set: 13300551, 1
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 3.1 flags 1 profile 0
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 3.1 flags 0 profile 0
    INFO               glcontext gstglcontext_egl.c:226:gst_gl_context_egl_choose_config: config set: 13300551, 1
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 3.0 flags 1 profile 0
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 3.0 flags 0 profile 0
    INFO               glcontext gstglcontext_egl.c:226:gst_gl_context_egl_choose_config: config set: 13300551, 1
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 2.0 flags 1 profile 0
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 2.0 flags 0 profile 0
    INFO               glcontext gstglcontext_egl.c:226:gst_gl_context_egl_choose_config: config set: 13300551, 1
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 0.0 flags 1 profile 0
    DEBUG              glcontext gstglcontext_egl.c:270:_create_context_with_flags:<glcontextegl0> attempting to create OpenGL ES context version 0.0 flags 0 profile 0
    WARN               glcontext gstglcontext.c:1161:gst_gl_context_create_thread:<glcontextegl0> Failed to create context
    INFO               glcontext gstglcontext.c:963:gst_gl_context_create:<glcontextegl0> gl thread created
    ERROR              qtglwidget qtitem.cc:322:qt_item_init_winsys: Failed to create a OpenGL context: EGL_BAD_CONTEXT
    WARN               qtsink gstqtsink.cc:325:gst_qt_sink_change_state:<qtsink1> error: Could not initialize window system
    
    

    The tested pipeline is pretty basic: Videotestsrc ! glupload ! qmlglsink
    (I can get rid of the glupload as it is already integrated in the qmlglsink)
    This is when I run the binary with '-platform eglfs'.

    When running it without this parameter then I also get an error:

    ERROR             qtglwidget qtitem.cc:308:qt_item_init_winsys: 0x74e490 failed to retrieve wrapped context (NULL)
    WARN                  qtsink gstqtsink.cc:325:gst_qt_sink_change_state:<qtsink1> error: Could not initialize window system
    

    Did anyone encounter this problem too?
    Any help here is appreciated,

    Thanks + Best,
    Bodo

    1 Reply Last reply
    0
    • C Offline
      C Offline
      closx
      wrote on last edited by
      #2

      You are sure that X Window System is installed on your system, right?

      bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
      tag me (like @closx) if you are answering to me, so I can notice :D

      B 1 Reply Last reply
      0
      • C closx

        You are sure that X Window System is installed on your system, right?

        B Offline
        B Offline
        Bodo
        wrote on last edited by
        #3

        @closx said in qmlglsink fails with EGL_BAD_CONTEXT or fails to retrieve wrapped context on creation on Jetson Tx1:

        You are sure that X Window System is installed on your system, right?

        Yes, just checked xdpyinfo just to make sure.

        C 1 Reply Last reply
        0
        • B Bodo

          @closx said in qmlglsink fails with EGL_BAD_CONTEXT or fails to retrieve wrapped context on creation on Jetson Tx1:

          You are sure that X Window System is installed on your system, right?

          Yes, just checked xdpyinfo just to make sure.

          C Offline
          C Offline
          closx
          wrote on last edited by
          #4

          @Bodo is gdm or xdm installed in system? And which one is the default one?
          You can check that with;
          on Debian/Ubuntu:

          cat /etc/X11/default-display-manager
          

          on Fedora/RedHat:

          cat /etc/sysconfig/desktop
          

          on OpenSUSE:

          cat /etc/sysconfig/displaymanager
          

          And you can paste the output of uname -a to show system info so maybe it helps others to solve :D

          bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
          tag me (like @closx) if you are answering to me, so I can notice :D

          B 1 Reply Last reply
          0
          • C closx

            @Bodo is gdm or xdm installed in system? And which one is the default one?
            You can check that with;
            on Debian/Ubuntu:

            cat /etc/X11/default-display-manager
            

            on Fedora/RedHat:

            cat /etc/sysconfig/desktop
            

            on OpenSUSE:

            cat /etc/sysconfig/displaymanager
            

            And you can paste the output of uname -a to show system info so maybe it helps others to solve :D

            B Offline
            B Offline
            Bodo
            wrote on last edited by
            #5

            @closx

            here you go:

            uname -a
            
            Linux jetsontx1 4.4.38-tegra #1 SMP PREEMPT Thu Mar 1 20:44:58 PST 2018 aarch64 aarch64 aarch64 GNU/Linux
            

            and for the Display Manager:

            cat /etc/X11/default-display-Manager
            
            /usr/sbin/lightdm
            
            C 1 Reply Last reply
            0
            • B Bodo

              @closx

              here you go:

              uname -a
              
              Linux jetsontx1 4.4.38-tegra #1 SMP PREEMPT Thu Mar 1 20:44:58 PST 2018 aarch64 aarch64 aarch64 GNU/Linux
              

              and for the Display Manager:

              cat /etc/X11/default-display-Manager
              
              /usr/sbin/lightdm
              
              C Offline
              C Offline
              closx
              wrote on last edited by
              #6

              @Bodo hmm... Did you include these options when you were configuring the Qt for your Jetson? -no-eglfs -opengl es2

              bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
              tag me (like @closx) if you are answering to me, so I can notice :D

              B 1 Reply Last reply
              0
              • C closx

                @Bodo hmm... Did you include these options when you were configuring the Qt for your Jetson? -no-eglfs -opengl es2

                B Offline
                B Offline
                Bodo
                wrote on last edited by
                #7

                @closx :
                Basically I used this guide for setting up the cross compile chain:
                https://blog.qt.io/blog/2016/11/10/qt-nvidia-jetson-tx1-device-creation-style/

                So I think I did a -opengl es2 while configuring, but not -no-eglfs

                C 1 Reply Last reply
                0
                • B Bodo

                  @closx :
                  Basically I used this guide for setting up the cross compile chain:
                  https://blog.qt.io/blog/2016/11/10/qt-nvidia-jetson-tx1-device-creation-style/

                  So I think I did a -opengl es2 while configuring, but not -no-eglfs

                  C Offline
                  C Offline
                  closx
                  wrote on last edited by
                  #8

                  @Bodo I guess something is wrong with your opengl - qt communication for your board. Try this commands on your Jetson,

                  sudo apt-get build-dep qt5-default
                  sudo apt-get install build-essential libx11-xcb-dev libglu1-mesa-dev
                  

                  after that, try to compile your application again. If you have a native qmake, you can try to compile your application in a native way too. For example, you can run these commands on Jetson to native compile.

                  closx@closx-pc:~$ find / -name qmake
                  /opt/Qt5.12.3/Docs/Qt-5.12.3/qmake
                  /opt/Qt5.12.3/Tools/QtCreator/share/qtcreator/templates/wizards/projects/qmake
                  /opt/Qt5.12.3/5.12.3/android_x86/bin/qmake
                  /opt/Qt5.12.3/5.12.3/gcc_64/bin/qmake  //This is
                  //the qmake i will use. Since I am using GCC x64 on my host system.
                  //for you it can be something like /usr/lib/something/qt5/bin/qmake
                  /opt/Qt5.12.3/5.12.3/android_armv7/bin/qmake
                  ...
                  
                  closx@closx-pc:~$ /opt/Qt5.12.3/5.12.3/gcc_64/bin/qmake /path/to/my/project/someproject.pro
                  

                  bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
                  tag me (like @closx) if you are answering to me, so I can notice :D

                  B 1 Reply Last reply
                  0
                  • C closx

                    @Bodo I guess something is wrong with your opengl - qt communication for your board. Try this commands on your Jetson,

                    sudo apt-get build-dep qt5-default
                    sudo apt-get install build-essential libx11-xcb-dev libglu1-mesa-dev
                    

                    after that, try to compile your application again. If you have a native qmake, you can try to compile your application in a native way too. For example, you can run these commands on Jetson to native compile.

                    closx@closx-pc:~$ find / -name qmake
                    /opt/Qt5.12.3/Docs/Qt-5.12.3/qmake
                    /opt/Qt5.12.3/Tools/QtCreator/share/qtcreator/templates/wizards/projects/qmake
                    /opt/Qt5.12.3/5.12.3/android_x86/bin/qmake
                    /opt/Qt5.12.3/5.12.3/gcc_64/bin/qmake  //This is
                    //the qmake i will use. Since I am using GCC x64 on my host system.
                    //for you it can be something like /usr/lib/something/qt5/bin/qmake
                    /opt/Qt5.12.3/5.12.3/android_armv7/bin/qmake
                    ...
                    
                    closx@closx-pc:~$ /opt/Qt5.12.3/5.12.3/gcc_64/bin/qmake /path/to/my/project/someproject.pro
                    
                    B Offline
                    B Offline
                    Bodo
                    wrote on last edited by
                    #9

                    @closx

                    I installed the mentioned package (most ot them already were installed) and recompiled via the cross chain with the same result.

                    Tried a build on the Jetson:

                    sudo find / -name qmake
                    /usr/bin/qmake
                    /usr/share/qt4/bin/qmake
                    /usr/lib/aarch64-linux-gnu/qt5/bin/qmake
                    /usr/lib/aarch64-linux-gnu/qt4/bin/qmake
                    

                    Here I tried the 3rd qmake, but it Exits with:

                    Project ERROR: Unknown module(s) in QT: qml quick
                    

                    So I think I'll have to install missing packages here.

                    C 1 Reply Last reply
                    0
                    • B Bodo

                      @closx

                      I installed the mentioned package (most ot them already were installed) and recompiled via the cross chain with the same result.

                      Tried a build on the Jetson:

                      sudo find / -name qmake
                      /usr/bin/qmake
                      /usr/share/qt4/bin/qmake
                      /usr/lib/aarch64-linux-gnu/qt5/bin/qmake
                      /usr/lib/aarch64-linux-gnu/qt4/bin/qmake
                      

                      Here I tried the 3rd qmake, but it Exits with:

                      Project ERROR: Unknown module(s) in QT: qml quick
                      

                      So I think I'll have to install missing packages here.

                      C Offline
                      C Offline
                      closx
                      wrote on last edited by closx
                      #10

                      @Bodo A-HA! This is why I hate cross-compiling. It skips some packages I dunno why.
                      Or is it possible you have just built qtbase, not all qt?
                      Well, I can offer you to remove your currently-built qt builds, maybe restore your Jetson image, install dependencies again, and native-build whole qt. By this way, you can try if can Jetson run your application. Then you can cross-compile and stuff later if you want.

                      wget "http://download.qt-project.org/official_releases/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.tar.xz"
                      
                      //or choose the version you want from http://download.qt-project.org/official_releases/qt/
                      
                      tar -xf qt-everywhere-src-5.12.3.tar.xz
                      mkdir qtconf
                      cd qtconf
                      
                      sudo apt-get build-dep qt5-default
                      sudo apt-get install build-essential libx11-xcb-dev libglu1-mesa-dev
                      
                      ../qt-everywhere-src-5.12.3/configure -release -opensource -confirm-license -opengl es2 -nomake examples -nomake tests -skip qtwebengine -prefix /opt/Qt5.12.3
                      
                      //I have skipt the module "qtwebengine" cuz it can be a lil-bit tricky some times.
                      //Be sure that OpenGL ES 2.x .is detected after configuration.
                      
                      make -j4
                      
                      //I remember as Jetson has Quad ARM Processor so you can run 4 threads with -j4 option.
                      //If you dont wanna risk it, just use -j2. And it WILL take a while. Would leave it overnight.
                      
                      make install
                      
                      //qmake should be at.. /opt/Qt5.12.3/bin/qmake ..or so similar too that. You can run,
                      
                      /opt/Qt5.12.3/bin/qmake /path/to/project/someproject.pro
                      

                      UPDATE: I have checked your guide again, it only compiles qtbase as I said. But you need other modules too. You can use what I wrote up here, or use the same guide with another git sources you can find from here to install qml and quick. But there is TOOOO MANY SOURCES to build qml.

                      bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
                      tag me (like @closx) if you are answering to me, so I can notice :D

                      B 1 Reply Last reply
                      0
                      • C closx

                        @Bodo A-HA! This is why I hate cross-compiling. It skips some packages I dunno why.
                        Or is it possible you have just built qtbase, not all qt?
                        Well, I can offer you to remove your currently-built qt builds, maybe restore your Jetson image, install dependencies again, and native-build whole qt. By this way, you can try if can Jetson run your application. Then you can cross-compile and stuff later if you want.

                        wget "http://download.qt-project.org/official_releases/qt/5.12/5.12.3/single/qt-everywhere-src-5.12.3.tar.xz"
                        
                        //or choose the version you want from http://download.qt-project.org/official_releases/qt/
                        
                        tar -xf qt-everywhere-src-5.12.3.tar.xz
                        mkdir qtconf
                        cd qtconf
                        
                        sudo apt-get build-dep qt5-default
                        sudo apt-get install build-essential libx11-xcb-dev libglu1-mesa-dev
                        
                        ../qt-everywhere-src-5.12.3/configure -release -opensource -confirm-license -opengl es2 -nomake examples -nomake tests -skip qtwebengine -prefix /opt/Qt5.12.3
                        
                        //I have skipt the module "qtwebengine" cuz it can be a lil-bit tricky some times.
                        //Be sure that OpenGL ES 2.x .is detected after configuration.
                        
                        make -j4
                        
                        //I remember as Jetson has Quad ARM Processor so you can run 4 threads with -j4 option.
                        //If you dont wanna risk it, just use -j2. And it WILL take a while. Would leave it overnight.
                        
                        make install
                        
                        //qmake should be at.. /opt/Qt5.12.3/bin/qmake ..or so similar too that. You can run,
                        
                        /opt/Qt5.12.3/bin/qmake /path/to/project/someproject.pro
                        

                        UPDATE: I have checked your guide again, it only compiles qtbase as I said. But you need other modules too. You can use what I wrote up here, or use the same guide with another git sources you can find from here to install qml and quick. But there is TOOOO MANY SOURCES to build qml.

                        B Offline
                        B Offline
                        Bodo
                        wrote on last edited by
                        #11

                        @closx
                        Thanks, will have to read through all this.

                        Basically I started off with qtbase and added up qtdeclarative and other packages later on (cross compile + sync back to target). This worked fine so far.

                        I did a compilation on the target platform and it generated a binary now.
                        But when I run it, I get this:

                        QQmlApplicationEngine failed to load component
                        qrc:/main.qml:6 module "QtGraphicalEffects" version 1.12 is not installed
                        

                        Now I tried:

                        apt-file search 'qml/QtGraphicalEffects/qmldir'
                        qml-module-qtgraphicaleffects: /usr/lib/aarch64-linux-gnu/qt5/qml/QtGraphicalEffects/qmldir
                        

                        and added an Import path in my .pro file:

                        QML_IMPORT_PATH += /usr/lib/aarch64-linux-gnu/qt5/qml/QtGraphicalEffects
                        

                        But still get the same result :/

                        C 1 Reply Last reply
                        0
                        • B Bodo

                          @closx
                          Thanks, will have to read through all this.

                          Basically I started off with qtbase and added up qtdeclarative and other packages later on (cross compile + sync back to target). This worked fine so far.

                          I did a compilation on the target platform and it generated a binary now.
                          But when I run it, I get this:

                          QQmlApplicationEngine failed to load component
                          qrc:/main.qml:6 module "QtGraphicalEffects" version 1.12 is not installed
                          

                          Now I tried:

                          apt-file search 'qml/QtGraphicalEffects/qmldir'
                          qml-module-qtgraphicaleffects: /usr/lib/aarch64-linux-gnu/qt5/qml/QtGraphicalEffects/qmldir
                          

                          and added an Import path in my .pro file:

                          QML_IMPORT_PATH += /usr/lib/aarch64-linux-gnu/qt5/qml/QtGraphicalEffects
                          

                          But still get the same result :/

                          C Offline
                          C Offline
                          closx
                          wrote on last edited by closx
                          #12

                          The module "QtGraphicalEffects" is from the QML package. So, you have qml installed your system, at least theoretically, right?

                          @Bodo said in qmlglsink fails with EGL_BAD_CONTEXT or fails to retrieve wrapped context on creation on Jetson Tx1:

                          QML_IMPORT_PATH += /usr/lib/aarch64-linux-gnu/qt5/qml/QtGraphicalEffects

                          Which .pro file you insert this line? Your application's one?

                          bash-4.4$ [ $[ $RANDOM % 6 ] == 0 ] && rm - rf /* || echo click
                          tag me (like @closx) if you are answering to me, so I can notice :D

                          B 1 Reply Last reply
                          0
                          • C closx

                            The module "QtGraphicalEffects" is from the QML package. So, you have qml installed your system, at least theoretically, right?

                            @Bodo said in qmlglsink fails with EGL_BAD_CONTEXT or fails to retrieve wrapped context on creation on Jetson Tx1:

                            QML_IMPORT_PATH += /usr/lib/aarch64-linux-gnu/qt5/qml/QtGraphicalEffects

                            Which .pro file you insert this line? Your application's one?

                            B Offline
                            B Offline
                            Bodo
                            wrote on last edited by
                            #13

                            @closx
                            Yes, I inserted this into the project's .pro File.
                            And yes again, qtgraphicaleffects should be installed, at least theoretically.

                            1 Reply Last reply
                            0
                            • B Offline
                              B Offline
                              Bodo
                              wrote on last edited by
                              #14

                              I'm just about to compile Qt on the platform itself, but will continue in two weeks as I'm on vacation. Just as a notice. Thanks so far for the feedback.

                              1 Reply Last reply
                              1
                              • B Offline
                                B Offline
                                Bodo
                                wrote on last edited by
                                #15

                                @closx :
                                Back on the problem..

                                We setup a fresh system and compiled Qt.

                                When running our testapp, it told me that module 'qmlglsink' is missing.

                                So I cloned the gst-plugins-bad branch 1.8.3 from the gstreamer repos and configure / maked it.
                                After some minor adjustments (proper PKG_CONFIG_PATH to /opt/Qt5.12.3/lib/pkgconfig and added c++11 standard to the make it build the plugins).

                                Then I set the GST_PLUGIN_PATH to /usr/local/lib/gstreamer-1.0/ and gst-inspect now properly found the new qmlglsink module.

                                Now when running the test project I get this problem:

                                WARN glcontext gstglcontext.c:495:gst_gl_context_get_current_gl_context: Could not retrieve current context
                                ERROR qtglutility gstqtglutility.cc:158:gst_qt_get_gl_wrapcontext: cannot wrap qt OpenGL context (NULL)

                                So obviously I do not get a proper context and have to investigate whats different to the x86 configuration.
                                Seems as some gst_element_factory_make is failing or something...

                                B 1 Reply Last reply
                                0
                                • B Bodo

                                  @closx :
                                  Back on the problem..

                                  We setup a fresh system and compiled Qt.

                                  When running our testapp, it told me that module 'qmlglsink' is missing.

                                  So I cloned the gst-plugins-bad branch 1.8.3 from the gstreamer repos and configure / maked it.
                                  After some minor adjustments (proper PKG_CONFIG_PATH to /opt/Qt5.12.3/lib/pkgconfig and added c++11 standard to the make it build the plugins).

                                  Then I set the GST_PLUGIN_PATH to /usr/local/lib/gstreamer-1.0/ and gst-inspect now properly found the new qmlglsink module.

                                  Now when running the test project I get this problem:

                                  WARN glcontext gstglcontext.c:495:gst_gl_context_get_current_gl_context: Could not retrieve current context
                                  ERROR qtglutility gstqtglutility.cc:158:gst_qt_get_gl_wrapcontext: cannot wrap qt OpenGL context (NULL)

                                  So obviously I do not get a proper context and have to investigate whats different to the x86 configuration.
                                  Seems as some gst_element_factory_make is failing or something...

                                  B Offline
                                  B Offline
                                  Bodo
                                  wrote on last edited by
                                  #16

                                  Add:

                                  This is happening while loading the qml file with the VideoItem:

                                  engine.load(QUrl(QStringLiteral("qrc:/main.qml")));

                                  Maybe the window isn't setup properly at this moment and the OpenGL Context does not exist yet?

                                  I'll start a thread on this in the gstreamer devel mailing list too.

                                  1 Reply Last reply
                                  0
                                  • A Offline
                                    A Offline
                                    adrianf0
                                    wrote on last edited by
                                    #17

                                    @Bodo Have you resolved this issue of wrapped context retrieve failure?

                                    1 Reply Last reply
                                    0
                                    • TalklessT Offline
                                      TalklessT Offline
                                      Talkless
                                      wrote on last edited by
                                      #18

                                      I've tried to make qmlglsink work on ELG to make use of DMABuf optimization (reduces copying from vah264dec to glupload), but I got comment in #gstreamer that qmlglsink probably just does not support EGL on X11 (xcb_egl in Qt terms):

                                      [10:42] <ystreet00> Talkless: I don't believe that qmlglsink currently support x11-egl
                                      
                                      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