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

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

Open
laichiaheng opened this issue Jul 14, 2024 · 23 comments
Open
Labels
amd gpu bug Something isn't working help wanted Extra attention is needed performance Qt Likely depends on Qt to implement/fix

Comments

@laichiaheng
Copy link

laichiaheng commented Jul 14, 2024

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
Copy link
Owner

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

  • Run kinfo and share the output
  • You mention gstreamer, are you using it as qt-multimedia back-end? If so, why
  • 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

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
Copy link
Author

laichiaheng commented Jul 15, 2024

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
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

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
Copy link
Author

laichiaheng commented Jul 15, 2024

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
Copy link
Owner

Should I replace kwriteconfig5 to kwriteconfig6?

Yes

@laichiaheng
Copy link
Author

laichiaheng commented Jul 15, 2024

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
Copy link
Owner

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
Copy link
Author

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

qml_log.txt

@luisbocanegra
Copy link
Owner

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
Copy link
Author

laichiaheng commented Jul 15, 2024

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
Copy link
Owner

luisbocanegra commented Jul 15, 2024

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
Copy link
Author

laichiaheng commented Jul 15, 2024

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
Copy link
Owner

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
Copy link
Author

laichiaheng commented Jul 15, 2024

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
Copy link
Owner

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

  • Does the desktop also lag?
  • Does stopping the qml6 command and running it again restores the usage back to normal?

@luisbocanegra luisbocanegra added bug Something isn't working help wanted Extra attention is needed amd gpu performance Qt Likely depends on Qt to implement/fix labels Jul 15, 2024
@laichiaheng
Copy link
Author

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
Copy link
Owner

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

@laichiaheng
Copy link
Author

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
Copy link
Author

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
Copy link
Author

@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
Copy link
Owner

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:

  • Switching to the gstreamer backend as per the README
  • Forcefully disable hardware video decoding by adding LIBVA_DRIVER_NAME=nothing to /etc/environment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
amd gpu bug Something isn't working help wanted Extra attention is needed performance Qt Likely depends on Qt to implement/fix
Projects
None yet
Development

No branches or pull requests

2 participants