hyprwm / Hyprland

Hyprland is an independent, highly customizable, dynamic tiling Wayland compositor that doesn't sacrifice on its looks.
https://hyprland.org
BSD 3-Clause "New" or "Revised" License
21.41k stars 898 forks source link

Memory leak during screenshare/recording in obs/discord/etc #7787

Closed cuddleplush closed 3 weeks ago

cuddleplush commented 1 month ago

Already reported ? *

Regression?

No

System Info and Version

System/Version info ```sh Hyprland, built from branch at commit d35e70a8c6599bb058cf86eb87c783ce1cf72471 dirty (cmake: drop ninja dep). Date: Fri Sep 13 18:56:44 2024 Tag: v0.43.0-22-gd35e70a8, commits: 5218 flags: (if any) System Information: System name: Linux Node name: violet Release: 6.10.9-violet Version: #1 SMP PREEMPT_DYNAMIC TKG Mon Sep 9 17:57:33 CEST 2024 GPU information: 09:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 23 [Radeon RX 6650 XT / 6700S / 6800S] [1002:73ef] (rev c1) (prog-if 00 [VGA controller]) os-release: NAME=Gentoo ID=gentoo PRETTY_NAME="Gentoo Linux" ANSI_COLOR="1;32" HOME_URL="https://www.gentoo.org/" SUPPORT_URL="https://www.gentoo.org/support/" BUG_REPORT_URL="https://bugs.gentoo.org/" VERSION_ID="2.15" plugins: hyprsplit by shezdy ver 1.0 hyprbars by Vaxry ver 1.0 ======Config-Start====== Config File: /home/max/.config/hypr/hyprland.conf: Read Succeeded # __ __ __ # / /_ __ ______ _____/ /___ _____ ____/ / # / __ \/ / / / __ \/ ___/ / __ `/ __ \/ __ / # / / / / /_/ / /_/ / / / / /_/ / / / / /_/ / # /_/ /_/\__, / .___/_/ /_/\__,_/_/ /_/\__,_/ # /____/_/ # Monitors monitor = DP-3, highrr, 1920x0, 1 monitor = HDMI-A-1, highrr, 0x0, 1 # Source files source = ~/.config/hypr/hyprland/vars.hl source = ~/.config/hypr/hyprland/env.hl source = ~/.config/hypr/hyprland/auto.hl source = ~/.config/hypr/hyprland/binds.hl source = ~/.config/hypr/hyprland/opts.hl source = ~/.config/hypr/hyprland/rules.hl Config File: /home/max/.config/hypr/hyprland/vars.hl: Read Succeeded $term = footclient # $menu = tofi-drun --drun-launch=true $menu = rofi -show drun $fman = nemo $shot = grimblast --notify copysave area $edit = emacsclient -c $wall = mpvpaper '*' ~/Videos/mpvpaper/ -o "--hwdec yes no-audio --loop inf --loop-playlist inf input-ipc-server=/tmp/mpv-socket" --fork $cw = cat /home/max/.cache/swww/DP-3 $waybar-mono = waybar -c ~/.config/waybar/mono/config.jsonc -s ~/.config/waybar/mono/style.css $waybar-cloud = waybar -c ~/.config/waybar/cloud/config.jsonc -s ~/.config/waybar/cloud/style.css $waybar-bun = waybar -c ~/.config/waybar/bun/config.jsonc -s ~/.config/waybar/bun/style.css && hyprctl keyword decoration:rounding 15 Config File: /home/max/.config/hypr/hyprland/env.hl: Read Succeeded # Env vars env = XDG_CURRENT_DESKTOP, Hyprland env = XDG_SESSION_DESKTOP, Hyprland env = MOZ_ENABLE_WAYLAND, 1 env = QT_QPA_PLATFORM, wayland;xcb env = QT_QPA_PLATFORMTHEME, qt6ct env = CMAKE_COLOR_DIAGNOSTICS, ON env = BROWSER, /usr/bin/librewolf # env = AQ_NO_ATOMIC, 1 # env = WLR_DRM_NO_ATOMIC, 1 env = ZDOTDIR, $HOME/.config/zsh env = PATH, /home/max/.local/bin:$PATH env = EDITOR, /usr/bin/nvim env = DXVK_ASYNC, 1 env = HYPRCURSOR_THEME, Bibata-Modern-Classic env = HYPRCURSOR_SIZE, 24 env = GTK_THEME, Graphite-Dark env = ICON_THEME, Reversal-dark env = DOTNET_CLI_TELEMETRY_OPTOUT, 1 Config File: /home/max/.config/hypr/hyprland/auto.hl: Read Succeeded # Initialize plugins exec-once = sleep 1 && hyprpm reload -n & # Setup environment exec-once = dbus-update-activation-environment WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=Hyprland & exec-once = gentoo-pipewire-launcher restart & exec-once = wl-paste -t text --watch clipman store --no-persist & # Setup UI exec-once = /usr/libexec/polkit-gnome-authentication-agent-1 & exec-once = mako & exec-once = swayosd-server & exec-once = sleep 0.5 && ags-old -c ~/.config/ags/mono/config.js > /dev/null & # exec-once = sleep 0.5 && ags -c ~/.config/ags/astal > /dev/null & # Start daemons exec-once = swww-daemon & exec-once = openrazer-daemon & exec-once = razer-cli --restore & exec-once = foot --server & exec-once = xembedsniproxy & # Start user apps exec-once = corectrl --minimize-systray & # exec-once = sleep 3 && vesktop & Config File: /home/max/.config/hypr/hyprland/binds.hl: Read Succeeded # Keybinds $mainMod = SUPER bind = $mainMod, Return, exec, $term bind = $mainMod SHIFT, Return, exec, $fman bind = $mainMod, S, exec, $shot bind = $mainMod, D, exec, $menu bind = $mainMod, A, exec, $edit bind = $mainMod SHIFT, P, exec, hyprpicker -f hex -a -r bind = $mainMod ALT, P, exec, foot --hold hyprprop bind = $mainMod, R, exec, ags-old -q && ags-old -c ~/.config/ags/mono/config.js > /dev/null & bind = $mainMod, X, exec, ags-old -t power bind = $mainMod, W, exec, rofi-wall.sh bind = $mainMod, V, exec, clipman pick -t rofi bind = $mainMod, L, exec, hyprshade toggle blue-light-filter bind = $mainMod SHIFT, space, exec, echo 'cycle pause' | socat - /tmp/mpv-socket bind = $mainMod, P, pseudo, bind = $mainMod, space, togglefloating, bind = $mainMod, space, resizeactive, exact 1000 700 bind = $mainMod, space, centerwindow, 0 bind = $mainMod, C, centerwindow, 0 bind = $mainMod SHIFT, F, fullscreen, 0 bind = $mainMod SHIFT, M, fullscreen, 1 bind = $mainMod, J, togglesplit, bind = $mainMod, G, togglegroup, bind = $mainMod, B, changegroupactive, f bind = $mainMod SHIFT, B, changegroupactive, b bind = $mainMod, Q, killactive, bind = $mainMod SHIFT, O, exit, bind = $mainMod, Tab, exec, playerctl play-pause # bind = $mainMod, escape, hycov:toggleoverview bind = $mainMod, Left, movefocus, l bind = $mainMod, Right, movefocus, r bind = $mainMod, Up, movefocus, u bind = $mainMod, Down, movefocus, d bind = $mainMod SHIFT, Left, movewindow, l bind = $mainMod SHIFT, Right, movewindow, r bind = $mainMod SHIFT, Up, movewindow, u bind = $mainMod SHIFT, Down, movewindow, d bind = $mainMod, 1, split:workspace, 1 bind = $mainMod, 2, split:workspace, 2 bind = $mainMod, 3, split:workspace, 3 bind = $mainMod, 4, split:workspace, 4 bind = $mainMod, 5, split:workspace, 5 bind = $mainMod, 6, split:workspace, 6 bind = $mainMod, 7, split:workspace, 7 bind = $mainMod, 8, split:workspace, 8 bind = $mainMod, 9, split:workspace, 9 bind = $mainMod, 0, split:workspace, 10 bind = $mainMod SHIFT, 1, split:movetoworkspacesilent, 1 bind = $mainMod SHIFT, 2, split:movetoworkspacesilent, 2 bind = $mainMod SHIFT, 3, split:movetoworkspacesilent, 3 bind = $mainMod SHIFT, 4, split:movetoworkspacesilent, 4 bind = $mainMod SHIFT, 5, split:movetoworkspacesilent, 5 bind = $mainMod SHIFT, 6, split:movetoworkspacesilent, 6 bind = $mainMod SHIFT, 7, split:movetoworkspacesilent, 7 bind = $mainMod SHIFT, 8, split:movetoworkspacesilent, 8 bind = $mainMod SHIFT, 9, split:movetoworkspacesilent, 9 bind = $mainMod SHIFT, 0, split:movetoworkspacesilent, 10 bind = , XF86AudioLowerVolume, exec, swayosd-client --output-volume lower bind = , XF86AudioRaiseVolume, exec, swayosd-client --output-volume raise bind = CTRL, XF86AudioLowerVolume, exec, swayosd-client --input-volume lower bind = CTRL, XF86AudioRaiseVolume, exec, swayosd-client --input-volume raise bind = , XF86AudioMute, exec, swayosd-client --input-volume mute-toggle bind = , Caps_Lock, exec, swayosd-client --caps-lock-led input7::capslock bind = CTRL_SHIFT, m, pass, ^(VencordDesktop)$ bind = , F9, pass, ^(com\.obsproject\.Studio)$ bind = $mainMod, bracketright, pass, ^(com\.obsproject\.Studio)$ bindm = $mainMod, mouse:272, movewindow bindm = $mainMod, mouse:273, resizewindow Config File: /home/max/.config/hypr/hyprland/opts.hl: Read Succeeded # Main Settings general { gaps_in = 5 gaps_out = 10, 10, 10, 10 border_size = 0 col.active_border = rgb(cdcdcd) col.inactive_border = rgb(2f2f2f) resize_on_border = false no_focus_fallback = true allow_tearing = false layout = dwindle } decoration { rounding = 0 shadow_ignore_window = false drop_shadow = true shadow_range = 10 shadow_render_power = 2 col.shadow = rgba(0a0a0a66) blur { enabled = false } } animations { enabled = true bezier = hyprnostretch, 0.05, 0.9, 0.1, 1 # Hyprland's default but no stretch animation = windows, 1, 3, hyprnostretch, slide animation = windowsOut, 1, 7, default, popin 80% animation = border, 1, 10, default animation = fade, 1, 3, default animation = workspaces, 1, 3, hyprnostretch, slide animation = layers, 1, 3, hyprnostretch, fade } input { kb_layout = eu,ru kb_options = grp:alt_shift_toggle scroll_method = no_scroll follow_mouse = 1 mouse_refocus = false accel_profile = flat repeat_rate = 60 repeat_delay = 500 natural_scroll = false sensitivity = 0 } group { groupbar { col.inactive = rgb(cdcdcd) rgb(cdcdcd) col.active = rgb(ff7eb6) gradients = false font_size = 12 render_titles = false } } dwindle { pseudotile = true preserve_split = true force_split = 2 } master { new_status = master } misc { vfr = false vrr = 0 enable_swallow = true; swallow_regex = "^(foot)$"; force_default_wallpaper = false disable_hyprland_logo = true } binds { workspace_center_on = 1 } plugin { hyprbars { # example config bar_height = 35 bar_color = rgb(1b1b1b) col.text = rgb(CDCDCD) bar_text_size = 11 bar_text_font = BlexMono Nerd Font Propo bar_text_align = left bar_buttons_alignment = right bar_padding = 7 bar_button_padding = 8 bar_part_of_window = true bar_precedence_over_border = true hyprbars-button = rgb(1b1b1b), 20, , hyprctl dispatch killactive hyprbars-button = rgb(1b1b1b), 20, , hyprctl dispatch togglefloating && hyprctl dispatch resizeactive exact 1000 700 && hyprctl dispatch centerwindow 0 } } debug { error_position = 1 error_limit = 1 # disable_logs = false } Config File: /home/max/.config/hypr/hyprland/rules.hl: Read Succeeded # Windowrules windowrule = float, title:File Operation Progress windowrule = float, title:Confirm to replace files windowrule = size 1000 500,title:Wine configuration windowrule = tile,title:Spotify windowrule = plugin:hyprbars:nobar,LibreWolf windowrule = plugin:hyprbars:nobar,lutris windowrule = plugin:hyprbars:nobar,steam windowrule = plugin:hyprbars:nobar,firefox windowrule = plugin:hyprbars:nobar,moe.launcher.an-anime-game-launcher windowrule = plugin:hyprbars:nobar,YouTube Music windowrule = plugin:hyprbars:nobar,showmethekey-gtk windowrule = plugin:hyprbars:nobar,brave-browser windowrule = plugin:hyprbars:nobar,zen-alpha windowrule = plugin:hyprbars:nobar,chromium-browser windowrule = plugin:hyprbars:nobar,Cider windowrule = plugin:hyprbars:nobar,lunarclient windowrule = plugin:hyprbars:nobar,vesktop windowrulev2 = plugin:hyprbars:nobar, class:^(org.gnome.*)$ windowrulev2 = immediate, class:^(cs2)$ windowrulev2 = immediate, class:^(steam_proton)$ windowrulev2 = immediate, class:^(steam_app_*)$ windowrulev2 = immediate, class:^(tetrio-desktop)$ windowrulev2 = immediate, class:^(gamescope)$ windowrulev2 = immediate, class:(gamescope)$ windowrulev2 = immediate, title:^(Counter-Strike 2)$ windowrulev2 = immediate, class:^(SkyClient)(.*)$ windowrulev2 = immediate, class:(Minecraft)(.*)$ windowrulev2 = immediate, class:(Lunar Client)(.*)$ windowrulev2 = immediate, class:^(osu!)$ windowrulev2 = noblur,class:(steam)$ windowrulev2 = opacity 0.7,class:(showmethekey-gtk)$ windowrulev2 = forcergbx,class:(steam)$ windowrulev2 = suppressevent maximize, class:.* # idle inhibit for fullscreen apps windowrulev2 = idleinhibit fullscreen,class:(.+) # Vesktop on Mon 2 WS 1 windowrulev2 = monitor 1, class:^(vesktop)$ windowrulev2 = workspace 11, class:^(vesktop)$ # Srain on Mon 1 WS 5 windowrulev2 = monitor 0, class:^(srain)$ windowrulev2 = workspace 5, class:^(srain)$ layerrule = animation fade, swayosd layerrule = animation slide, notifications layerrule = animation none, selection # layerrule = animation none, gtk-layer-shell workspace = 1, monitor:DP-3, persistent:true workspace = 2, monitor:DP-3, persistent:true workspace = 3, monitor:DP-3, persistent:true workspace = 4, monitor:DP-3, persistent:true workspace = 5, monitor:DP-3, persistent:true workspace = 11, monitor:HDMI-A-1, persistent:true workspace = 12, monitor:HDMI-A-1, persistent:true workspace = 13, monitor:HDMI-A-1, persistent:true workspace = 14, monitor:HDMI-A-1, persistent:true workspace = 15, monitor:HDMI-A-1, persistent:true ======Config-End======== ```

