hyprwm / xdg-desktop-portal-hyprland

xdg-desktop-portal backend for Hyprland
BSD 3-Clause "New" or "Revised" License
273 stars 47 forks source link

Multiple processes with maximum CPU usage #103

Closed joelsleeba closed 11 months ago

joelsleeba commented 12 months ago

OS: Arch Kernel: 6.5.5-arch1-1 Hyprland: 0.30.0-1 xdg-desktop-portal-hyprland: 1.1.0-3

steps to reproduce:

  1. Start Hyprland
  2. Exit Hyprland
  3. Start Hyprland

Now there was maximum CPU usage. I checked htop to find two proceses with PID 777 and 829, both of xdg-desktop-portal-hyprland utilizing over 100% of the CPU thread. I ran strace on the two processes. Details below

trace of 777

[pid   777] <... futex resumed>)        = 0
[pid   829] <... poll resumed>)         = 1 ([{fd=6, revents=POLLIN|POLLHUP}])
[pid   777] futex(0x56437ec5e390, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
[pid   829] futex(0x56437ec5e390, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
[pid   777] <... futex resumed>)        = -1 EAGAIN (Resource temporarily unavailable)
[pid   829] <... futex resumed>)        = 0
[pid   777] futex(0x56437ec5e3c8, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
[pid   829] futex(0x56437ec5e3c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   777] <... futex resumed>)        = -1 EAGAIN (Resource temporarily unavailable)
[pid   829] <... futex resumed>)        = 0
[pid   777] futex(0x56437ec5e398, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   829] poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}], 3, -1 <unfinished ...>
[pid   777] <... futex resumed>)        = 0
[pid   829] <... poll resumed>)         = 1 ([{fd=6, revents=POLLIN|POLLHUP}])
[pid   777] futex(0x56437ec5e3c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   829] poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}], 3, -1 <unfinished ...>
[pid   777] <... futex resumed>)        = 0
[pid   829] <... poll resumed>)         = 1 ([{fd=6, revents=POLLIN|POLLHUP}])
[pid   777] futex(0x56437ec5e394, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
[pid   829] futex(0x56437ec5e394, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
[pid   777] <... futex resumed>)        = -1 EAGAIN (Resource temporarily unavailable)
[pid   829] <... futex resumed>)        = 0
[pid   777] futex(0x56437ec5e3c8, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
[pid   829] futex(0x56437ec5e3c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   777] <... futex resumed>)        = -1 EAGAIN (Resource temporarily unavailable)
[pid   829] <... futex resumed>)        = 0
[pid   777] futex(0x56437ec5e398, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   829] poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}], 3, -1 <unfinished ...>
[pid   777] <... futex resumed>)        = 0
[pid   829] <... poll resumed>)         = 1 ([{fd=6, revents=POLLIN|POLLHUP}])
[pid   777] futex(0x56437ec5e3c8, FUTEX_WAKE_PRIVATE, 1^C[pid   829] poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}], 3, -1strace: Process 777 detached

trace of 829

