Skip to content

Commit f30cb0e

Browse files
committed
egl-wayland: Initialize streamImages during Pbuffer surface creation
We are missing the initializer for the streamImages wl_list in wlEglCreatePbufferSurfaceHook. This ensures the list is valid when we eventually destroy the surface and have to check the list contents. This change adds a common initialization function wlEglInitializeSurfaceCommon which is used by both surface creators to set up common state such as these wl_lists. This fixes crashes with qt6webengine.
1 parent 5a5b17e commit f30cb0e

File tree

1 file changed

+20
-17
lines changed

1 file changed

+20
-17
lines changed

src/wayland-eglsurface.c

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,22 @@ getWlEglWindowVersionAndSurface(struct wl_egl_window *window,
26092609
}
26102610
}
26112611

2612+
static bool
2613+
wlEglInitializeSurfaceCommon(WlEglDisplay *display,
2614+
WlEglSurface *surface,
2615+
EGLConfig config)
2616+
{
2617+
surface->wlEglDpy = display;
2618+
surface->eglConfig = config;
2619+
surface->syncPoint = 1;
2620+
surface->refCount = 1;
2621+
surface->isDestroyed = EGL_FALSE;
2622+
wl_list_init(&surface->ctx.streamImages);
2623+
wl_list_init(&surface->oldCtxList);
2624+
2625+
return wlEglInitializeMutex(&surface->ctx.streamImagesMutex);
2626+
}
2627+
26122628
EGLSurface wlEglCreatePlatformWindowSurfaceHook(EGLDisplay dpy,
26132629
EGLConfig config,
26142630
void *nativeWin,
@@ -2669,17 +2685,17 @@ EGLSurface wlEglCreatePlatformWindowSurfaceHook(EGLDisplay dpy,
26692685
goto fail;
26702686
}
26712687

2672-
if (!wlEglInitializeMutex(&surface->mutexLock)) {
2688+
if (!wlEglInitializeSurfaceCommon(display, surface, config)) {
26732689
err = EGL_BAD_ALLOC;
26742690
goto fail;
26752691
}
26762692

2677-
if (!wlEglInitializeMutex(&surface->mutexFrameSync)) {
2693+
if (!wlEglInitializeMutex(&surface->mutexLock)) {
26782694
err = EGL_BAD_ALLOC;
26792695
goto fail;
26802696
}
26812697

2682-
if (!wlEglInitializeMutex(&surface->ctx.streamImagesMutex)) {
2698+
if (!wlEglInitializeMutex(&surface->mutexFrameSync)) {
26832699
err = EGL_BAD_ALLOC;
26842700
goto fail;
26852701
}
@@ -2689,18 +2705,11 @@ EGLSurface wlEglCreatePlatformWindowSurfaceHook(EGLDisplay dpy,
26892705
goto fail;
26902706
}
26912707

2692-
wl_list_init(&surface->ctx.streamImages);
2693-
2694-
surface->wlEglDpy = display;
2695-
surface->eglConfig = config;
26962708
surface->wlEglWin = window;
26972709
surface->ctx.eglStream = EGL_NO_STREAM_KHR;
26982710
surface->ctx.eglSurface = EGL_NO_SURFACE;
26992711
surface->ctx.isOffscreen = EGL_FALSE;
27002712
surface->isSurfaceProducer = EGL_TRUE;
2701-
surface->refCount = 1;
2702-
surface->isDestroyed = EGL_FALSE;
2703-
surface->syncPoint = 1;
27042713
// FIFO_LENGTH == 1 to set FIFO mode, FIFO_LENGTH == 0 to set MAILBOX mode
27052714
// We set two here however to bump the "swapchain" count to 4 on Wayland.
27062715
// This is done to better match what Mesa does, as apparently 4 is the
@@ -2732,7 +2741,6 @@ EGLSurface wlEglCreatePlatformWindowSurfaceHook(EGLDisplay dpy,
27322741
getWlEglWindowVersionAndSurface(window,
27332742
&surface->wlEglWinVer,
27342743
&surface->wlSurface);
2735-
wl_list_init(&surface->oldCtxList);
27362744

27372745
err = assignWlEglSurfaceAttribs(surface, attribs);
27382746
if (err != EGL_SUCCESS) {
@@ -2883,18 +2891,13 @@ EGLSurface wlEglCreatePbufferSurfaceHook(EGLDisplay dpy,
28832891
goto fail;
28842892
}
28852893

2886-
if (!wlEglInitializeMutex(&surface->mutexLock)) {
2894+
if (!wlEglInitializeSurfaceCommon(display, surface, config)) {
28872895
err = EGL_BAD_ALLOC;
28882896
goto fail;
28892897
}
28902898

2891-
surface->wlEglDpy = display;
2892-
surface->eglConfig = config;
28932899
surface->ctx.eglSurface = surf;
28942900
surface->ctx.isOffscreen = EGL_TRUE;
2895-
surface->refCount = 1;
2896-
surface->isDestroyed = EGL_FALSE;
2897-
wl_list_init(&surface->oldCtxList);
28982901

28992902
wl_list_insert(&display->wlEglSurfaceList, &surface->link);
29002903
pthread_mutex_unlock(&display->mutex);

0 commit comments

Comments
 (0)