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

Entering fullscreen with Vulkan freezes window content on AMD #8008

Closed
aufkrawall opened this issue Aug 16, 2020 · 58 comments
Closed

Entering fullscreen with Vulkan freezes window content on AMD #8008

aufkrawall opened this issue Aug 16, 2020 · 58 comments

Comments

@aufkrawall
Copy link

aufkrawall commented Aug 16, 2020

Important Information

-mpv-x86_64-20200816-git-7f67c52
-Windows 10 2004
-shinchiro SF repo

Reproduction steps

Play any video with --gpu-api=vulkan and enter fullscreen

Expected behavior

Playback should continue normally in fullscreen

Actual behavior

Playback freezes and shows the last frame from before entering fullscreen (playback returns normally after switching back into windowed mode). mpv fullscreen has always been rather problematic on AMD Windows, i.e. slow switching. But of course it always freezing makes it unusable. The AMD driver seems to treat it as "exclusive" fullscreen, and unfortunately no mpv config option seems to help to avoid that.

Log file

output.txt

Sample files

Can be any video.

@h1z1
Copy link

h1z1 commented Aug 18, 2020

I don't know if this is specific to AMD nor Windows given I've seen the same thing in Linux and NVIDIA? Vulkan can bring X to it's knees with a poorly encoded video

@Dudemanguy
Copy link
Member

Linux and NVIDIA

Almost certainly a NVIDIA driver issue.

@Jules-A
Copy link

Jules-A commented Aug 18, 2020

Might not be related but I'm also using AMD (RX570) on Windows 1909 using Vulkan and fullscreen causes my monitor to switch from 75hz to 60hz (the process causes a black screen for ~5secs) and is very laggy afterwards but I don't recall it freezing completely.

@aufkrawall
Copy link
Author

Almost certainly a NVIDIA driver issue.

Yep, switching into fullscreen on Windows worked fine with the Nvidia card that was installed before and Linux Xorg issues should be unrelated.

Might not be related but I'm also using AMD (RX570) on Windows 1909 using Vulkan and fullscreen causes my monitor to switch from 75hz to 60hz (the process causes a black screen for ~5secs) and is very laggy afterwards but I don't recall it freezing completely.

I waited like 10 seconds or so and it didn't recover. I'm also using single refresh rate EDID, so it can't change it.

@Jules-A
Copy link

Jules-A commented Aug 19, 2020

I waited like 10 seconds or so and it didn't recover. I'm also using single refresh rate EDID, so it can't change it.

What happens when you don't? Seems like it's forcing to run at 60hz for some reason like it's hardcoded, maybe since it can't it ends up failing?

@aufkrawall
Copy link
Author

It happens also with my default EDID that features only 60Hz.

@Provissy
Copy link

My RX570 with a 60HZ display experience no issue. Same Windows 10 2004 & Vulkan are being used. When switching to fullscreen, the screen will turn black for about 2 seconds then enter exclusive mode, playback will then be resumed.

Did you turn AMD FreeSync on? or flip it on and try again?

@aufkrawall
Copy link
Author

My display is not VRR capable. I also think that a 2s transition wouldn't be acceptable either. While this is certainly AMD's fault, it would still be nice to have a workaround (if possible).

@Jules-A
Copy link

Jules-A commented Aug 24, 2020

While this is certainly AMD's fault, it would still be nice to have a workaround (if possible).

What makes you think it's AMD's fault? I haven't noticed anything like this in any other Vulkan app?
Also yeah, a 2s black screen isn't really great for a video player, might be fine for games though.

@aufkrawall
Copy link
Author

It works with Intel & Nvidia (without weird transition slowness) and fullscreen behavior can also be bad in other Vulkan fullscreen applications with AMD. E.g. it doesn't seem to "unredirect" DWM compositing when I alt + tab out and again into some games with DXVK on Windows when there are other windows at the same time, so ironically what would be more desirable for media players.

@Provissy
Copy link

Comparing to freeze after switching to fullscreen, I think a short latency is totally acceptable! But it certainly could be better.

I use the "pro" version of the AMD's Radeon Software. afaik, the "pro" version is proprietary and the normal one is open source(at least for Linux), there might be some difference between them, you could probably give it a try.

@Jules-A
Copy link

Jules-A commented Aug 25, 2020

Oh, I just realised MPV allows changing the swapchain mode, I can't really test it now but have you tried changing those settings? I have a feeling choosing another mode may solve this but it's just a theory.

EDIT: Actually tested fullscreen again and something has changed recently. It no longer changes my screen's refresh rate or blackscreens and instead doesn't open to fullscreen at all and trying to interact with the window is pretty much impossible but it's not frozen, the video will still play smoothly in the background if you try to alt-tab or press the window key but stops when you try to open that window or close the start/alt-tab menu.

