[vlc-commits] [Git][videolan/vlc][master] 7 commits: qt: ensure FBO exists before destroying them in X11 compositor

Felix Paul Kühne (@fkuehne) gitlab at videolan.org
Sat Jun 1 16:08:10 UTC 2024



Felix Paul Kühne pushed to branch master at VideoLAN / VLC


Commits:
27bc33a6 by Pierre Lamot at 2024-06-01T15:53:38+00:00
qt: ensure FBO exists before destroying them in X11 compositor

- - - - -
d6ab5c09 by Fatih Uzunoglu at 2024-06-01T15:53:38+00:00
qt: use destroyFbo() in CompositorX11UISurface::resizeFbo()

- - - - -
255030b1 by Fatih Uzunoglu at 2024-06-01T15:53:38+00:00
qt: remove unused member in CompositorX11UISurface

- - - - -
eeea8dde by Pierre Lamot at 2024-06-01T15:53:38+00:00
qt: fix freeze after minimizing window with X11 compositor

The expose event is emitted after a resize, thus this not necessary to monitor
width/height events on the main window

- - - - -
81a2cbc6 by Pierre Lamot at 2024-06-01T15:53:38+00:00
qt: fix out of bound checking of xcb properties

- - - - -
65dc0343 by Pierre Lamot at 2024-06-01T15:53:38+00:00
qt: fix race condition when closing interface while video is opening with X11

- - - - -
5afeb5aa by Pierre Lamot at 2024-06-01T15:53:38+00:00
qt: fix deadlock when quitting qt application with X11 compositor

Under some circumstances, the application won't close after a quit event.
Using an `exit` in `triggerQuit` callback ensure that the application won't
prevent the mainloop to quit. At this point, both the gui and vout are stopped

- - - - -


7 changed files:

- modules/gui/qt/maininterface/compositor_x11_renderclient.cpp
- modules/gui/qt/maininterface/compositor_x11_renderclient.hpp
- modules/gui/qt/maininterface/compositor_x11_renderwindow.cpp
- modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
- modules/gui/qt/maininterface/compositor_x11_uisurface.hpp
- modules/gui/qt/maininterface/compositor_x11_utils.cpp
- modules/gui/qt/qt.cpp


Changes:

=====================================
modules/gui/qt/maininterface/compositor_x11_renderclient.cpp
=====================================
@@ -22,12 +22,11 @@
 
 using namespace vlc;
 
-CompositorX11RenderClient::CompositorX11RenderClient(qt_intf_t* p_intf, xcb_connection_t* conn,  QWindow* window, QObject *parent)
+CompositorX11RenderClient::CompositorX11RenderClient(qt_intf_t* p_intf, xcb_connection_t* conn,  xcb_window_t wid, QObject *parent)
     : QObject(parent)
     , m_intf(p_intf)
-    , m_window(window)
     , m_conn(conn)
-    , m_wid(window->winId())
+    , m_wid(wid)
     , m_pixmap(m_conn)
     , m_picture(m_conn)
 {
@@ -65,9 +64,6 @@ CompositorX11RenderClient::CompositorX11RenderClient(qt_intf_t* p_intf, xcb_conn
         xcb_change_property(m_conn, XCB_PROP_MODE_REPLACE, m_wid,
                             _NET_WM_BYPASS_COMPOSITOR, XCB_ATOM_CARDINAL, 32, 1, &val);
     }
-
-    connect(window, &QWindow::widthChanged, this, &CompositorX11RenderClient::resetPixmap);
-    connect(window, &QWindow::heightChanged, this, &CompositorX11RenderClient::resetPixmap);
 }
 
 CompositorX11RenderClient::~CompositorX11RenderClient()
@@ -78,7 +74,7 @@ CompositorX11RenderClient::~CompositorX11RenderClient()
 
 xcb_drawable_t CompositorX11RenderClient::getWindowXid() const
 {
-    return m_window->winId();
+    return m_wid;
 }
 
 void CompositorX11RenderClient::createPicture()


=====================================
modules/gui/qt/maininterface/compositor_x11_renderclient.hpp
=====================================
@@ -43,7 +43,7 @@ class CompositorX11RenderClient : public QObject
 public:
     CompositorX11RenderClient(
             qt_intf_t* p_intf, xcb_connection_t* conn,
-            QWindow* window,
+            xcb_window_t wid,
             QObject* parent = nullptr);
 
     ~CompositorX11RenderClient();
@@ -58,7 +58,6 @@ public slots:
 
 private:
     qt_intf_t* m_intf;
-    QWindow* m_window = nullptr;
 
     xcb_connection_t* m_conn = 0;
     xcb_window_t m_wid = 0;


