Skip to content

Truly independent web browser

UI/Qt: Release the Wayland Vulkan swapchain before moving a tab

Timothy Flynn67215ded41d9
diff --git a/UI/Qt/WebContentView.cpp b/UI/Qt/WebContentView.cpp
index e7272cdbf72..a9989b17a12 100644
--- a/UI/Qt/WebContentView.cpp
+++ b/UI/Qt/WebContentView.cpp
@@ -418,6 +418,8 @@ void WebContentView::prepare_for_window_move()
QCoreApplication::sendEvent(this, &window_about_to_change_event);
destroy();
+#elif defined(LADYBIRD_QT_USE_VULKAN_WINDOW)
+ release_vulkan_window_surface_for_move();
#endif
}
@@ -434,6 +436,9 @@ void WebContentView::finish_window_move()
install_accessibility(this);
# endif
show();
+#elif defined(LADYBIRD_QT_USE_VULKAN_WINDOW)
+ if (m_vulkan_window && QGuiApplication::platformName().startsWith(QStringLiteral("wayland")))
+ schedule_vulkan_window_update();
#endif
}
diff --git a/UI/Qt/WebContentView.h b/UI/Qt/WebContentView.h
index 96351b09f6a..b32851c7127 100644
--- a/UI/Qt/WebContentView.h
+++ b/UI/Qt/WebContentView.h
@@ -456,6 +456,7 @@ private:
friend struct VulkanWindowRenderer;
void create_vulkan_window();
+ void release_vulkan_window_surface_for_move();
void destroy_vulkan_window();
void update_vulkan_window_mask();
void update_vulkan_alpha_blending_support();
diff --git a/UI/Qt/WebContentViewLinux.cpp b/UI/Qt/WebContentViewLinux.cpp
index 1714543e74a..edc57f25b1f 100644
--- a/UI/Qt/WebContentViewLinux.cpp
+++ b/UI/Qt/WebContentViewLinux.cpp
@@ -1215,6 +1215,17 @@ void WebContentView::fall_back_from_vulkan_window()
});
}
+void WebContentView::release_vulkan_window_surface_for_move()
+{
+ if (!m_vulkan_window || !QGuiApplication::platformName().startsWith(QStringLiteral("wayland")))
+ return;
+
+ // Qt can destroy a Wayland surface during reparenting without notifying QVulkanWindow. Destroy the native window
+ // explicitly so QVulkanWindow releases its swapchain before Qt destroys the surface.
+ set_vulkan_window_container_visible(false);
+ m_vulkan_window->destroy();
+}
+
void WebContentView::destroy_vulkan_window()
{
if (m_vulkan_window)