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

Fix stalls on ffmpeg based decoder reset #7998

Merged
merged 2 commits into from
Nov 5, 2024

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Nov 5, 2024

What

(All perf numbers on Windows which is well known for slower process handling compared to its competitors.)

Makes the ffmpeg listen/write thread shutdown much more rigorous. It worked fine before, but on Windows in particular I often noticed long stalls:
383056190-113e4efa-3376-4b7b-96cf-dfd79fac8e4d

This happened mostly due to delays in "noticing" that ffmpeg was shut down already. The shutdown fixes themselves, make the problem almost go away. But it still happens that the "listen thread" takes a fair while until it closes:
image

Occasionally I also still observed 100ms+ for this operation, especially when having several decoders open at the same time (coincidence? did that just make it more likely to get a bad one or is there more to it?). So I decided to have the thread shut down in the background instead - this is safe now, since the on_output callback gets disconnected prior to the shutdown.

No profiler picture for this, since there's nothing left to look at ;-)

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!
  • If have noted any breaking changes to the log API in CHANGELOG.md and the migration guide

To run all checks from main, comment on the PR with @rerun-bot full-check.

@Wumpf Wumpf added 🚀 performance Optimization, memory use, etc exclude from changelog PRs with this won't show up in CHANGELOG.md 🎞️ video labels Nov 5, 2024
@Wumpf Wumpf force-pushed the andreas/ffmpeg-improved-shutdown-sequence branch from c88c04a to 02787a2 Compare November 5, 2024 15:18
@Wumpf Wumpf merged commit 8b2b7b3 into main Nov 5, 2024
36 checks passed
@Wumpf Wumpf deleted the andreas/ffmpeg-improved-shutdown-sequence branch November 5, 2024 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
exclude from changelog PRs with this won't show up in CHANGELOG.md 🚀 performance Optimization, memory use, etc 🎞️ video
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants