Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc display sync fixes #15259

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

llyyr
Copy link
Contributor

@llyyr llyyr commented Nov 4, 2024

First two commits are entirely theoretical, it's more correct but it probably doesn't matter much because this code is only used to detect underruns and to wait for a frame to finish before applying new image_params.

Third commit fixes a real world problem with bad drivers that I encountered while testing various wip fifo-v1/commit-timing implementations. By not always updating base_vsync, we could potentially end up in a permanent underflow state and never recover from it even once the driver has stopped giving us bogus values.

Copy link

github-actions bot commented Nov 4, 2024

Download the artifacts for this pull request:

Windows
macOS

video/out/vo.c Outdated
@@ -489,11 +489,14 @@ static void update_vsync_timing_after_swap(struct vo *vo,
}

in->num_successive_vsyncs++;
if (in->num_successive_vsyncs <= DELAY_VSYNC_SAMPLES)
if (in->num_successive_vsyncs <= DELAY_VSYNC_SAMPLES) {
in->base_vsync += in->vsync_interval;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is correct to increment base_vsync here. It is updated in update_vsync_timing_after_swap and this function makes sure valid value is used. base_vsync is last valid point, incrementing with with interval will accumulate a lot of drift, making this value unreliable.

Copy link
Contributor Author

@llyyr llyyr Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it makes more sense to set it to the actual vsync instead of incrementing by nominal vsync interval. Updated the patch

This is still used for caclulating a/v sync and delay remaining even
for initial samples, so we should always update it to the actual vsync
for those initial samples so we have something to work with at least.

And if we receive bogus values, also reset it to 0 along with
prev_vsync.

Not having base_vsync set to _some_ value completely breaks
vsync_skip_detection, and mpv stays stuck in a permanent mistimed state
where every frame is marked as delayed and never recovers from it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants