diff --git a/src/Ryujinx/AppHost.cs b/src/Ryujinx/AppHost.cs index 909cd20aa..45d5a45eb 100644 --- a/src/Ryujinx/AppHost.cs +++ b/src/Ryujinx/AppHost.cs @@ -43,6 +43,7 @@ using Ryujinx.UI.Common.Configuration; using Ryujinx.UI.Common.Helper; using Silk.NET.Vulkan; using SkiaSharp; +using SPB.Graphics.Exceptions; using SPB.Graphics.Vulkan; using System; using System.Collections.Generic; @@ -640,8 +641,22 @@ namespace Ryujinx.Ava if (RendererHost.EmbeddedWindow is EmbeddedWindowOpenGL openGlWindow) { - // Try to bind the OpenGL context before calling the shutdown event. - openGlWindow.MakeCurrent(false, false); + try + { + // Try to bind the OpenGL context before disposing GPU resources. + openGlWindow.MakeCurrent(); + } + catch (ContextException e) when (_userChannelPersistence.ShouldRestart) + { + // ExecuteProgram may detach the old native window before GPU + // disposal. Allow the old context to be released with the window + // and continue the requested program relaunch. + Logger.Warning?.Print( + LogClass.UI, + $"Failed to bind OpenGL context during program relaunch: {e}"); + + return; + } Device.DisposeGpu();