=====================================
modules/gui/qt/maininterface/compositor_x11_renderwindow.cpp
=====================================
@@ -531,7 +531,9 @@ void CompositorX11RenderWindow::setVideoWindow( QWindow* window)
 {
     //ensure Qt x11 pending operation have been forwarded to the server
     xcb_flush(qGuiApp->nativeInterface<QNativeInterface::QX11Application>()->connection());
-    m_videoClient = std::make_unique<CompositorX11RenderClient>(m_intf, m_conn, window);
+    m_videoClient = std::make_unique<CompositorX11RenderClient>(m_intf, m_conn, window->winId());
+    connect(window, &QWindow::widthChanged, m_videoClient.get(), &CompositorX11RenderClient::resetPixmap);
+    connect(window, &QWindow::heightChanged, m_videoClient.get(), &CompositorX11RenderClient::resetPixmap);
     m_videoPosition = QRect(0,0,0,0);
     m_videoWindow = window;
     emit videoSurfaceChanged(m_videoClient.get());
@@ -539,11 +541,19 @@ void CompositorX11RenderWindow::setVideoWindow( QWindow* window)
 
 void CompositorX11RenderWindow::enableVideoWindow()
 {
+    //if we stop the rendering, m_videoWindow may be null
+    if (!m_videoWindow)
+        return;
+
     emit registerVideoWindow(m_videoWindow->winId());
 }
 
 void CompositorX11RenderWindow::disableVideoWindow()
 {
+    //if we stop the rendering, m_videoWindow may be null
+    if (!m_videoWindow)
+        return;
+
     emit registerVideoWindow(0);
 }
 
@@ -558,7 +568,8 @@ void CompositorX11RenderWindow::setInterfaceWindow(CompositorX11UISurface* windo
 {
     //ensure Qt x11 pending operation have been forwarded to the server
     xcb_flush(qGuiApp->nativeInterface<QNativeInterface::QX11Application>()->connection());
-    m_interfaceClient = std::make_unique<CompositorX11RenderClient>(m_intf, m_conn, window);
+    m_interfaceClient = std::make_unique<CompositorX11RenderClient>(m_intf, m_conn, window->winId());
+    connect(window, &CompositorX11UISurface::requestPixmapReset, m_interfaceClient.get(), &CompositorX11RenderClient::resetPixmap);
     m_interfaceWindow = window;
 }
 


=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.cpp
=====================================
@@ -169,10 +169,16 @@ void CompositorX11UISurface::createFbo()
 
 void CompositorX11UISurface::destroyFbo()
 {
-    m_context->functions()->glDeleteTextures(1, &m_textureId);
-    m_textureId = 0;
-    m_context->functions()->glDeleteFramebuffers(1, &m_fboId);
-    m_fboId = 0;
+    if (m_textureId)
+    {
+        m_context->functions()->glDeleteTextures(1, &m_textureId);
+        m_textureId = 0;
+    }
+    if (m_fboId)
+    {
+        m_context->functions()->glDeleteFramebuffers(1, &m_fboId);
+        m_fboId = 0;
+    }
 }
 
 void CompositorX11UISurface::render()
@@ -367,11 +373,7 @@ void CompositorX11UISurface::resizeFbo()
     {
         const bool current = m_context->makeCurrent(this);
         assert(current);
-
-        m_context->functions()->glDeleteTextures(1, &m_textureId);
-        m_textureId = 0;
-        m_context->functions()->glDeleteFramebuffers(1, &m_fboId);
-        m_fboId = 0;
+        destroyFbo();
         createFbo();
         m_context->doneCurrent();
         updateSizes();
@@ -420,14 +422,15 @@ void CompositorX11UISurface::exposeEvent(QExposeEvent *)
         {
             m_uiRenderControl->initialize();
         }
+        emit requestPixmapReset();
         requestUpdate();
     }
 }
 
 void CompositorX11UISurface::handleScreenChange()
 {
-   m_uiWindow->setGeometry(0, 0, width(), height());
-   requestUpdate();
+    emit requestPixmapReset();
+    requestUpdate();
 }
 
 void CompositorX11UISurface::forwardFocusObjectChanged(QObject* object)


=====================================
modules/gui/qt/maininterface/compositor_x11_uisurface.hpp
=====================================
@@ -75,6 +75,8 @@ signals:
     void sizeChanged(const QSize& size);
     void updated();
 
+    void requestPixmapReset();
+
 protected:
     bool eventFilter(QObject* object, QEvent *event) override;
 
@@ -105,9 +107,8 @@ private:
 
     uint m_textureId = 0;
     qreal m_dpr = 0;
-    QOffscreenSurface *m_offscreenSurface = nullptr;
 
-    bool initialized=  false;
+    bool initialized = false;
 
     unsigned int m_fboId = 0;
 };


=====================================
modules/gui/qt/maininterface/compositor_x11_utils.cpp
=====================================
@@ -188,12 +188,18 @@ static xcb_window_t getWindowProperty(xcb_connection_t* conn, xcb_window_t windo
     if (!reply)
        return 0;
 
-    return ((xcb_window_t *)xcb_get_property_value(reply.get()))[0];
+    if (xcb_get_property_value_length(reply.get()) == 0)
+        return 0;
+
+    return *((xcb_window_t *)xcb_get_property_value(reply.get()));
 }
 
 //see https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm45894598113264
 static bool supportWMCheck(xcb_connection_t* conn, xcb_window_t rootWindow)
 {
+    if (rootWindow == 0)
+        return false;
+
     xcb_atom_t atom = getInternAtom(conn, "_NET_SUPPORTING_WM_CHECK");
     xcb_window_t wmWindow = getWindowProperty(conn, rootWindow, atom);
     if (wmWindow == 0)


=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -483,7 +483,8 @@ static inline void triggerQuit()
 {
     QMetaObject::invokeMethod(qApp, []() {
             qApp->closeAllWindows();
-            qApp->quit();
+            //at this point both UI and Vout have ended, stop Qt mainloop
+            qApp->exit();
         }, Qt::QueuedConnection);
 }
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/61d8527f544030f79e5301c8281abda1c8abdbaa...5afeb5aaefe806c6948ab767563d17077ee64295

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/61d8527f544030f79e5301c8281abda1c8abdbaa...5afeb5aaefe806c6948ab767563d17077ee64295
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list