1
0
mirror of https://github.com/mpv-player/mpv synced 2025-02-07 15:41:55 +00:00
mpv/video/out/opengl
wm4 cc746c9508 vo_gpu: x11egl: cleanup EGL correctly
...probably.

The EGL backend had a strange problem: when recreating the window, EGL
surface creation sometimes mysteriously failed. For example, keeping the
"_" key down (cycles video by default) destroys and recreates the window
in rapid succession, which will often enough show the "Could not create
EGL surface!" message.

This was puzzling because due to mpv's architecture, the X11 Window and
even the X11 Display were fully destroyed, the thread on which they ran
was destroyed, and then everything was recreated. There shouldn't have
been any state that could make subsequent EGL initialization fail.

It turns out mpv forgot to free EGLSurfaces in the x11 code. EGL is a
pretty crazy API (full of thread local and global state with weird
lifetime requirements), and for example it seems EGLDisplay cannot be
explicitly released, but apparently implicitly dies when the native
display is closed (at least EGL 1.5 claims eglTerminate() does _not_
invalidate the display, only certain objects linked to it). It appears
that Mesa still referenced at least EGLSurface in some form, and either
some pointer or some X11 ID was dangling, and when it randomly matched
when eglCreateWindowSurface() was called, it failed.

Fix this by calling eglTerminate(), which supposedly destroys (or rather
unreferences) contexts and surfaces created from the display (but
absurdly not the display itself).

Now why can't you just destroy the display? If it's implicitly
invalidated, why can't it just call eglTerminate() implicitly when this
happens? Did Mesa do something wrong when they somehow didn't
automatically remove the dangling object (so I could claim not to be
responsible for the bug)? Who the fuck knows, and I'm too tired to
figure this out (both because it's late, and because I'm tired of this
EGL crap API).

Still not sure if the code is correct now. I think EGL was designed to
maximize implementation and API-use complications. How else could you
possibly come up with something like the EGLDisplay life cycle? Or am I
just making a fuss? Anyway, fuck EGL, fuck computers, fuck technology.

Fixes: #7129
2019-12-12 01:50:05 +01:00
..
angle_dynamic.c
angle_dynamic.h
common.c vo_gpu: opengl: do not free "GL" sub-allocations 2019-11-29 20:23:27 +01:00
common.h
context_android.c context_android: move common code to a separate file 2019-09-27 00:05:06 +03:00
context_angle.c vo: make swapchain-depth option generic for all VOs 2019-09-28 14:10:01 +03:00
context_cocoa.c
context_drm_egl.c drm: avoid division by 0 in drm_pflip_cb with bad drivers 2019-12-07 18:34:25 +01:00
context_dxinterop.c vo: make swapchain-depth option generic for all VOs 2019-09-28 14:10:01 +03:00
context_glx.c vo_gpu: context_glx: Add X11 native resource 2019-11-16 15:35:32 -08:00
context_rpi.c rpi: destroy fullscreen change handling 2019-12-11 18:50:37 +01:00
context_wayland.c wayland: use eglGetPlatformDisplay() 2019-11-16 14:23:07 -06:00
context_win.c
context_x11egl.c vo_gpu: x11egl: cleanup EGL correctly 2019-12-12 01:50:05 +01:00
context.c vo_gpu/opengl: fully initialize FBO when passing it to rendering 2019-10-30 15:54:41 +01:00
context.h vo: use a struct for vsync feedback stuff 2018-12-06 10:30:25 +01:00
egl_helpers.c
egl_helpers.h
formats.c
formats.h
gl_headers.h vo_gpu: opengl: add hack for ancient Mesa/GLX 2019-11-30 13:38:28 +01:00
hwdec_d3d11egl.c vo_gpu: hwdec_d3d11egl: add missing P010 format to supported list 2019-10-17 22:45:05 +02:00
hwdec_drmprime_drm.c vo_gpu: hwdec_drmprime_drm: add hwdec ctx 2019-09-27 13:08:27 +02:00
hwdec_dxva2egl.c
hwdec_dxva2gldx.c
hwdec_ios.m
hwdec_osx.c
hwdec_rpi.c
hwdec_vdpau.c vo_gpu: vdpau actually works under EGL 2019-11-07 22:53:13 +01:00
libmpv_gl.c
oml_sync.c oml_sync: fix typo in comment 2019-09-20 00:32:29 +02:00
oml_sync.h vo_gpu: glx: move OML sync code to an independent file 2019-09-08 23:23:43 +10:00
ra_gl.c vo_gpu: opengl: add support for IMGFMT_RGB30 2019-11-02 17:46:46 +01:00
ra_gl.h
utils.c
utils.h