vulkan-swap-mode=immediate is the only option that works properly with fullscreen but that means no vsync so probably not ideal for some. With no shaders and video-sync=display-resample I was getting 322fps without shaders and I wasn't seeing tearing but the reported vsync jitter was around 0.7. I'm not sure running without vsync and video-sync=audio does but it seemed to play fine (I think that's meant to disable interpolation but I couldn't really notice).

Also, using the default swapchain and "ontop" I can get fullscreen to show after alt-tabbing to it but interacting with the window will cause the image to freeze but audio continues playing and alt-tabbing again returns it to focus while continuing to play the video.

Another thing I noticed is running window-maximized with no-borders replicates the same issue.

@aufkrawall
Copy link
Author

Yes, that's what I meant ("freezes window content").
I tested with D3D11 -> Vulkan via DXVK and that way mpv can enter fullscreen normally.

@Jules-A
Copy link

Jules-A commented Aug 28, 2020

Yes, it works fine with DXVK and not only that but it has the lowest Vsync jitter I've seen. That said, the Anime4k shaders I'm trying to run give a green screen under DX11 and the same thing happens when using DXVK.

@ghost
Copy link

ghost commented Sep 19, 2020

Same thing here...works with any other API, but just freezes on Vulkan when i use fullscreen. That's pretty sad, since vulkan don't even stress the GPU (RX 5700 XT in my case). And for some weird reason, this just started some days ago, before that i was able to use without a single freeze, even with 4K or astonishing overkill 8K videos.

@haasn
Copy link
Member

haasn commented Oct 21, 2020

I don't think there's anything we can do to work around this, unfortunately. Until there's some sort of vulkan extension to control what happens when going into fullscreen. It's possible you can find some driver setting to disable it.

@tyler274
Copy link

Only freezes on my non main monitors, fullscreening works fine on the main monitor.

@Jules-A
Copy link

Jules-A commented Nov 13, 2020

Only freezes on my non main monitors, fullscreening works fine on the main monitor.

What about when you only have 1 monitor connected?

@PleaseFixThis1
Copy link

RX 580
144hz monitor
no freesync
same issue

@PleaseFixThis1
Copy link

!FIXED!: Run with mpvnet.exe instead of mpv.exe!

@lextra2
Copy link

lextra2 commented Nov 28, 2020

!FIXED!: Run with mpvnet.exe instead of mpv.exe!

no thanks

@JensDA
Copy link

JensDA commented Dec 15, 2020

I've found this in the nvidia driver's readme, could it be related?

Vulkan applications crash when entering or leaving fullscreen, or when resized

Resizing a Vulkan application generates events that trigger an out-of-date swapchain.
Fullscreen Vulkan applications are optimized for performance by the driver. This optimization also generates events that trigger an out-of-date swapchain upon entering or leaving fullscreen mode. This is commonly encountered when using the alt-tab key combination, for example.
Applications that do not properly respond to the VK_ERROR_OUT_OF_DATE_KHR return code may not function properly when these events occur. The expected behavior is documented in section 30.8 of the Vulkan specification.

@haasn
Copy link
Member

haasn commented Dec 15, 2020

Unlikely. We respect those events.

@Jules-A
Copy link

Jules-A commented Apr 5, 2021

This is partially fixed in the latest Shinchiro build with libplacebo v3.120.0. It is now able to play a file in fullscreen with working controls BUT it's dropping and delaying a tonne of frames, it's syncing to ~66hz instead of my monitor's 75hz... When launching the file it goes in and out of fullscreen 3 times in the first few seconds. It still does the same as thing as previous libplacebo versions when launching just the program without a video file.

