mpv/video/out
wm4 4d43c79e4c client API: fix potential deadlock problems by throwing more shit at it
The render API (vo_libmpv) had potential deadlock problems with
MPV_RENDER_PARAM_ADVANCED_CONTROL. This required vd-lavc-dr to be
enabled (the default). I never observed these deadlocks in the wild
(doesn't mean they didn't happen), although I could specifically provoke
them with some code changes.

The problem was mostly about DR (direct rendering, letting the video
decoder write to OpenGL buffer memory). Allocating/freeing a DR image
needs to be done on the OpenGL thread, even though _lots_ of threads are
involved with handling images. Freeing a DR image is a special case that
can happen any time. dr_helper.c does most of the evil magic of
achieving this. Unfortunately, there was a (sort of) circular lock
dependency: freeing an image while certain internal locks are held would
trigger the user's context update callback, which in turn would call
mpv_render_context_update(), which processed all pending free requests,
and then acquire an internal lock - which the caller might not release
until a further DR image could be freed.

"Solve" this by making freeing DR images asynchronous. This is slightly
risky, but actually not much. The DR images will be free'd eventually.
The biggest disadvantage is probably that debugging might get trickier.

Any solution to this problem will probably add images to free to some
sort of queue, and then process it later. I considered making this more
explicit (so there'd be a point where the caller forcibly waits for all
queued items to be free'd), but discarded these ideas as this probably
would only increase complexity.

Another consequence is that freeing DR images on the GL thread is not
synchronous anymore. Instead, it mpv_render_context_update() will do it
with a delay. This seems roundabout, but doesn't actually change
anything, and avoids additional code.

This also fixes that the render API required the render API user to
remain on the same thread, even though this wasn't documented. As such,
it was a bug. OpenGL essentially forces you to do all GL usage on a
single thread, but in theory the API user could for example move the GL
context to another thread.

The API bump is because I think you can't make enough noise about this.
Since we don't backport fixes to old versions, I'm specifically stating
that old versions are broken, and I'm supplying workarounds.

Internally, dr_helper_create() does not use pthread_self() anymore, thus
the vo.c change. I think it's better to make binding to the current
thread as explicit as possible.

Of course it's not sure that this fixes all deadlocks (probably not).
2019-09-26 14:14:49 +02:00
..
cocoa
cocoa-cb cocoa-cb: add support for 10bit opengl rendering 2019-09-26 00:02:02 +02:00
d3d11 vo_gpu: d3d11: add support for presentation feedback 2019-09-22 23:18:40 +10:00
gpu rpi: Update for modern systems 2019-09-20 11:39:06 +02:00
hwdec vo_gpu: hwdec_vaegl: silence confusing message during probing 2019-09-19 20:37:05 +02:00
opengl context_drm_egl: Don't get stuck forever if drmHandleEvent fails 2019-09-22 22:39:10 +02:00
placebo
vulkan
win32
aspect.c aspect: add video margin options 2019-09-19 20:37:05 +02:00
aspect.h
bitmap_packer.c
bitmap_packer.h
cocoa_cb_common.swift
cocoa_common.h
cocoa_common.m
d3d_shader_420p.h
d3d_shader_yuv.hlsl
dither.c
dither.h
dr_helper.c client API: fix potential deadlock problems by throwing more shit at it 2019-09-26 14:14:49 +02:00
dr_helper.h client API: fix potential deadlock problems by throwing more shit at it 2019-09-26 14:14:49 +02:00
drm_atomic.c
drm_atomic.h
drm_common.c drm_common: add missing zero-initialization of struct vt_mode variable 2019-09-24 21:46:52 +02:00
drm_common.h
drm_prime.c
drm_prime.h
filter_kernels.c
filter_kernels.h
libmpv.h
vo.c client API: fix potential deadlock problems by throwing more shit at it 2019-09-26 14:14:49 +02:00
vo.h vo: remove unused equalizer control remains 2019-09-20 00:45:17 +02:00
vo_caca.c
vo_direct3d.c
vo_drm.c vo_drm: 30bpp support 2019-09-22 15:59:24 +02:00
vo_gpu.c
vo_image.c
vo_lavc.c
vo_libmpv.c client API: fix potential deadlock problems by throwing more shit at it 2019-09-26 14:14:49 +02:00
vo_mediacodec_embed.c
vo_null.c
vo_rpi.c
vo_sdl.c vo_sdl: Only create the SDL window once 2019-09-21 12:58:01 +02:00
vo_tct.c
vo_vaapi.c
vo_vdpau.c
vo_x11.c
vo_xv.c
w32_common.c
w32_common.h
wayland_common.c wayland: create current_output in wayland_reconfig 2019-09-22 03:33:21 +00:00
wayland_common.h wayland: don't show cursor when fullscreening 2019-09-21 15:24:06 +02:00
win_state.c win_state: silence a valgrind warning 2019-09-19 20:37:05 +02:00
win_state.h
x11_common.c x11: fix ICC profiling for multiple monitors 2019-09-21 15:36:16 +02:00
x11_common.h x11: fix ICC profiling for multiple monitors 2019-09-21 15:36:16 +02:00