mpv icon indicating copy to clipboard operation
mpv copied to clipboard

Resizing the mpv window fast causes the system to stutter

Open AhmedHalim96 opened this issue 10 months ago • 11 comments

mpv Information

mpv v0.40.0 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
libplacebo version: v7.349.0
FFmpeg version: 7.1.1
FFmpeg library versions:
   libavcodec      61.19.101
   libavdevice     61.3.100
   libavfilter     10.4.100
   libavformat     61.7.100
   libavutil       59.39.100
   libswresample   5.3.100
   libswscale      8.3.100

Other Information

- Linux version:Fedora Linux 42 (Adams)
- Kernel Version: Linux fedora 6.14.9-300.fc42.x86_64
- GPU Model: Nvidia 3050 Mobile
- Mesa/GPU Driver Version: 575.57.08 and Mesa 25.0.7
- Window Manager and Version: AwesomeWM v4.3
- Source of mpv: The fedora repos
- Latest known working version: Not sure. probably version 39 or whatever was on fedora 41 as I noticed the issue after fedora 42 upgrade
- Issue started after the following happened: I upgraded to fedora 42. which upgraded mpv from 39 to version 40

Reproduction Steps

  1. Run mpv --no-config ./lab.mp4
  2. resizing the window using the mouse or keyboard somewhat fast.

Expected Behavior

it resizes without an issue

Actual Behavior

The whole system freezes for a second then continue

Log File

output.txt

also might be helpful running journalctl -f throws these warnings when the stutter happen

fedora kernel: NVRM: kdispApplyWarForBug3385499_v03_00: timeout waiting for METHOD_EXEC to IDLE
fedora kernel: NVRM: kdispApplyWarForBug3385499_v03_00: timeout waiting for channel state to UNCONNECTED

Sample Files

https://github.com/user-attachments/assets/e1a468c0-e27e-4bed-8e21-6849fd1d91b7

I carefully read all instruction and confirm that I did the following:

  • [x] I tested with the latest mpv version to validate that the issue is not already fixed.
  • [x] I provided all required information including system and mpv version.
  • [x] 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.
  • [x] I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • [x] I attached the full, untruncated log file.
  • [x] I attached the backtrace in the case of a crash.

AhmedHalim96 avatar Jun 11 '25 10:06 AhmedHalim96

I can confirm the same issue, observed when moving from F40 to F42 which updated from mpv-0.37 (my guess) to 0.40. I've downgraded mpv to 0.39 (https://koji.fedoraproject.org/koji/buildinfo?buildID=2648945) which resolved the problem. Not only resize was very slow, the system would freeze for about 1-2s with normal usage (I assume because some other video would play in Chrome). I've also tried with various vo (hwdec vaapi/vaapi-copy) and LIBVA_DRIVER_NAME (iHD/nvidia) settings but all exhibited the same problem. Can also confirm the same nvidia driver output in dmesg as the one above.

muresan avatar Jun 30 '25 11:06 muresan

Older versions were using --gpu-api=opengl by default, newer use Vulkan by default --gpu-api=vulkan. There was also a change to swapchain recreation, that would affect resizing https://github.com/mpv-player/mpv/commit/d2f3b6643964ada78803e7ef2d50b60f5c275acf

If you can test with this patch reverted it would be helpful.

/cc @llyyr

kasper93 avatar Jun 30 '25 12:06 kasper93

I can't reproduce the issue on i3 here. Are both of you using Nvidia cards and/or the same window manager?

FWIW it is theoretically a possibility that Nvidia's X11 WSI implementation returns VK_SUBOPTIMAL on both AcquireNextImage and QueuePresent, but the original log only resizes 7 times in a 11-12 second log so I highly doubt that's the case. In any case that can be tested if you switch to gpu-api=opengl.

llyyr avatar Jun 30 '25 15:06 llyyr

Using --gpu-api=vulkan I was able to reproduce it on 0.39, stuttering without any resize, just drag the window around, almost locking the system when resizing and also when dragging the window from one monitor to another (laptop panel <-> external monitor). It also takes visibly longer to even display the 1st frame (and to stop playback) of the sample video, for example using the video above at 4x speed, it took real 0m4.487s with OpenGL and real 0m5.806s with Vulkan.

Upgraded to 0.40 and with --gpu-api=opengl there is no stuttering.

Fedora 42, NVidia driver 575.64, XFCE for WM on X11.

I also tested with the patch above reverted (added .allow_suboptimal = true,) and it made no difference, opengl works, vulkan stutters. Now that I've installed the mpv build dependencies locally I can test more if needed.

I've tried to pinpoint the stutter and while running with -v I can see:

Jul 02 14:31:49 [statusline] V: 00:00:02 / 00:00:13 (20%)
Jul 02 14:31:49 [lavf] bytes=83856, read_more=0 prefetch_more=0, refresh_more=0
Jul 02 14:31:49 [statusline] V: 00:00:02 / 00:00:13 (20%)
Jul 02 14:31:49 [cplayer] video_output_image: r=2/eof=0/st=playing
Jul 02 14:31:53 [statusline] V: 00:00:02 / 00:00:13 (20%)
Jul 02 14:31:53 [vo/gpu/libplacebo] vk->GetSwapchainImagesKHR(vk->dev, p->swapchain, &num_images, NULL)
Jul 02 14:31:53 [statusline] V: 00:00:02 / 00:00:13 (20%)
Jul 02 14:31:53 [vo/gpu/libplacebo] vk->GetSwapchainImagesKHR(vk->dev, p->swapchain, &num_images, vkimages)
Jul 02 14:31:53 [statusline] V: 00:00:02 / 00:00:13 (20%)
Jul 02 14:31:53 [vo/gpu/libplacebo] vk->CreateImageView(vk->dev, &vinfo, PL_VK_ALLOC, &tex_vk->view)

