Bug 492202 - BT.709 videos 1080p or larger cannot be played in mpv with vulkan depending on display scale
Summary: BT.709 videos 1080p or larger cannot be played in mpv with vulkan depending o...
Status: RESOLVED UPSTREAM
Alias: None
Product: kwin
Classification: Plasma
Component: wayland-generic (show other bugs)
Version: 6.1.4
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWin default assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-08-26 11:15 UTC by TheFeelTrain
Modified: 2024-09-24 13:21 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description TheFeelTrain 2024-08-26 11:15:30 UTC
SUMMARY

This is some extremely odd behavior that I have narrowed down to being caused (or at least affected by) display scale. If mpv is configured to use vulkan then 1080p videos cannot be played if display scaling is set to 150% or higher.

For some reason it only affects 1080p video and nothing else. 
I have tested: 
SDR and HDR content
480p, 720p, and 2160p
8-bit AVC, 8-bit VP9, 8-bit HEVC, and 10-bit HEVC

Everything plays normally regardless of the other factors except for 1080p resolution.
Playback works at 50-125% display scale, but does not work at 150-200%.

STEPS TO REPRODUCE
1. Set display scale to 150% or higher in system settings
2. Open a 1080p video in mpv with --gpu-api=vulkan --gpu-context=waylandvk

OBSERVED RESULT

The video will be frozen. Audio continues to play, so it is purely graphical.
The mpv window also can't be resized or be made fullscreen.

Console output:

[vo/gpu-next/libplacebo] vk->CreateSwapchainKHR(...): VK_ERROR_OUT_OF_HOST_MEMORY (../src/vulkan/swapchain.c:622)
[vo/gpu-next/libplacebo] Failed (re)creating swapchain!
[vo/gpu-next/libplacebo] vk->CreateSwapchainKHR(...): VK_ERROR_OUT_OF_HOST_MEMORY (../src/vulkan/swapchain.c:622)
[vo/gpu-next/libplacebo] Failed (re)creating swapchain!
[vo/gpu-next/libplacebo] vk->CreateSwapchainKHR(...): VK_ERROR_OUT_OF_HOST_MEMORY (../src/vulkan/swapchain.c:622)
[vo/gpu-next/libplacebo] Failed (re)creating swapchain!

(repeating)

EXPECTED RESULT

Video plays normally.

SOFTWARE/OS VERSIONS

OS: Arch Linux
KDE Plasma Version: 6.1.4
KDE Frameworks Version: 6.5.0
Qt Version: 6.7.2

CPU: AMD Ryzen 9 7950X
GPU: AMD Radeon RX 7900 XTX
Memory: 32 GB
Kernel: 6.10.6-zen1-1-zen
Driver: mesa 24.1.6

ADDITIONAL INFORMATION

My full mpv config is: 

vo=gpu-next
profile=gpu-hq
hwdec=vaapi
gpu-api=vulkan
gpu-context=waylandvk

Only the gpu-api and gpu-context options seem to matter for this bug, so vaapi and gpu-next are not the culprit.

I have a single 3840x2160 display at 120hz. 

To be thorough I tried running at 60hz. No effect.
Tried running at 1440p instead of native 2160p. No effect.
Tried building mesa from the latest commit. No effect.
Tried building mpv from latest commit. No effect.
Tied both with and without ENABLE_HDR_WSI. No effect.

The only thing that works is putting display scale below 150%.

If this is not a Plasma bug feel free to close the issue, but since display scale seems to have something to do with it I thought this is the most appropriate place to report it. It could very well be a vulkan or libplacebo bug that just happens to interact with display scale.
Comment 1 Nate Graham 2024-08-27 20:33:29 UTC
VK_ERROR_OUT_OF_HOST_MEMORY seems quite relevant. Probably at over 150% scale, the image buffer is too large for MPV to handle or something.
Comment 2 TheFeelTrain 2024-09-01 08:10:36 UTC
It is definitely something to do with a buffer size. Now that I have done some more testing I have a few more observations:

BT.2020 content is unaffected regardless of resolution. This was the only other variable I hadn't considered previously. 4K (2160p) video was working in my initial testing but that's only because the vast majority of 4K video is in BT.2020.

With BT.709 video:

At 150% scale:
1080p -> does not work
1440p -> does not work
2160p -> does not work

At 125% scale:
1080p -> works
1440p -> does not work
2160p -> does not work

At 100% scale: 
1080p -> works
1440p -> works
2160p -> does not work

I cannot get 2160p in BT.709 to play at all, even at 50% scaling.

I should also mention I tried a few different kernel flavors, 6.11-rc5, even downgrading my kernel to 6.9.12 and the problem still persists so I feel like it is safe to say the problem is not kernel-related.

Both mpv and libplacebo have not been updated in the Arch repos since July 6th, and the problem did not start occurring until roughly two weeks ago so I also feel it is safe to say that it's not caused by those.
Comment 3 Zamundaaa 2024-09-24 13:21:35 UTC
I don't know what the exact problem is, but KWin doesn't make clients use differently sized buffers with different scaling - it's up the application to deal with fractional scaling properly. It sounds like mpv isn't doing that correctly, so please report this at https://github.com/mpv-player/mpv/issues