Skip to content

Commit

Permalink
vo: Fix race condition causing redraw requests to be ignored
Browse files Browse the repository at this point in the history
This manifested most frequently as a bug where the OSD fails to update
after pausing or single-stepping forwards (issues mpv-player#8172, mpv-player#8350).

In `render_frame`, the vo thread takes the lock once before rendering
the frame, and once after. The lock is relinquished whilst the frame is
actually rendering.

The redraw_request flag was being cleared whilst holding the lock
*after* the video frame has been rendered; however this frame was
rendered according to the request fetched whilst holding the lock the
first time. If the OSD was updated during the rendering of this frame,
the redraw request is cleared once the frame finishes rendering even
though the updated OSD is not included in the rendered frame.
  • Loading branch information
chengsun authored and avih committed Jan 25, 2022
1 parent e5bd1d4 commit d4f2b84
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions video/out/vo.c
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ static bool render_frame(struct vo *vo)
} else {
in->rendering = true;
in->hasframe_rendered = true;
in->request_redraw = false;
int64_t prev_drop_count = vo->in->drop_count;
// Can the core queue new video now? Non-display-sync uses a separate
// timer instead, but possibly benefits from preparing a frame early.
Expand Down Expand Up @@ -997,8 +998,6 @@ static bool render_frame(struct vo *vo)

if (in->dropped_frame) {
MP_STATS(vo, "drop-vo");
} else {
in->request_redraw = false;
}

if (in->current_frame && in->current_frame->num_vsyncs &&
Expand Down

0 comments on commit d4f2b84

Please sign in to comment.