From 251d333231f5473bb53e4805a016fefc59b6b209 Mon Sep 17 00:00:00 2001 From: Swung0x48 Date: Thu, 24 Sep 2026 14:03:48 +0000 Subject: [PATCH] [MG_Backend] (P12 review): Magma's renderer is dropped when a server session ends, so a session that ended without a clean teardown leaves nothing attached to the server's window The Vulkan renderer (swapchain and VkSurfaceKHR on the window) is a process global that only ReleaseEGLResources or a released surface drops, and ~BackendObject_DirectVulkan was defaulted. A client that went away without eglTerminate (a crash, a kill, a dropped connection) sends neither, so after its session the renderer stayed on the display Activity's window past the end of the session's lease. Under a transport the server backend's destruction - the session's end, on the apply thread, before the lease ends - now drops the renderer (with the generation bump and the program reflection caches, as ReleaseEGLResources does). Split build only; the pull build's destructor is still defaulted (G1). --- .../BackendObject_DirectVulkan.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/MobileGL/MG_Backend/DirectVulkan/BackendObject_DirectVulkan.cpp b/MobileGL/MG_Backend/DirectVulkan/BackendObject_DirectVulkan.cpp index 64c8de26..8822111b 100644 --- a/MobileGL/MG_Backend/DirectVulkan/BackendObject_DirectVulkan.cpp +++ b/MobileGL/MG_Backend/DirectVulkan/BackendObject_DirectVulkan.cpp @@ -330,7 +330,25 @@ namespace MobileGL::MG_Backend::DirectVulkan { PopulateFormatCapabilitiesImpl(physicalDevice, getFormatProperties, capabilities, cache); } +#if MOBILEGL_BUILD_DISAGGREGATED + BackendObject_DirectVulkan::~BackendObject_DirectVulkan() { + // P12 review fix: A SERVER SESSION THAT ENDS WITHOUT A CLEAN TEARDOWN LEAVES NO RENDERER ON + // THE WINDOW. The renderer - swapchain and VkSurfaceKHR on the window - is a process global + // that only ReleaseEGLResources / a released surface drops, and a client that went away + // without eglTerminate (a crash, a kill, a dropped connection) sends neither. Under a + // transport this object is the server's and its destruction is the session's end (ServerLoop's + // apply thread, after the final drain, before the display lease ends), so the renderer goes + // here: nothing of the ended session keeps presenting into, or holding a surface on, the + // server's window once its lease is over. Monolith keeps its renderer. + if (MG_Config::Transport != MG_Config::TransportMode::Monolith && pVulkanRenderer != nullptr) { + BumpRendererGeneration(); + pVulkanRenderer.reset(); + ClearProgramResourceCaches(); + } + } +#else BackendObject_DirectVulkan::~BackendObject_DirectVulkan() = default; +#endif BackendObject_DirectVulkan::BackendObject_DirectVulkan() : m_rendererInfo{GetRendererIdentity()} {}