fix: handle EGL surface creation failure gracefully instead of aborting

When GPU VRAM is exhausted, eglCreatePlatformWindowSurfaceEXT and
wl_egl_window_create can return null. Previously this triggered
RASSERT -> std::abort(), crashing hyprlock and leaving the session
in a broken lock state.

Replace RASSERT with error logging and early return, setting
readyForFrame = false so the next configure event retries the
allocation. This allows hyprlock to survive transient GPU memory
pressure rather than crashing.

Fixes: https://github.com/hyprwm/hyprlock/issues/986
This commit is contained in:
Nilesh 2026-04-09 17:34:06 -07:00
parent d7079a1248
commit 2393fb7590

View file

@ -84,13 +84,21 @@ void CSessionLockSurface::configure(const Vector2D& size_, uint32_t serial_) {
if (!eglWindow) {
eglWindow = wl_egl_window_create((wl_surface*)surface->resource(), size.x, size.y);
RASSERT(eglWindow, "Couldn't create eglWindow");
if (!eglWindow) {
Debug::log(ERR, "Couldn't create eglWindow (GPU memory pressure?), will retry on next configure");
readyForFrame = false;
return;
}
} else
wl_egl_window_resize(eglWindow, size.x, size.y, 0, 0);
if (!eglSurface) {
eglSurface = g_pEGL->eglCreatePlatformWindowSurfaceEXT(g_pEGL->eglDisplay, g_pEGL->eglConfig, eglWindow, nullptr);
RASSERT(eglSurface, "Couldn't create eglSurface");
if (!eglSurface) {
Debug::log(ERR, "Couldn't create eglSurface (GPU memory pressure?), will retry on next configure");
readyForFrame = false;
return;
}
}
if (readyForFrame && !(SAMESIZE && SAMESCALE)) {