Description

Hyprland seems to leak memory during any form of screencapture. Specifically RAM, not VRAM. The memory usage of the Hyprland process balloons infinitely. I can also repro this on the default config. The only thing that seems to impact the leak at all is monitor refresh rate: the leak is slower on 60hz and faster on 144hz.

An example of the leak over the course of a few minutes of screencapture in OBS while leaving the system completely idle:

#!/bin/bash
while true; do
    sleep 30
    ps -p $(pidof Hyprland) --no-headers --format "etime %mem vsz rss comm"
done

      04:57  0.8 3640564 267656 Hyprland
      05:27  0.8 3643072 270088 Hyprland
      05:57  0.8 3645700 272648 Hyprland
      06:27  0.8 3648208 274940 Hyprland
      06:57  0.8 3650584 277364 Hyprland
      07:27  0.8 3652960 279924 Hyprland
      07:57  0.8 3655468 282348 Hyprland
      08:27  0.8 3657844 284752 Hyprland
      08:57  0.8 3660352 287044 Hyprland
      09:27  0.8 3663804 289972 Hyprland
      09:57  0.8 3665652 291892 Hyprland
      10:27  0.8 3668028 294580 Hyprland
      10:57  0.9 3670536 296872 Hyprland
      11:27  0.9 3672912 299432 Hyprland
      11:57  0.9 3675420 301724 Hyprland

