luisbocanegra / plasma-smart-video-wallpaper-reborn

Plasma 6 wallpaper plugin to play videos on your Desktop/Lock Screen.
https://store.kde.org/p/2139746
GNU General Public License v2.0
54 stars 1 forks source link

Hardware acceleration stops working after I turn off my monitor. #35

Open laichiaheng opened 1 month ago

laichiaheng commented 1 month ago

If I turn off my monitor and turn it on again, the hardware acceleration stops working. The desktop become super laggy when I right click on my desktop.

Is it possible to use MPV as backend?

By the way, you need gstreamer-vaapi in ArchLinux.

luisbocanegra commented 1 month ago

Can't reproduce here with Intel iGPU (UHD Graphics 630). I need more info

Is it possible to use MPV as backend?

yes https://github.com/mpv-player/mpv-examples/tree/master/libmpv/qml in fact https://github.com/catsout/wallpaper-engine-kde-plugin/tree/qt6 supports it, not sure when I will look into that so no ETA, (PRs welcome)

laichiaheng commented 1 month ago

Can't reproduce here with Intel iGPU (UHD Graphics 630). I need more info

* Run `kinfo` and share the output

Operating System: Arch Linux KDE Plasma Version: 6.1.2 KDE Frameworks Version: 6.3.0 Qt Version: 6.7.2 Kernel Version: 6.9.9-zen1-1-zen (64-bit) Graphics Platform: Wayland Processors: 16 × AMD Ryzen 7 3700X 8-Core Processor Memory: 31.2 GiB of RAM Graphics Processor: AMD Radeon RX 6750 XT

* You mention gstreamer, are you using it as qt-multimedia back-end? If so, why

Doesn't it need gstreamer? I saw gstreamer in README page, so I installed it.

* Send a screenshot of the wallpaper settings

圖片

* Enable debug node in wallpaper settings, run `journalctl -f > log.txt` after reproducing the issue end the command and attach the log here

log.txt

Is it possible to use MPV as backend?

yes https://github.com/mpv-player/mpv-examples/tree/master/libmpv/qml in fact https://github.com/catsout/wallpaper-engine-kde-plugin/tree/qt6 supports it, not sure when I will look into that so no ETA, (PRs welcome)

I don't understand what the first link says.

luisbocanegra commented 1 month ago

Doesn't it need gstreamer? I saw gstreamer in README page, so I installed it.

Only if you switch to gstreamer as video backend (also in the README) but should only need that if ffmpeg one (the default and what you are most likely using) has problems.

Since you have problems with the HW decoding you can try enabling it (the environment variable part) to see if it works any better. There are some bugs with Qt Multimedia and AMD and this is probably another.

I also suggest doing the same while playing videos on other programs where decoding is working to discard this being a driver bug.

If the problem seems to be only with the wallpaper please run this qml example https://gist.github.com/luisbocanegra/cb758ee5f57a9e7c2838b1db349b635a#file-testmediaplayer-qml download it and run it like this QSG_INFO=1 QT_LOGGING_RULES="qml.debug=true" qml6 testMediaPlayer.qml > qml_log.txt and try to reproduce the problem. If only the qml fails share the generated log file.

I don't understand what the first link says.

No problem, first is just an example of how to implement mpv support and the second is another wallpaper plugin that already supports it. Personally I am not very well versed in C++/lower level stuff so this was more of a hint in case someone was to help implementing it

luisbocanegra commented 1 month ago

Also it seems you didn't enable debug mode or the qml logging level has changed to warning by default I am not sure.

Set plasmashell to full debug in KDebugSettings and reboot, if there are no debug logs from the wallpaper you may need to do https://develop.kde.org/docs/plasma/widget/testing/#enable-logging too.

laichiaheng commented 1 month ago

Also it seems you didn't enable debug mode or the qml logging level has changed to warning by default I am not sure.

Set plasmashell to full debug in KDebugSettings and reboot, if there are no debug logs from the wallpaper you may need to do https://develop.kde.org/docs/plasma/widget/testing/#enable-logging too.

Should I replace kwriteconfig5 to kwriteconfig6?

laichiaheng commented 1 month ago

Doesn't it need gstreamer? I saw gstreamer in README page, so I installed it.

Only if you switch to gstreamer as video backend (also in the README) but should only need that if ffmpeg one (the default and what you are most likely using) has problems.

Since you have problems with the HW decoding you can try enabling it (the environment variable part) to see if it works any better. There are some bugs with Qt Multimedia and AMD and this is probably another.

I also suggest doing the same while playing videos on other programs where decoding is working to discard this being a driver bug.

If the problem seems to be only with the wallpaper please run this qml example https://gist.github.com/luisbocanegra/cb758ee5f57a9e7c2838b1db349b635a#file-testmediaplayer-qml download it and run it like this QSG_INFO=1 QT_LOGGING_RULES="qml.debug=true" qml6 testMediaPlayer.qml > qml_log.txt and try to reproduce the problem. If only the qml fails share the generated log file.

I don't understand what the first link says.

No problem, first is just an example of how to implement mpv support and the second is another wallpaper plugin that already supports it. Personally I am not very well versed in C++/lower level stuff so this was more of a hint in case someone was to help implementing it

qml_log.txt

I also notice that I can't drag files into text block after turning off my monitor.

luisbocanegra commented 1 month ago

Should I replace kwriteconfig5 to kwriteconfig6?

Yes

laichiaheng commented 1 month ago

I also see this happen when I log out and log in again, is it a Plasma6 bug? I forgot to enable debug mode in setting, here is the new log log.txt The stutter problem is harder to see when I try to record it with OBS.

luisbocanegra commented 1 month ago

qml_log.txt

Sorry that file is empty, you need to use this command QT_FFMPEG_DEBUG=1 QSG_INFO=1 QT_LOGGING_RULES="*.debug=true" qml6 testMediaPlayer.qml 2> qml_log.txt

I also notice that I can't drag files into text block after turning off my monitor.

This is a plasma wayland bug, (unrelated to this wallpaper plugin), you should report this in bugs.kde.org

laichiaheng commented 1 month ago

Sorry that file is empty, you need to use this command QT_FFMPEG_DEBUG=1 QSG_INFO=1

qml_log.txt

luisbocanegra commented 1 month ago

I need you to answer these questions please, otherwise I am making guesses here

Does the testMediaPlayer.qml also loses hardware decoding after turning off the monitor?

What about firefox or mpv --hwdec=auto-safe 'video.mp4' --loop if those also lose hardare acceleration then the problem is somewhere else and not caused by this wallpaper plugin.

laichiaheng commented 1 month ago

I need you to answer these questions please, otherwise I am making guesses here

Does the testMediaPlayer.qml also loses hardware decoding after turning off the monitor? Nope.

What about firefox or mpv --hwdec=auto-safe 'video.mp4' --loop if those also lose hardare acceleration then the problem is somewhere else and not caused by this wallpaper plugin.

The hardware acceleration works as expected with mpv --no-config --hwdec=auto-safe Before I turn off my monitor: 螢幕截圖_20240715_133533 After I turn on my monitor: 螢幕截圖_20240715_133621 (The text became blur though)

I don't know how to test it on Firefox.

I noticed that the decoding usage of my GPU in AMDGPU_TOP increased dramatically after I turned on my monitor with the live wallpaper enabled. Before: 螢幕截圖_20240715_134806 (Only about 10%) After: 螢幕截圖_20240715_134839 (Sometimes over 45%)

luisbocanegra commented 1 month ago

The hardware acceleration works as expected with mpv --no-config --hwdec=auto-safe

Then the problem is (most likely) in Qt or KDE, I suspect this could be related to the other AMD playback bugs that were also reported in this repo, as none of them seems to happen on Intel or Nvidia GPU

If you switch back to Image wallpaper, and run the qml6 testMediaPlayer.qml then suspend and resume does the decoding usage increases too? If so then the problem is with Qt

laichiaheng commented 1 month ago

qml6 testMediaPlayer.qml

The usage is really low, so I can't tell the difference. But once I have turned off my monitor, the usage rises when I enable the live wallpaper for the 1st time, only reboot can fix it.

luisbocanegra commented 1 month ago

The usage is really low, so I can't tell the difference.

You can replace the video array with a large video from your disk like this

testmediaplayer.qml line #12

property var videos: ["/path/to/video.mp4"]

Then run the testMediaPlayer.qml file again, do the monitor off/on and let me know if the decoding usage also increases

laichiaheng commented 1 month ago

The usage is really low, so I can't tell the difference.

You can replace the video array with a large video from your disk like this

testmediaplayer.qml line #12

property var videos: ["/path/to/video.mp4"]

Then run the testMediaPlayer.qml file again, do the monitor off/on and let me know if the decoding usage also increases

Yes, it does. After playing 4K 23.976fps video, it rises from 6% to 10-13%. I hope Qt developers can notice it.

luisbocanegra commented 1 month ago

Yes, it does. After playing 4K 23.976fps video, it rises from 6% to 10-13%.

laichiaheng commented 1 month ago

Yes, it does. After playing 4K 23.976fps video, it rises from 6% to 10-13%.

* Does the desktop also lag?

If I try to drag the window or resize it, yes.

* Does stopping the qml6 command and running it again restores the usage back to normal?

Nope. I need to reboot my PC.

luisbocanegra commented 1 month ago

Thanks, will file a Qt bug report when I have the time.

laichiaheng commented 1 month ago

Thanks, will file a Qt bug report when I have the time.

By the way, it also happens if I switch SDR/HDR mode.

laichiaheng commented 3 weeks ago

Thanks, will file a Qt bug report when I have the time.

The situation has become worse than before, if I turn off my monitor and turn it on again, I can see the glitches on whole desktop environment.

laichiaheng commented 3 weeks ago

@luisbocanegra Hi, if I disable VRR on the monitor side, there seem to be no such issue. Is it caused by the MESA driver?

luisbocanegra commented 3 weeks ago

if I disable VRR on the monitor side, there seem to be no such issue.

Which issue is gone without VRR, the HW acceleration, the flickering or both?

Is it caused by the MESA driver?

You mention that the testMediaPlayer.qml doesn't loose HW acceleration after suspending (sorry I missed that response), if it doesn't flicker with VRR either then it could mean that the problem could be in the driver but I can't be 100% sure of that unless you were able to reproduce in other applications

There are two more things you can try:

Let me know if any of these worked (just make sure you try only one at a time)