4s stutter because of a resize. Then I press q to quit and it stops again for ~2s:

Jul 02 14:31:54 [cplayer] Exiting... (Quit)
Jul 02 14:31:54 [vo/gpu/libplacebo] Freeing slab of size 3840K
Jul 02 14:31:54 [vo/gpu/libplacebo] Freeing slab of size 7680K
Jul 02 14:31:54 [vo/gpu/libplacebo] Freeing slab of size 7680K
Jul 02 14:31:54 [vo/gpu/libplacebo] Freeing slab of size 3840K
Jul 02 14:31:54 [vo/gpu/libplacebo] VkSemaphore signalled: 0x7f4dde4bba40 = 117
Jul 02 14:31:54 [vo/gpu/libplacebo] Freeing slab of size 7680K
Jul 02 14:31:54 [vo/gpu/libplacebo] VkSemaphore signalled: 0x7f4dde4bec80 = 67
Jul 02 14:31:54 [vo/gpu/libplacebo] VkSemaphore signalled: 0x7f4dde46afd0 = 127
Jul 02 14:31:54 [vo/gpu] flushing shader cache
Jul 02 14:31:54 [vo/gpu/libplacebo] QF 0: 0/1
Jul 02 14:31:54 [vo/gpu/libplacebo] QF 1: 0/1
Jul 02 14:31:54 [vo/gpu/libplacebo] QF 2: 0/1
Jul 02 14:31:56 [vo/gpu/libplacebo] Waiting for remaining commands...
Jul 02 14:31:56 [vo/gpu/libplacebo] Memory heaps supported by device:
Jul 02 14:31:56 [vo/gpu/libplacebo]     0: flags 0x1 size 8192M
Jul 02 14:31:56 [vo/gpu/libplacebo]     1: flags 0x0 size   23G
Jul 02 14:31:56 [vo/gpu/libplacebo]     2: flags 0x1 size  246M
Jul 02 14:31:56 [vo/gpu/libplacebo] Memory types supported by device:
Jul 02 14:31:56 [vo/gpu/libplacebo]     0: flags 0x0 heap 1
Jul 02 14:31:56 [vo/gpu/libplacebo]     1: flags 0x1 heap 0
Jul 02 14:31:56 [vo/gpu/libplacebo]     2: flags 0x1 heap 0
Jul 02 14:31:56 [vo/gpu/libplacebo]     3: flags 0x6 heap 1
Jul 02 14:31:56 [vo/gpu/libplacebo]     4: flags 0xe heap 1
Jul 02 14:31:56 [vo/gpu/libplacebo]     5: flags 0x7 heap 2

if it helps.

Command ran was:

./build/mpv -v -v -v --gpu-debug --no-config --vo=gpu --gpu-api=vulkan ~/Downloads/453861829-e1a468c0-e27e-4bed-8e21-6849fd1d91b7.mp4 2>&1 | ts -m

muresan avatar Jul 02 '25 13:07 muresan

Can you reproduce the issue with llvmpipe as the vulkan driver?

Run mpv --vulkan-device=help then run mpv with vulkan and --vulkan-device=<llvmpipe>

llyyr avatar Jul 02 '25 13:07 llyyr

$ mpv --vulkan-device=help
Available vulkan devices:
  'Intel(R) UHD Graphics (CML GT2)' (GPU 0, PCI ID 8086:9bc4, UUID 8680c49b-0500-0000-0002-000000000000)
  'NVIDIA GeForce RTX 2070 with Max-Q Design' (GPU 1, PCI ID 10de:1f14, UUID f0010324-968c-3c54-232c-41b50b73e9a9)
  'llvmpipe (LLVM 20.1.6, 256 bits)' (GPU 2, PCI ID 10005:0, UUID 6d657361-3235-2e31-2e34-000000000000)

For some strange reason, the 1st run (and some other runs) with llvmpipe UUID resulted in a black screen (I can reproduce if the mpv window shows on the laptop panel but it's not consistent), but no issues with resize/stutter/moving between monitors. I've then tried nvidia vulkan device (which exibited the same issue) then intel integrated, which worked, then llvm which worked.

llvmpipe: works, but sometimes black window (with OSD) nvidia: stutters integrated intel: works

muresan avatar Jul 02 '25 15:07 muresan

This is probably an Nvidia issue with their X11 WSI then, not much mpv can do. You could use Wayland which probably doesn't have this issue

llyyr avatar Jul 02 '25 15:07 llyyr

Sorry for the late reply. I can confirm using --gpu-api=opengl flag solves the issue with 0.40. And it doesn't seem to affect the Wayland side at least on Hyprland.

AhmedHalim96 avatar Jul 05 '25 09:07 AhmedHalim96

I'm having this issue in all Vulkan programs, this is 100% a NVIDIA driver bug (and should be reported there)

awsms avatar Jul 11 '25 12:07 awsms

I see this issue on an AMD laptop with Radeon (internal) graphics. As with others, --gpu-api=opengl makes it go away. I don't see the resize issue when the video is playing, only when it is paused.

It appears to be the same as what someone reported as a KDE issue here: https://www.reddit.com/r/kde/comments/1mkbtcw/mpv_goes_boing_boing/

mpv 0.40.0

afontenot avatar Aug 10 '25 02:08 afontenot

I've had this happen a few times, when resizing the mpv window (seems to be moving the bottom right handle more?) the whole system will crash. I get a black screen with a white underscore and the only thing to do is to restart my machine.

I'm using Linux Debian 13 (Trixie) XFCE. Some system specs: 6.12.27-amd64 Graphics: NVDIDIA GeForce FTX 3060 Laptop GPU

travis-jeans avatar Nov 02 '25 02:11 travis-jeans