Process memory steadily increases. After a few hours, it can reach above a gig. Other than on -git, this is also present on 0.43 and 0.42. Logs do not show anything of interest. Also, this is on AMD.

How to reproduce

  1. Start Hyprland
  2. Start a screen capture, for example in OBS
  3. Observe the memory of the Hyprland process increase continuously

Crash reports, logs, images, videos

No response

vaxerski commented 1 month ago

can you bisect this

cuddleplush commented 1 month ago

Didn't bisect yet, but I've found the cause - having VFR disabled. With misc:vfr enabled, the leak is gone as far as I can tell

Pegoku commented 1 month ago

This also happens to me ~when screensharing on discord~, didn't find any cause. Arch, hyprland-git

Pegoku commented 1 month ago

image it uses +10GB, sometimes it goes over 13GB

vaxerski commented 1 month ago

great, can you bisect this

cuddleplush commented 1 month ago

can you bisect this

@vaxerski this is the first bad commit ec672b1ab95e341a0dcb6679592ae4e5eea9b1cf

vaxerski commented 1 month ago

@ikalco regressor moment

ikalco commented 1 month ago

@ikalco regressor moment

i remember fixing a similar issue when I wrote it its probably related to the wp or sp of the individual frames not getting deleted

vaxerski commented 1 month ago

you wanna debug it or do I have to do it

ikalco commented 1 month ago

you wanna debug it or do I have to do it

it'll be a few days before i get the time for it so you can if you want to get it done fast

vaxerski commented 1 month ago

I'm working on other things, so no hurries

cuddleplush commented 4 weeks ago

@vaxerski @ikalco Any update on this? Still present as of 0.44.0

vaxerski commented 4 weeks ago

I don't have it so debugging might be tricky but ikalco said he can work on it

ikalco commented 4 weeks ago

@cuddleplush try this patch.txt

cuddleplush commented 4 weeks ago

@cuddleplush try this patch.txt

Thanks! So far looks very promising, after 3 - 4 hours of screencapture I'm not seeing the leak, but I'll test more just in case