mpv-player / mpv

🎥 Command line video player
https://mpv.io
Other
28.71k stars 2.93k forks source link

Flashing purple screen when using gpu-api=vulkan #14026

Open PuraIgnis opened 6 months ago

PuraIgnis commented 6 months ago

Important Information

Provide following Information:

Reproduction steps

It happens when I use --gpu-api=vulkan. Changing it to d3d11 would eliminate the issue.

Expected behavior

Video plays.

Actual behavior

Flashing screen, but audio is still there.

Log file

(output.txt))

Sample files

kasper93 commented 6 months ago

[   2.567][d][vo/gpu-next/libplacebo] Allocating 17694720 memory of type 0x1 (id 1) in heap 0: unknown
[   2.567][d][vo/gpu-next/libplacebo] Spent 0.404 ms allocating slab
[   2.572][d][vo/gpu-next/libplacebo] LUT invalidated, regenerating..
[   2.572][d][vo/gpu-next/libplacebo] Spent 0.002 ms generating shader LUT
[   2.572][d][vo/gpu-next/libplacebo] Allocating 262144 memory of type 0x1 (id 1) in heap 0: src/shaders/sampling.c:709
[   2.572][d][vo/gpu-next/libplacebo] Spent 0.263 ms allocating slab
[   2.572][d][vo/gpu-next/libplacebo] Allocating 258048 memory of type 0x7 (id 5) in heap 2: ../../../../../src_packages/libplacebo/src/gpu/utils.c:564
[   2.574][e][vo/gpu-next/libplacebo] Allocation of size  252K failed: VK_ERROR_OUT_OF_DEVICE_MEMORY!
[   2.574][e][vo/gpu-next/libplacebo] Memory heaps supported by device:
[   2.574][e][vo/gpu-next/libplacebo]     0: flags 0x1 size 3935M
[   2.574][e][vo/gpu-next/libplacebo]     1: flags 0x0 size 7895M
[   2.574][e][vo/gpu-next/libplacebo]     2: flags 0x1 size  214M
[   2.574][d][vo/gpu-next/libplacebo] Memory types supported by device:
[   2.574][d][vo/gpu-next/libplacebo]     0: flags 0x0 heap 1
[   2.574][d][vo/gpu-next/libplacebo]     1: flags 0x1 heap 0
[   2.574][d][vo/gpu-next/libplacebo]     2: flags 0x1 heap 0
[   2.574][d][vo/gpu-next/libplacebo]     3: flags 0x6 heap 1
[   2.574][d][vo/gpu-next/libplacebo]     4: flags 0xe heap 1
[   2.574][d][vo/gpu-next/libplacebo]     5: flags 0x7 heap 2
[   2.574][e][vo/gpu-next/libplacebo] Memory pool 0:
[   2.574][e][vo/gpu-next/libplacebo]     Compatible types: 0x3
[   2.574][e][vo/gpu-next/libplacebo]     Optimal flags: 0x1
[   2.574][e][vo/gpu-next/libplacebo]     Export handle: 0x2
[   2.574][e][vo/gpu-next/libplacebo]     Slab  0:        c x 4320K: 6720K used 8640K res   16M alloc from heap 0, efficiency 77.78%  [unknown]
[   2.574][e][vo/gpu-next/libplacebo]     Pool summary: 6720K used 8640K res   16M alloc, efficiency 77.78%, utilization 50.00%
[   2.574][e][vo/gpu-next/libplacebo] Memory pool 1:
[   2.574][e][vo/gpu-next/libplacebo]     Compatible types: 0x3
[   2.574][e][vo/gpu-next/libplacebo]     Optimal flags: 0x1
[   2.574][e][vo/gpu-next/libplacebo]     Slab  0: fffffffe x  8192:  8192 used  8192 res  256K alloc from heap 0, efficiency 100.00%  [src/shaders/sampling.c:709]
[   2.574][e][vo/gpu-next/libplacebo]     Pool summary:  8192 used  8192 res  256K alloc, efficiency 100.00%, utilization 3.12%
[   2.574][e][vo/gpu-next/libplacebo] Memory pool 2:
[   2.574][e][vo/gpu-next/libplacebo]     Compatible types: 0xffffffff
[   2.574][e][vo/gpu-next/libplacebo]     Optimal flags: 0x3
[   2.574][e][vo/gpu-next/libplacebo]     Buffer flags: 0x3
[   2.574][e][vo/gpu-next/libplacebo]     Pool summary:     0 used     0 res     0 alloc, efficiency 100.00%, utilization 100.00%
[   2.574][e][vo/gpu-next/libplacebo] Memory summary: 6728K used 8648K res   17M alloc, efficiency 77.80%, utilization 49.32%, max page:  245M
[   2.592][e][vo/gpu-next/libplacebo]   for malloc: ../../../../../src_packages/libplacebo/src/gpu/utils.c:564
[   2.592][d][vo/gpu-next/libplacebo] Freeing slab of size  252K
[   2.592][e][vo/gpu-next/libplacebo] No slab to serve request for  1024 bytes (with alignment 0xc00) in pool 2!
[   2.592][e][vo/gpu-next/libplacebo] Failed creating LUT texture!
[   2.592][e][vo/gpu-next/libplacebo] Failed initializing polar LUT!
[   2.592][e][vo/gpu-next/libplacebo] Failed dispatching scaler.. disabling
[   2.592][e][vo/gpu-next/libplacebo] Attempting to modify a failed shader!