[pid   777] <... futex resumed>)        = 0
[pid   829] <... poll resumed>)         = 1 ([{fd=6, revents=POLLIN|POLLHUP}])
[pid   777] futex(0x56437ec5e394, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
[pid   829] futex(0x56437ec5e394, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
[pid   777] <... futex resumed>)        = -1 EAGAIN (Resource temporarily unavailable)
[pid   829] <... futex resumed>)        = 0
[pid   777] futex(0x56437ec5e3c8, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
[pid   829] futex(0x56437ec5e3c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   777] <... futex resumed>)        = -1 EAGAIN (Resource temporarily unavailable)
[pid   829] <... futex resumed>)        = 0
[pid   777] futex(0x56437ec5e398, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   829] poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}], 3, -1 <unfinished ...>
[pid   777] <... futex resumed>)        = 0
[pid   829] <... poll resumed>)         = 1 ([{fd=6, revents=POLLIN|POLLHUP}])
[pid   777] futex(0x56437ec5e3c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   829] poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}], 3, -1 <unfinished ...>
[pid   777] <... futex resumed>)        = 0
[pid   829] <... poll resumed>)         = 1 ([{fd=6, revents=POLLIN|POLLHUP}])
[pid   777] futex(0x56437ec5e390, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY <unfinished ...>
[pid   829] futex(0x56437ec5e390, FUTEX_WAKE_PRIVATE, 2147483647 <unfinished ...>
[pid   777] <... futex resumed>)        = -1 EAGAIN (Resource temporarily unavailable)
[pid   829] <... futex resumed>)        = 0
[pid   777] futex(0x56437ec5e3c8, FUTEX_WAIT_PRIVATE, 2, NULL <unfinished ...>
[pid   829] futex(0x56437ec5e3c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   777] <... futex resumed>)        = -1 EAGAIN (Resource temporarily unavailable)
[pid   829] <... futex resumed>)        = 0
[pid   777] futex(0x56437ec5e398, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
[pid   829] poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}], 3, -1 <unfinished ...>
[pid   777] <... futex resumed>)        = 0
[pid   829] <... poll resumed>)         = 1 ([{fd=6, revents=POLLIN|POLLHUP}])
[pid   777] futex(0x56437ec5e3c8, FUTEX_WAKE_PRIVATE, 1 <unfinished ...>
^C[pid   829] poll([{fd=3, events=POLLIN}, {fd=6, events=POLLIN}, {fd=7, events=POLLIN}], 3, -1strace: Process 829 detached
vaxerski commented 12 months ago

what if you kill xdph and restart it? Maybe it's an old session that is confused?

thejch commented 12 months ago

have this issue too. for me restarting xdph fixes it, but if i reboot this happens again

darknebula05 commented 12 months ago

I am having a similar issue where if I close hyprland and restart it, there is an xdph process that is taking a large amount of cpu. Killing the process works fine and the issue goes away until I restart hyprland again.

joelsleeba commented 12 months ago

Yes. Same behavior. Once I kill one of those processes, the CPU usage is back to normal, but at the expense of xdg-..-hyprland. It happens almost every time I exit and relaunch Hyprland.

On Sun, 1 Oct 2023 at 09:36, darknebula05 @.***> wrote:

I am having a similar issue where if I close hyprland and restart it, there is an xdph process that is taking a large amount of cpu. Killing the process works fine and the issue goes away until I restart hyprland again.

— Reply to this email directly, view it on GitHub https://github.com/hyprwm/xdg-desktop-portal-hyprland/issues/103#issuecomment-1741949300, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANCQNW5IWQJYADKFK2BGOP3X5DT2TANCNFSM6AAAAAA5M5JRUM . You are receiving this because you authored the thread.Message ID: @.***>

vaxerski commented 12 months ago

patch.txt

Apply this patch, add -v to launching xdph and redirect its logs to somewhere (so e.g. -v > /tmp/xdphlog) and provide the log from an offending session, please :)

joelsleeba commented 12 months ago
[LOG] Initializing xdph...
[CRITICAL] Couldn't create the dbus connection ([org.freedesktop.DBus.Error.FileExists] Failed to request bus name (File exists))

This was the output. I don't know where to run xdph from. I added it to the hyprland config with exec-once

vaxerski commented 12 months ago

try the nuclear script from here

joelsleeba commented 11 months ago

I used the code snippet. But now I cannot seem to get a conflicting session and hence no cpu throttling. I wonder if it is because the script kills xdph beforehand.

vaxerski commented 11 months ago

possible

houdinihacker commented 11 months ago

Same for me (I'm using sway). Found this topic when my coolers went to the moon. I'll try to apply patch today and let you know

vaxerski commented 11 months ago

check with the above commit please :)

pavanbhat1999 commented 11 months ago

Hope fix comes into release version soon.

I have the same issue in Nixos as well. Little bit modification in nuclear script is working fine for now.

thejch commented 11 months ago

Issue seems fixed on the latest commit

vaxerski commented 11 months ago

closing then

bill88t commented 11 months ago

Requesting reopen.

xdg-desktop-portal-hyprland 1.2.1-1 still exhibits this issue for me (arch, up-to-date). fine on boot -> logout -> login -> xdph takes up 20% cpu. systemctl --user restart fixes it.

I installed hyperland today, so I have no clue about previous versions.

bill88t commented 11 months ago

Nevermind, just tested it. 1.2.0 -> 1.2.1 reintroduces this issue.

vaxerski commented 11 months ago

I'll just make a nuclear solution tomorrow I guess, it's some damn thread in a deadlock most likely

vaxerski commented 11 months ago

done 667007fa4e370e7fbac5d9e6789b119f9456cf75