-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Getting VK_ERROR_DEVICE_LOST upon resizing mpv's window #8360
Comments
Can confirm the issue, there is no need to resize "as fast you can" the issue can appear on any resize kinda randomly. |
Indeed! Today I was watching a video with my second screen enabled, and as soon as I clicked and dragged just a little to start resizing the window, the crash happened. It just seemed easier to reproduce by resizing it quickly, though. >:) Can you still reproduce a crash/freeze without using |
I use |
It's also extremely likely that mpv and/or libplacebo would benefit from having better code to recover from device loss, since that can happen for entirely legitimate reasons as well. As far as that distinction is concerned, I'm convinced libplacebo is, essentially, doing the correct thing. It's forwarding the error to vo_gpu's So in terms of an actual change that needs to be made, it's most likely on the mpv side. More specifically, mpv needs some mechanism of signalling that the entire gpu context needs to be recreated (possibly as a new VOCTRL of some sort) |
So an update to their beta Vulkan driver was released yesterday:
Before I waste my time downloading, packaging and installing this beta driver, do you guys think that fix could be related to this bug? Cheers. |
Unlikely. We don't use stencil buffers. (But maybe they do, internally. Or maybe the bug affects more than just stencil buffers.) |
Yep, it's definitely not fixed. Attaching a new log file nonetheless, since mpv's output appears to have changed slightly: NVIDIA driver 455.50.04 |
I can confirm I also have the same issue, also not just resizing the window but also going fullscreen or exiting fullscreen causes the error very frequently. I have noticed that if I pause the video prior to going fullscreen it seems to practically never happen. If I pause the video prior to resizing, the crash is softer (e.g. MPV seems to crash/display black screen but the whole system doesn't freeze up anymore, and mpv doesn't hang anymore either) I also noticed that if I change the video sync method from display-resample to audio, it significantly alleviates the issue but doesn't entirely eliminate it, but at least if it's just going in and out of fullscreen, it doesn't really happen anymore. Sad part is that this means no interpolation. Has anybody reported the issue to nvidia? |
Issue still the same almost a year later. I'm on a laptop, and all the issues I had originally were when using PRIME Offloading But now I have set things up so that my dGPU is the default GPU, so no offloading anymore. This solved a bunch of other issues I had (like games hard crashing my system when vsync was on) But this particular issue actually got worse (happens more frequently) under this setup. Also found this almost certainly related bug report thread on nvidia's forums: https://forums.developer.nvidia.com/t/vk-error-device-lost-in-many-game-titles/164513 Also mentioned in that thread is a workaround used by DXVK to prevent said issue: doitsujin/dxvk@16a51f3 I would make a test build of mpv and see if this fixes it here too or not but I'm not much of a developer so I'd probably struggle for days to get it done D: |
It might be a good idea to re-investigate whether the validation layers pick up anything that could explain this. Make sure you have the vulkan validation layers installed and then run mpv using |
here's a gist: https://gist.github.com/Rabcor/1e58aa97be8545ff387c10d8bb3d65ba Btw for me this is happening with the anime4k shaders, but not some other shaders. I think the reason it isn't happening on GL might have something to do with the shaders not loading correctly on openGL in the first place (I mean mpv seems to load them but they're not actually doing anything). |
Btw I did find a workaround of sorts... If I disable the shaders before resizing the window the issue naturally won't happen, so I just added this to input.conf
Where I can hit CTRL+0 for resizing the window, and setting to fullscreen will never crash mpv anymore. The extra show-text is there just to add a tiny extra delay just in case. To reapply the shader afterwards I can use something like
or
A more ideal way would be for it to reload the config after going fullscreen, but I couldn't find a way to do tha through input.conf. Also a note I thought I'd make: The issue does not occur on Windows with the same config, only Linux, implying that as said before, yes, this is probably an issue in the nvidia driver. |
Looks like a GPU hang. |
might be a default settings mismatch, i think i might have managed to fix it with this setting (dunno which one is better)
seems like swapchain depth is reliant on queue-count ? |
Ah, holy shit, this works! Also I tried some variants like
And
But only setting both to 1 actually seemed to solve the issue, no other variation on the settings I tested seemed to work. |
I believe queue count is gpu dependant, no idea how to check how many gpu can handle so I defaulted to 1. edit: edit2: also aside from resizing, issues shows up when leaving full screen, though that's due to resize, quite often though at random. edit3: something is about 1 and 1. tl;dr no idea why but needs to be queue count 1, swapchain depth 1. |
Can also confirm that setting mpv --no-config --profile=gpu-hq --gpu-api=vulkan --vulkan-queue-count=1 --swapchain-depth=1 http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 I tried to reproduce this on an Radeon R9 280x with amdgpu drivers and it doesn't crash there with the default values. |
I found out that (perhaps unsurprisingly) that disabling the swapchain logic (setting it to 1 disables it, technically) somewhat dramatically affects performance, particularly for interpolation. My vsync jitter becomes about 10x worse according to statistics, compared to when it is set to 3. I figured out a way to sorta combat it. You cannot change the swapchain-depth post launch, you cannot change the rendering API either, after you have launched mpv with the swapchain depth set to 1 there's literally nothing you can do ot set it to 3 again besides turning it off and launching it again with swapchain depth set to 3 from the start. My workaround for this is to set swapchain depth to 1 when in windowed mode, otherwise letting it remain at it's default (3), and just configuring mpv to always launch in fullscreen and disable the keybinds to exit fullscreen; like this: in mpv.conf:
nofscycle.conf:
With this setup, I can either launch mpv with It's not ideal, but since I mostly watch things in fullscreen anyways, I am more or less getting the best of both worlds here. Also for people who mostly use windowed it's easy to flip the logic, just remove the first two lines I put in mpv.conf and only use the profile, then launch |
I've encountered this issue on manjaro with 470 and 495 dirvers. Tested it now, after 510.47.03 release with this command:
And the issue seems to be resolved. |
If this is indeed fixed on R510, hopefully it gets backported to R470 because it's the last driver branch that will support my GPU. :c |
I can still reproduce this in 510.47.03. It seems a lot less likely to happen, but still possible. dmesg message:
Log with |
This isn't really resolved, I can second OceanS2000 on that, it seems a lot less likely to happen but it still does on 510 drivers when there's no config. But when i'm using certain aforementioned shaders it's just as bad as before. Honestly i think i already mentioned earlier that it rarely happens when not using shaders. |
Is there any way to solve this problem temporarily? |
It could probably be worked around by forcing all resizes to be synchronous. I guess I could add a debug flag for that. |
I'll try, thank you very much! |
Can you guys retest this? I can't seem to reproduce this anymore, which is great, especially because my GPU will only be getting limited drivers updates...
|
Windows 10 here. Mpv kept crashing and eventually froze my entire OS when I attempted to resize a window. I jumped from 0.34.0 to 0.35.0-15 after that, and resizing works more reliably now, but mpv can still crash... at least it doesn't seem to freeze my system anymore. |
I can no longer reproduce this issue either.
We should probably close this thread, I don't know how or when but it seems like it's been resolved. I'm guessing it was an nvidia driver update that resolved it rather than anything MPV did.
I still ahd issue in drivers 510, so something between 510 and 525 must have solved it. |
It still happens for me. Using
|
for me, above suggestions did not fix it (still having mpv hang on window resize with error
nvidia driver version:
mpv version:
Seems this error is not limited to nVidia cards: #10425 |
Can you test if this diff works around the issue? diff --git a/src/vulkan/swapchain.c b/src/vulkan/swapchain.c
index 3febf409..ff586173 100644
--- a/src/vulkan/swapchain.c
+++ b/src/vulkan/swapchain.c
@@ -598,6 +598,8 @@ static bool vk_sw_recreate(pl_swapchain sw, int w, int h)
sinfo.imageExtent.width,
sinfo.imageExtent.height);
+ vk_wait_idle(vk);
+
// Calling `vkCreateSwapchainKHR` puts sinfo.oldSwapchain into a retired
// state whether the call succeeds or not, so we always need to garbage
// collect it afterwards - asynchronously as it may still be in use |
Seems to work as should (on my machine) |
Issue exists with mpv v0.35.1 in KDE v5.27.4, x11
from mpv.log
I can also confirm that setting |
Which version of libplacebo do you use? The fix above should be available starting from v6.287.0-rc1 |
Important Information
Provide following Information:
libplacebo
version in the official Arch Linux repositories was too old (and it was indeed), so I waited until v0.33.0 was officially released (therefore with a newer version oflibplacebo
), but the issue persisted.Reproduction steps
First, let me say I'm not sure if I should've opened an issue here, or in the
libplacebo
repo, so feel free to close this if it's in the wrong place.Anyway, I could only reproduce this when combining
--profile=gpu-hq
with--gpu-api=vulkan
. To reproduce this, pick a random video (the download link for the one I used is at the end of this post), then run mpv in a terminal window, like this:After that, start resizing the mpv window diagonally (I couldn't reproduce it when resizing horizontally or vertically), as fast as you can: mpv will freeze (and sometimes your whole desktop will too, for a brief moment).
mpv will also spam this following message in the console:
And If you have
journalctl -f
open (and if you have a NVIDIA GPU), this Xid error will show up:Expected behavior
mpv to not freeze and the NVIDIA driver to not throw a Xid error.
Actual behavior
mpv freezes and NVIDIA throws a Xid error.
Log file
https://gist.githubusercontent.com/guihkx/97e8437eb059868623564f18156d667b/raw/7d51f3bed46bc72661b8c1d81c30b4ff5c518427/log.txt
Sample files
http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
The text was updated successfully, but these errors were encountered: