1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-12 18:02:36 +00:00
mpv/video
Dudemanguy 296d40dc6f vo: fix race condition with redraw requests
There is a very subtle race in vo that can manifest itself on pause
events. In the renderloop, render_frame, unsurprisingly, does the heavy
lifting of actually queuing up and flipping the frames. This is called
during normal playback. Sometimes various parts of the player can make a
redraw request which will latter trigger another render of the frame
later down in the loop (do_redraw). Because these requests can happen at
essentially anytime, sometimes the redraw request will happen *before*
do_redraw and it'll be caught in render_frame. When this happens,
the existing render_frame run works perfectly fine as a redraw so it
clears out the request which is sensible. Normally this is all locked of
course, but there's one catch. render_frame has to unlock itself when
propagating down into specific VOs/backends. That's what causes this
bug.

While render_frame is unlocked, other parts of the player can send
redraw requests which will cause in->request_redraw to become true. The
logic in the code always clears out this parameter after a successful
render, but this isn't correct. When in->request_become becomes true in
the middle of render_frame, there needs to be one more draw afterwards
to reflect whatever actually changed (usually the OSD). Instead, this
gets simply discarded. If you rapidly spam pause while rendering things
to the OSD at the same time, it's possible to for the last render to
be behind a frame and appear as if your osd event was ignored.

Once you realize what is happening, the fix is quite simple. Just store
the initial value of in->request_redraw before the unlock step. After we
do the render step and unlock again, only set in->request_redraw to
false if there was an initial redraw request. We just finished doing a
redraw, so it is safe to clear. Otherwise, leave in->request_redraw
alone. If it is initially false, then it will still be false and nothing
changes. However if it updated to true in the middle of the rendering,
this value is now preserved so we can go and call do_redraw later and
show what that last frame was meant to be when you pause. One
unfortunate thing about this design is that it is technically possible
for other internal things in vo to update during that unlocked period.
Hopefully, that doesn't actually happen and only redraw requests work
like this.

Fixes #8172 and #8350.
2023-03-02 22:09:10 +00:00
..
decode vd_lavc: sort hwdecs without hwdevices last for autoprobing 2023-02-26 16:40:59 +01:00
filter vf_gpu: initialize depth=1 on target textures 2023-02-28 14:13:55 +00:00
out vo: fix race condition with redraw requests 2023-03-02 22:09:10 +00:00
csputils.c vo_gpu: improve XYZ conversion 2023-03-02 09:37:06 -05:00
csputils.h csputils: add MP_CSP_TRC_ST428 as defined in ST 428-1 2023-03-02 09:37:06 -05:00
cuda.c various: drop unused #include "config.h" 2023-02-20 14:21:18 +00:00
d3d.c
d3d.h
drmprime.c various: drop unused #include "config.h" 2023-02-20 14:21:18 +00:00
fmt-conversion.c various: drop unused #include "config.h" 2023-02-20 14:21:18 +00:00
fmt-conversion.h
hwdec.c
hwdec.h
image_loader.c
image_loader.h
image_writer.c options: transition options from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
image_writer.h options: transition options from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
img_format.c various: drop unused #include "config.h" 2023-02-20 14:21:18 +00:00
img_format.h filters/f_hwtransfer: remove VAAPI <-> Vulkan mapping for now 2022-10-29 18:49:46 -07:00
mp_image_pool.c various: drop unused #include "config.h" 2023-02-20 14:21:18 +00:00
mp_image_pool.h
mp_image.c mp_image: fix XYZ gamma and primaries guess 2023-03-02 09:37:06 -05:00
mp_image.h mp_image: forward AV_FRAME_DATA_DOVI_RPU_BUFFER side data 2023-02-19 20:50:37 +01:00
repack.c
repack.h
sws_utils.c test: integrate unittests with meson 2023-03-02 15:45:27 +00:00
sws_utils.h
vaapi.c
vaapi.h
vdpau_functions.inc
vdpau_mixer.c
vdpau_mixer.h options: transition options from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00
vdpau.c
vdpau.h
zimg.c zimg: fix MP_CSP_PRIM_CIE_1931 mapping 2023-03-02 09:37:06 -05:00
zimg.h options: transition options from OPT_FLAG to OPT_BOOL 2023-02-21 17:15:17 +00:00