Log (with current settings, haven't tested default):
output.txt

EDIT: Tried without shaders/extra vulkan settings and same issue. Runs full speed in DX11/OGL fullscreen and Vulkan in window-maximized.

@haasn
Copy link
Member

haasn commented Apr 5, 2021

Just to rule this out, try with --vulkan-async-transfer=no? Testing recent-ish versions of AMD's official driver on Linux, I'm having massive issues with that option enabled. (Seems to be a regression, too)

@ghost
Copy link

ghost commented Apr 5, 2021

Update: On Sep 19, 2020, I mentioned that it was impossible to use Vulkan API in full screen, since that day I never used Vulkan again, but a few months ago (Dec 29, 2020) I bought another GPU and managed to use Vulkan without major issues. I am not sure if it was an update that fixed it or just a type of incompatibility with my previous GPU or driver, but although it is apparently functional it is impossible to share the media through Discord or record it with programs like OBS, in both cases the video appears to be frozen in the recording with the audio playing, while the media itself still plays normally.

My previous GPU was a RX 5700 XT, i'm currently using a RTX 3070.

@Jules-A
Copy link

Jules-A commented Apr 5, 2021

Just to rule this out, try with --vulkan-async-transfer=no? Testing recent-ish versions of AMD's official driver on Linux, I'm having massive issues with that option enabled. (Seems to be a regression, too)

Previously I tested that without any luck, will try it again in a bit but I'm on Windows using the latest driver so might be a separate issue.

EDIT: No change, still extremely laggy.

@lextra2
Copy link

lextra2 commented Apr 6, 2021

You didn't test opening the MPV app without any content in that vid (it causes the same issue for me as previously but playing content works).

And how exactly do you want me to test performance without a video playing?
Here is another video. Again, works on my machine.
This time with 2560x1440@120Hz instead of 3840x2160@60Hz.

https://drive.google.com/file/d/18CONx9MiA0AwoTScZZmDuzVbPl8oUDwU

@lextra2
Copy link

lextra2 commented Apr 6, 2021

@haasn @adisib
I've reported the issue to AMD
Will probably take over 12 Months to get it fixed though.

@Jules-A
Copy link

Jules-A commented Apr 6, 2021

And how exactly do you want me to test performance without a video playing?

I wasn't talking about performance... It's probably easier to show you what I mean: https://www.youtube.com/watch?v=Puj_3k9oN3w

EDIT: Oh right, you attempted to try it but you weren't opening in fullscreen, this bug is ONLY about fullscreen, there's nothing wrong when I open in windowed. That said, you aren't getting the performance issues I'm experiencing it seems.

I just tested at 60hz and the performance issue isn't there but vsync jitter is fairly high at 0.3. Setting my monitor to 60hz actually disables my monitor's Freesync so not sure if the jitter is just from that.

@lextra2
Copy link

lextra2 commented Apr 6, 2021

EDIT: Oh right, you attempted to try it but you weren't opening in fullscreen, this bug is ONLY about fullscreen, there's nothing wrong when I open in windowed. That said, you aren't getting the performance issues I'm experiencing it seems.

Well, there we go. I finally see the issue you are talking about. When I use the following settings:

gpu-api=vulkan
fullscreen

And open MPV with no file, my Samsung TV loses signal and gives a "Mode not Supported" error. From tinkering with my EDID via CRU I know this happens only in exclusive fullscreen applications that do not respect the set desktop resolution, but instead try to force another resolution (which does not exist in my case, since I've deleted it with CRU)

So yeah #8008 (comment) is the issue here. AMD vulkan driver bug.

@lextra2
Copy link

lextra2 commented Apr 7, 2021

doitsujin/dxvk#1928 (comment)
interesting read. most likely related to this issue.

@Jules-A
Copy link

Jules-A commented Apr 7, 2021

doitsujin/dxvk#1928 (comment)
interesting read. most likely related to this issue.

Come to think about it I don't think anyone has reported seeing this bug on Linux (except for a guy using Nvidia). I'm installing a preview cumulative update right now that has a few fixes that could be related so here goes :P

I don't recall DXVK capping to 60fps though, whatever they are doing it's working around this issue. I have had problems in the past with Vulkan apps being limited to 60fps though in fullscreen so that's not new.

EDIT: AHAHAHA KB5000842 actually fixed the lagg issue I was getting at 75hz. I never would have imagined it would be a Windows issue....

If you are wondering which issues they fixed that I suspected:

Addresses an issue that causes video playback to be out of sync in duplicate mode when you use multiple monitors.
Addresses a window rendering issue that causes content in a window to flash frequently when FlipEx is used.
Addresses a window rendering issue that causes content in a window to flash frequently when multi-plane overlay (MPO) is used.

I only have a single monitor though :/

The videos also start up faster now and only do 1-2 flashes instead of 3x when launching to fullscreen. Opening the exe without content is worse than before, I can't even alt-tab to it now.

Vsync jitter is pretty high though in Vulkan, 0.270 vs 0.017 in DX11. No idea if that's really enough to cause issues though.

@lextra2
Copy link

lextra2 commented Apr 7, 2021

I remember having the 60Hz issue in almost all exclusive fullscreen games, which is exactly why I've deleted all but 2 resolutions from my EDID.

@Hrxn
Copy link
Contributor

Hrxn commented Apr 7, 2021

@lextra2

By CRU, you mean this CRU? -> https://www.monitortests.com/forum/Thread-Custom-Resolution-Utility-CRU

@lextra2
Copy link

lextra2 commented Apr 8, 2021

@Hrxn
Yes.

These are my settings, for anyone wondering

01

02

@Jules-A
Copy link

Jules-A commented Apr 17, 2021

@haasn Dolphin just merged a workaround for the bug (linked above), what's your opinion on that if you don't mind?

@haasn
Copy link
Member

haasn commented Apr 17, 2021

@Jules-A I'm not entirely sure what the work-around is doing here. Do they just treat that result as if it were VK_SUCCESS? (Which is what the code+comment seems to be implying?) I would expect it to make more sense to treat that error as VK_ERROR_OUT_OF_DATE_KHR.

Overall I'm more inclined to work around it by explicitly disabling exclusive full screen support, since I'm not sure why full screen exclusive mode makes any sense in the context of mpv/libplacebo. (If anything, disabling full screen exclusive mode ought to make going in and out of fullscreen smoother)

That said, though, full screen exclusive might be required for HDR output?

@Jules-A
Copy link

Jules-A commented Apr 17, 2021

@Jules-A I'm not entirely sure what the work-around is doing here.

I didn't quite understand what it did from the comments which is why I was asking about it in-case something similar could be done for MPV.

Overall I'm more inclined to work around it by explicitly disabling exclusive full screen support, since I'm not sure why full screen exclusive mode makes any sense in the context of mpv/libplacebo. (If anything, disabling full screen exclusive mode ought to make going in and out of fullscreen smoother)
That said, though, full screen exclusive might be required for HDR output?

I'm not sure of the advantages but I was hoping maybe it would offer better Vsync timing (currently it's really poor in comparison to DX). I can imagine there are quite a few people using dedicated media PCs who don't care much about leaving the app. If there is some advantages then an option to run in exclusive could be useful but I don't think it should be default. I don't have a HDR monitor to test unfortunately.

@haasn
Copy link
Member

haasn commented Apr 17, 2021

Lack of vsync timing is awell-known vulkan issue that is still unresolved 5 years after Vulkan's release. Fullscreen exclusive mode does not help here.

@Jules-A
Copy link

Jules-A commented Apr 17, 2021

Lack of vsync timing is awell-known vulkan issue that is still unresolved 5 years after Vulkan's release. Fullscreen exclusive mode does not help here.

Oh thanks but wow... is it still not solved with 1.2.175 which implemented VK_KHR_video_queue (I haven't looked at it and I don't think AMD supports that yet anyway) ?

@soredake
Copy link
Contributor

Overall I'm more inclined to work around it by explicitly disabling exclusive full screen support, since I'm not sure why full screen exclusive mode makes any sense in the context of mpv/libplacebo. (If anything, disabling full screen exclusive mode ought to make going in and out of fullscreen smoother)

@haasn can mpv have similar to d3d11 option(d3d11-exclusive-fs) for vulkan?

@haasn
Copy link
Member

haasn commented May 15, 2021

@haasn can mpv have similar to d3d11 option(d3d11-exclusive-fs) for vulkan?

VK_EXT_full_screen_exclusive seems to be the right extension to poke at for this.

@hooke007
Copy link
Contributor

hooke007 commented Nov 8, 2021

My amd gpu: pro 5600m
Unfortunately the latest driver for me is ver.21.11.1

Only set vulkan-swap-mode=immediate could avoid freezing when entering fullscreen.

@haasn
Copy link
Member

haasn commented Oct 16, 2022

@aufkrawall
Copy link
Author

I unfortunately don't have a test system with Radeon at my disposal. I'd test Nvidia and Intel though if there were a test build.

@Jules-A
Copy link

Jules-A commented Oct 19, 2022

@haasn Would it be possible to get an option to force enable it?

@haasn
Copy link
Member

haasn commented Oct 21, 2022

@haasn Would it be possible to get an option to force enable it?

What do you need it for? Can you explain the use case?

@Jules-A
Copy link

Jules-A commented Oct 21, 2022

@haasn Would it be possible to get an option to force enable it?
What do you need it for? Can you explain the use case?

I don't have a "need" for it but as you suggested earlier it might be needed for HDR. It might provide some benefits now or in the future but without the option for users to even test it without compiling themselves I have a feeling we'll never know.
Also, this bug was already fixed for me a year and half ago but only if content is provided (it still occurred when opening just the exe which I never did).
That said, Vulkan still performs worse for me than DX11 and gpu-next still has bugs with shaders so I'm not even using Vulkan :/

@haasn
Copy link
Member

haasn commented Oct 21, 2022

I don't have a "need" for it but as you suggested earlier it might be needed for HDR.

From testing it appears that this is not the case, and from discussion with other developers it seems that fullscreen exclusive mode in general is something that's on its way out / considered deprecated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests