Running subprocess command asynchronously still blocks main thread
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 37k
- Forks
- 3.5k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 22
Description
mpv Information
mpv v0.41.0-390-g4f9f1ffaf Copyright © 2000-2026 mpv/MPlayer/mplayer2 projects
built on Mar 29 2026 14:42:33
libplacebo version: v7.362.0 (v7.360.0-11-g33b5dfada6a8)
FFmpeg version: N-123518-gc49f6bec20cc
FFmpeg library versions:
libavcodec 62.29.100
libavdevice 62.4.100
libavfilter 11.15.101
libavformat 62.13.101
libavutil 60.29.100
libswresample 6.4.100
libswscale 9.7.100
Other Information
- Linux version: TW
- Kernel Version: 7.0.0-rc5
- GPU Model: 6600 XT
- Mesa/GPU Driver Version: Mesa 26.1.0-devel (git-93d7f01578)
- Window Manager and Version: sway version 1.13-dev-876bd7f653f5
- Source of mpv: Self built
- Latest known working version: Never worked
- Issue started after the following happened: N/A
Reproduction Steps
mp.add_key_binding("s", "crackle", function()
for i = 1, 1000 do
mp.command_native_async({
name = "subprocess",
args = { "true" }
}, function() end)
end
end)
Run mpv with this script and press s to run "true" command which does nothing one thousand times.
For ease of debugging, this command is sufficient to reproduce the problem:
sh -c 't=$(mktemp --suffix=.lua) || exit; echo "mp.add_key_binding(\"s\",\"crackle\",function() for i=1,1000 do mp.command_native_async({name=\"subprocess\",args={\"true\"}},function() end) end end)" > "$t"; mpv --no-config "av://lavfi:testsrc" --audio-file="av://lavfi:anoisesrc=color=pink:amplitude=0.02" --scripts="$t"; rm "$t"'
Press s after mpv opens.
I've only opened this issue for Linux as that's the only platform I use, but it might be an issue on other platforms too. I looked into this issue because of the thumbnailer script that was added in https://github.com/mpv-player/mpv/pull/17518 at some point, and had audio crackling issues when moving the cursor across the seekbar. The reproducer script runs 1000 commands to make the issue obvious.
Expected Behavior
Running subprocess command with command_native_async doesn't block mpv.
Actual Behavior
Running subprocess command with command_native_async blocks mpv.
Log File
Sample Files
No response
I carefully read all instruction and confirm that I did the following:
- I tested and confirmed that the issue exists with the latest release version or newer.
- I provided all required information including system and mpv version.
- I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of
--log-file=output.txt. - I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
- I attached the full, untruncated log file.
- I attached the backtrace in the case of a crash.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the mp.command_native_async subprocess path and reproduce the issue using the provided Lua script that launches 1,000 true commands. Trace why these asynchronous subprocesses block playback on Linux; done means the reproduction no longer causes mpv to block or audio to crackle.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, lua
- Domain
- cli, desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100