@haasn: Do you think we can optimize this memory allocation to work also on Vulkan?

Also I notice error handling is not great

[   2.715][e][vo/gpu-next/libplacebo] input:67: error: '' :  syntax error, unexpected LEFT_BRACE, expecting SEMICOLON

probably some NULL is substituted in shader code.

WilliamK7 commented 3 months ago

Hi, I'm having the same issue with gpu-context = winvk Here is the log file mpv-lazy.log

WilliamK7 commented 3 months ago

I updated my NVIDIA drive from 551.23 to 560.94, and the issue disappeared.

WilliamK7 commented 3 months ago

Sorry, but the issue reappears. Here is the new log file mpv-lazy.log

WilliamK7 commented 3 months ago

It's weird that after I restart my computer, the issue disappears again, so this issue is not related to the Nvidia drive problem.

planetrocky commented 3 months ago

It's weird that after I restart my computer, the issue disappears again, so this issue is not related to the Nvidia drive problem.

Initially on system boot mpv works correctly, after sometime it will go to "purple mode" until the computer is restarted.

For me mpv will show a solid purple screen of the correct dimensions when playing. On mpv start, it's a black screen and no overlay appears.

This occurs for all git "64bit" builds for at least the last 3-months (I've not exhaustively tested), from:

https://sourceforge.net/projects/mpv-player-windows/files/64bit/

mpv.conf:

profile=high-quality
vo=gpu-next
gpu-api=vulkan
hwdec=nvdec
osd-scale-by-window=no
taskbar-progress=no
autofit-larger=100%x100%
geometry=50%:25%
border=no
hr-seek=yes
hr-seek-framedrop=no
audio-exclusive=no
audio-channels=stereo

Always using Nvidia "Studio" drivers. Currently on 560.81 (tested also 560.70).

kasper93 commented 3 months ago

From the logs posted before, it looks like the issues starts with gpu memory allocation error, even for small chunks of memory. This also makes sense for your observation that it stops working after a while of PC use. You might be able to restore working state, by closing all applications that may be holding memory, have hardware acceleration. Also enabling resizable bar might help to mitigate the issue. But I think there was a fix for that already.

From log it doesn't look like libplacebo is leaking memory, maybe something else on your system does. Or we are trying to use memory type that is very small, dunno would need to read in more depth the log.

planetrocky commented 3 months ago

Yes. I just got a debug log myself:

[   1.458][d][vo/gpu-next/libplacebo] (Re)creating 3766x216x0 texture with format r8: unknown
[   1.458][d][vo/gpu-next/libplacebo] Allocating 3866624 memory of type 0x1 (id 1) in heap 0: unknown
[   1.459][d][vo/gpu-next/libplacebo] Spent 0.570 ms allocating slab
[   1.459][d][vo/gpu-next/libplacebo] Allocating 3538944 memory of type 0x7 (id 4) in heap 2: ../../../../../src_packages/libplacebo/src/gpu/utils.c:578
[   1.460][e][vo/gpu-next/libplacebo] Allocation of size 3456K failed: VK_ERROR_OUT_OF_DEVICE_MEMORY!
[   1.460][e][vo/gpu-next/libplacebo] Memory heaps supported by device:
[   1.460][e][vo/gpu-next/libplacebo]     0: flags 0x1 size   15G
[   1.460][e][vo/gpu-next/libplacebo]     1: flags 0x0 size   15G
[   1.461][e][vo/gpu-next/libplacebo]     2: flags 0x1 size  214M
[   1.461][d][vo/gpu-next/libplacebo] Memory types supported by device:
[   1.461][d][vo/gpu-next/libplacebo]     0: flags 0x0 heap 1
[   1.461][d][vo/gpu-next/libplacebo]     1: flags 0x1 heap 0
[   1.461][d][vo/gpu-next/libplacebo]     2: flags 0x6 heap 1
[   1.461][d][vo/gpu-next/libplacebo]     3: flags 0xe heap 1
[   1.461][d][vo/gpu-next/libplacebo]     4: flags 0x7 heap 2
[   1.461][e][vo/gpu-next/libplacebo] Memory pool 0:
[   1.461][e][vo/gpu-next/libplacebo]     Compatible types: 0x3
[   1.461][e][vo/gpu-next/libplacebo]     Optimal flags: 0x1
[   1.461][e][vo/gpu-next/libplacebo]     Slab  0:        e x  944K:  944K used  944K res 3776K alloc from heap 0, efficiency 100.00%  [unknown]
[   1.461][e][vo/gpu-next/libplacebo]     Pool summary:  944K used  944K res 3776K alloc, efficiency 100.00%, utilization 25.00%
[   1.461][e][vo/gpu-next/libplacebo] Memory pool 1:
[   1.461][e][vo/gpu-next/libplacebo]     Compatible types: 0xffffffff
[   1.461][e][vo/gpu-next/libplacebo]     Optimal flags: 0x3
[   1.461][e][vo/gpu-next/libplacebo]     Buffer flags: 0x3
[   1.462][e][vo/gpu-next/libplacebo]     Pool summary:     0 used     0 res     0 alloc, efficiency 100.00%, utilization 100.00%
[   1.462][e][vo/gpu-next/libplacebo] Memory summary:  944K used  944K res 3776K alloc, efficiency 100.00%, utilization 25.00%, max page: 1002M
[   1.465][e][vo/gpu-next/libplacebo]   Backtrace:
[   1.468][e][vo/gpu-next/libplacebo]     #0  0x7ff73cf301e6 in pl_shader_error_diffusion+0x55e66 (C:\Applications\mpv\mpv.exe+0x1db01e6) (0x141db01e6)
[   1.469][e][vo/gpu-next/libplacebo]     #1  0x7ff73cf2ee6a in pl_shader_error_diffusion+0x54aea (C:\Applications\mpv\mpv.exe+0x1daee6a) (0x141daee6a)
[   1.470][e][vo/gpu-next/libplacebo]     #2  0x7ff73cf33aec in pl_shader_error_diffusion+0x5976c (C:\Applications\mpv\mpv.exe+0x1db3aec) (0x141db3aec)
[   1.473][e][vo/gpu-next/libplacebo]     #3  0x7ff73c3dced4 in pl_buf_create+0x4d4 (C:\Applications\mpv\mpv.exe+0x125ced4) (0x14125ced4)
[   1.474][e][vo/gpu-next/libplacebo]     #4  0x7ff73cee11e6 in pl_shader_error_diffusion+0x6e66 (C:\Applications\mpv\mpv.exe+0x1d611e6) (0x141d611e6)
[   1.475][e][vo/gpu-next/libplacebo]     #5  0x7ff73c29d67c in mpv_render_context_get_info+0x1515c (C:\Applications\mpv\mpv.exe+0x111d67c) (0x14111d67c)
[   1.477][e][vo/gpu-next/libplacebo]     #6  0x7ff73c2998a2 in mpv_render_context_get_info+0x11382 (C:\Applications\mpv\mpv.exe+0x11198a2) (0x1411198a2)
[   1.479][e][vo/gpu-next/libplacebo]     #7  0x7ff73c284e47 in mpv_stream_cb_add_ro+0x939b7 (C:\Applications\mpv\mpv.exe+0x1104e47) (0x141104e47)
[   1.482][e][vo/gpu-next/libplacebo]     #8  0x7ffece9d1bb1 in configthreadlocale+0x91 (C:\WINDOWS\System32\ucrtbase.dll+0x21bb1) (0x180021bb1)
[   1.485][e][vo/gpu-next/libplacebo]     #9  0x7ffed0cb7373 in BaseThreadInitThunk+0x13 (C:\WINDOWS\System32\KERNEL32.DLL+0x17373) (0x180017373)
[   1.488][e][vo/gpu-next/libplacebo]     #10 0x7ffed131cc90 in RtlUserThreadStart+0x20 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x4cc90) (0x18004cc90)
[   1.489][e][vo/gpu-next/libplacebo]   for malloc: ../../../../../src_packages/libplacebo/src/gpu/utils.c:578
[   1.489][d][vo/gpu-next/libplacebo] Freeing slab of size 3456K
[   1.489][e][vo/gpu-next/libplacebo] No slab to serve request for  863K bytes (with alignment 0xc00) in pool 1!
[   1.489][e][vo/gpu-next] Failed uploading OSD texture!
planetrocky commented 3 months ago

From the logs posted before, it looks like the issues starts with gpu memory allocation error, even for small chunks of memory. This also makes sense for your observation that it stops working after a while of PC use. You might be able to restore working state, by closing all applications that may be holding memory, have hardware acceleration. Also enabling resizable bar might help to mitigate the issue. But I think there was a fix for that already.

From log it doesn't look like libplacebo is leaking memory, maybe something else on your system does. Or we are trying to use memory type that is very small, dunno would need to read in more depth the log.

My GPU has 16GB VRAM, and currently ~2GB is being used for screens and misc windows programs. There is 14GB VRAM free currently.

WilliamK7 commented 3 months ago

Also enabling resizable bar might help to mitigate the issue.

That's right, I tried to enable it in my BIOS settings several days ago. After that, the problem hasn't occurred so far.

planetrocky commented 2 months ago

My PC isn't compatible with resizable BAR :(