Skip to content

Running subprocess command asynchronously still blocks main thread #17669

@llyyr

Description

@llyyr

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 #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

mpvsucks.log

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions