xmonad/xmonad

Xmonad slowdown with newest chromium

Closed this issue · 4 comments

Problem Description

On a Debian unstable system, I've got xmonad 0.17.2-1+b1 and chromium 121.0.6167.139-1~deb12u1. This works. However once I upgrade chromium to 122.0.6261.111-1 and start chromium, xmonad will use much cpu and become very slow to respond. My only way out is to kill -9 chromium quickly and to reload xmonad.

Steps to Reproduce

Stop chromium, upgrade as described above, restart chromium.

Configuration File

Ok:

import qualified Data.Map as Map

import XMonad
import XMonad.StackSet hiding (workspaces)
import qualified XMonad.StackSet as W

import XMonad.Actions.FloatKeys
import XMonad.Actions.NoBorders
import XMonad.Actions.Warp
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook
import XMonad.Layout.IndependentScreens (countScreens)
import XMonad.Layout.NoBorders
-- import XMonad.Layout.SimpleFloat
import XMonad.Layout.SimplestFloat
import XMonad.Layout.WindowArranger
import XMonad.Util.Cursor
import XMonad.Util.EZConfig(additionalKeys)
import XMonad.Util.Run(spawnPipe)

import System.IO

myFullFloat = doFullFloat

myManagehook orig =
    idHook
    <+> manageDocks
    <+> composeAll
        [ appName =? "Places" --> doFloat
        , className =? "MPlayer" <||> appName =? "MPlayer" --> doFloat
        , className =? "mplayer2" <||> appName =? "mplayer2" --> doFloat
        , isFullscreen --> myFullFloat
        , className =? "Gitk" --> myFullFloat
        , className =? "Git-gui" --> doFloat
        ]
    <+> orig

myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
    "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
    "21", "22"]

myMods config = [ mod3Mask ]

warpTo x y = do
    root <- asks theRoot
    withDisplay $ \d -> io $ warpPointer d none root 0 0 0 0 0 0

myKeys' orig config@XConfig{ modMask = mod } =
    Map.unions
        [ Map.fromList
            ([ ((mod, xK_f), withFocused (\w -> windows (W.float w (RationalRect 0 0 1 1))))
            , ((mod .|. shiftMask, xK_v), withFocused (keysMoveWindow (-1, -1)))
            , ((mod, xK_g ), withFocused toggleBorder)
            , ((mod .|. shiftMask, xK_d), sendMessage $ ToggleStrut D)
            , ((mod .|. shiftMask, xK_u), sendMessage $ ToggleStrut U)
            , ((mod, xK_b), banish LowerRight)
            , ((mod .|. shiftMask, xK_b), banishScreen LowerRight)
            -- , ((mod .|. shiftMask .|. controlMask, xK_b), banishScreen UpperLeft)
            , ((mod .|. shiftMask .|. controlMask, xK_b), warpTo 0 0)
            --
            , ((0, xK_Pause), spawn "xscreensaver-command -lock")
            , ((mod .|. controlMask .|. shiftMask, xK_l), spawn "xscreensaver-command -lock")
            -- , ((0, xK_XF86Calculator), spawn "xscreensaver-command -lock")
            --
            , ((mod .|. shiftMask, xK_m), spawn "xterm -e alsamixer")
            -- XXX workaround dmenu vs. ibus bug
            , ((mod, xK_p), spawn "dmenu_run_workaround")

            -- WindowArranger stuff for floating layout
            , ((mod .|. controlMask              , xK_s    ), sendMessage  Arrange         )
            , ((mod .|. controlMask .|. shiftMask, xK_s    ), sendMessage  DeArrange       )
            , ((mod .|. controlMask              , xK_Left ), sendMessage (MoveLeft      1))
            , ((mod .|. controlMask              , xK_Right), sendMessage (MoveRight     1))
            , ((mod .|. controlMask              , xK_Down ), sendMessage (MoveDown      1))
            , ((mod .|. controlMask              , xK_Up   ), sendMessage (MoveUp        1))
            , ((mod                 .|. shiftMask, xK_Left ), sendMessage (IncreaseLeft  1))
            , ((mod                 .|. shiftMask, xK_Right), sendMessage (IncreaseRight 1))
            , ((mod                 .|. shiftMask, xK_Down ), sendMessage (IncreaseDown  1))
            , ((mod                 .|. shiftMask, xK_Up   ), sendMessage (IncreaseUp    1))
            , ((mod .|. controlMask .|. shiftMask, xK_Left ), sendMessage (DecreaseLeft  1))
            , ((mod .|. controlMask .|. shiftMask, xK_Right), sendMessage (DecreaseRight 1))
            , ((mod .|. controlMask .|. shiftMask, xK_Down ), sendMessage (DecreaseDown  1))
            , ((mod .|. controlMask .|. shiftMask, xK_Up   ), sendMessage (DecreaseUp    1))
            -- end WindowArranger stuff.
            ]
            ++  zip
                [ (mod, k) | k <- [ xK_1 .. xK_9 ] ++ [xK_0] ++ [xK_F1 .. xK_F12] ]
                [ windows (greedyView w) | w <- myWorkspaces]
            ++ zip
                [ (mod .|. shiftMask , k) |
                    k <- [ xK_1 .. xK_9 ] ++ [xK_0] ++ [xK_F1 .. xK_F12] ]
                [ windows (shift w) | w <- myWorkspaces]
            ++ zip
                [ (mod .|. controlMask , k) |
                    k <- [ xK_1 .. xK_9 ] ++ [xK_0] ++ [xK_F1 .. xK_F12] ]
                [ windows (view w) | w <- myWorkspaces])
        , Map.fromList [ ((m .|. controlMask, k), v) | (mapping@((m, k), v)) <- Map.toList $ orig config, isQuit mapping]
        , Map.fromList [ mapping | mapping <- Map.toList $ orig config, not $ isQuit mapping ]
        ]
    where
        isQuit ((m, k), _) = (m == mod .|. shiftMask) && (k == xK_q)

myKeys orig config =
    Map.unions
        [ myKeys' orig (config { modMask = mod }) | mod <- myMods config ]

myMouseBindings' orig config = orig config

myMouseBindings orig config =
    Map.unions
        [ myMouseBindings' orig (config { modMask = mod}) | mod <- myMods config ]

tall = Tall 1 (8/1280) (1/2)

myLayoutHook orig = avoidStrutsOn [U] (tall ||| Mirror tall ||| noBorders Full
    ||| simplestFloat)

myConfig def = def
    { terminal = "xterm"
    , workspaces = myWorkspaces
    , manageHook = myManagehook (manageHook def)
    , layoutHook = myLayoutHook (layoutHook def)
    , keys = myKeys (keys def)
    , mouseBindings = myMouseBindings (mouseBindings def)
    }

main = do
    xmonad $ withUrgencyHook NoUrgencyHook $ docks $ myConfig def

Not ok:

import qualified Data.Map as Map

import XMonad
import XMonad.StackSet hiding (workspaces)
import qualified XMonad.StackSet as W

import XMonad.Actions.FloatKeys
import XMonad.Actions.NoBorders
import XMonad.Actions.Warp
import XMonad.Hooks.DynamicLog
import XMonad.Hooks.ManageDocks
import XMonad.Hooks.ManageHelpers
import XMonad.Hooks.SetWMName
import XMonad.Hooks.UrgencyHook
import XMonad.Layout.IndependentScreens (countScreens)
import XMonad.Layout.NoBorders
-- import XMonad.Layout.SimpleFloat
import XMonad.Layout.SimplestFloat
import XMonad.Layout.WindowArranger
import XMonad.Util.Cursor
import XMonad.Util.EZConfig(additionalKeys)
import XMonad.Util.Run(spawnPipe)

import System.IO

myFullFloat = doFullFloat

myManagehook orig =
    idHook
    <+> manageDocks
    <+> composeAll
        [ appName =? "Places" --> doFloat
        , className =? "MPlayer" <||> appName =? "MPlayer" --> doFloat
        , className =? "mplayer2" <||> appName =? "mplayer2" --> doFloat
        , isFullscreen --> myFullFloat
        , className =? "Gitk" --> myFullFloat
        , className =? "Git-gui" --> doFloat
        ]
    <+> orig

myWorkspaces = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10",
    "11", "12", "13", "14", "15", "16", "17", "18", "19", "20",
    "21", "22"]

myMods config = [ mod3Mask ]

warpTo x y = do
    root <- asks theRoot
    withDisplay $ \d -> io $ warpPointer d none root 0 0 0 0 0 0

myKeys' orig config@XConfig{ modMask = mod } =
    Map.unions
        [ Map.fromList
            ([ ((mod, xK_f), withFocused (\w -> windows (W.float w (RationalRect 0 0 1 1))))
            , ((mod .|. shiftMask, xK_v), withFocused (keysMoveWindow (-1, -1)))
            , ((mod, xK_g ), withFocused toggleBorder)
            , ((mod .|. shiftMask, xK_d), sendMessage $ ToggleStrut D)
            , ((mod .|. shiftMask, xK_u), sendMessage $ ToggleStrut U)
            , ((mod, xK_b), banish LowerRight)
            , ((mod .|. shiftMask, xK_b), banishScreen LowerRight)
            -- , ((mod .|. shiftMask .|. controlMask, xK_b), banishScreen UpperLeft)
            , ((mod .|. shiftMask .|. controlMask, xK_b), warpTo 0 0)
            --
            , ((0, xK_Pause), spawn "xscreensaver-command -lock")
            , ((mod .|. controlMask .|. shiftMask, xK_l), spawn "xscreensaver-command -lock")
            -- , ((0, xK_XF86Calculator), spawn "xscreensaver-command -lock")
            --
            , ((mod .|. shiftMask, xK_m), spawn "xterm -e alsamixer")
            -- XXX workaround dmenu vs. ibus bug
            , ((mod, xK_p), spawn "dmenu_run_workaround")

            -- WindowArranger stuff for floating layout
            , ((mod .|. controlMask              , xK_s    ), sendMessage  Arrange         )
            , ((mod .|. controlMask .|. shiftMask, xK_s    ), sendMessage  DeArrange       )
            , ((mod .|. controlMask              , xK_Left ), sendMessage (MoveLeft      1))
            , ((mod .|. controlMask              , xK_Right), sendMessage (MoveRight     1))
            , ((mod .|. controlMask              , xK_Down ), sendMessage (MoveDown      1))
            , ((mod .|. controlMask              , xK_Up   ), sendMessage (MoveUp        1))
            , ((mod                 .|. shiftMask, xK_Left ), sendMessage (IncreaseLeft  1))
            , ((mod                 .|. shiftMask, xK_Right), sendMessage (IncreaseRight 1))
            , ((mod                 .|. shiftMask, xK_Down ), sendMessage (IncreaseDown  1))
            , ((mod                 .|. shiftMask, xK_Up   ), sendMessage (IncreaseUp    1))
            , ((mod .|. controlMask .|. shiftMask, xK_Left ), sendMessage (DecreaseLeft  1))
            , ((mod .|. controlMask .|. shiftMask, xK_Right), sendMessage (DecreaseRight 1))
            , ((mod .|. controlMask .|. shiftMask, xK_Down ), sendMessage (DecreaseDown  1))
            , ((mod .|. controlMask .|. shiftMask, xK_Up   ), sendMessage (DecreaseUp    1))
            -- end WindowArranger stuff.
            ]
            ++  zip
                [ (mod, k) | k <- [ xK_1 .. xK_9 ] ++ [xK_0] ++ [xK_F1 .. xK_F12] ]
                [ windows (greedyView w) | w <- myWorkspaces]
            ++ zip
                [ (mod .|. shiftMask , k) |
                    k <- [ xK_1 .. xK_9 ] ++ [xK_0] ++ [xK_F1 .. xK_F12] ]
                [ windows (shift w) | w <- myWorkspaces]
            ++ zip
                [ (mod .|. controlMask , k) |
                    k <- [ xK_1 .. xK_9 ] ++ [xK_0] ++ [xK_F1 .. xK_F12] ]
                [ windows (view w) | w <- myWorkspaces])
        , Map.fromList [ ((m .|. controlMask, k), v) | (mapping@((m, k), v)) <- Map.toList $ orig config, isQuit mapping]
        , Map.fromList [ mapping | mapping <- Map.toList $ orig config, not $ isQuit mapping ]
        ]
    where
        isQuit ((m, k), _) = (m == mod .|. shiftMask) && (k == xK_q)

myKeys orig config =
    Map.unions
        [ myKeys' orig (config { modMask = mod }) | mod <- myMods config ]

myMouseBindings' orig config = orig config

myMouseBindings orig config =
    Map.unions
        [ myMouseBindings' orig (config { modMask = mod}) | mod <- myMods config ]

tall = Tall 1 (8/1280) (1/2)

myLayoutHook orig = avoidStrutsOn [U] (tall ||| Mirror tall ||| noBorders Full
    ||| simplestFloat)

xmobarCommand (S s) = unwords ["/home/hannah/bin/xmobar-launch", "-x", show s, "/home/hannah/.xmobar.config"]
xmobarSpawn s = spawnPipe (xmobarCommand s)
xmobarLog xmobarPipe =
    dynamicLogWithPP xmobarPP
        { ppOutput = hPutStrLn xmobarPipe
        -- , ppTitle = xmobarColor "green" "" . shorten 115
        , ppTitle = xmobarColor "green" "" . shorten 105
        , ppUrgent = xmobarColor "red" "yellow"
        }

myLogHook orig xmobarPipes = do
    mapM_ xmobarLog xmobarPipes
    {-
    dynamicLogWithPP xmobarPP
        { ppOutput = hPutStrLn xmobarPipe
        , ppTitle = xmobarColor "green" "" . shorten 115
        } -}
    setWMName "LG3D"
    orig

myConfig def xmobarPipes = def
    { terminal = "xterm"
    , workspaces = myWorkspaces
    , manageHook = myManagehook (manageHook def)
    , layoutHook = myLayoutHook (layoutHook def)
    , keys = myKeys (keys def)
    , mouseBindings = myMouseBindings (mouseBindings def)
    , logHook = myLogHook (logHook def) xmobarPipes
    }

main = do
    -- xmobarPipe <- spawnPipe "xmobar /home/hannah/.xmobar.config"
    -- xmobarPipe <- spawnPipe "/home/hannah/bin/xmobar-launch /home/hannah/.xmobar.config"
    nScreens <- countScreens
    xmobarPipes <- mapM xmobarSpawn [0 .. (nScreens - 1)]
    -- xmonad $ withUrgencyHook NoUrgencyHook $ myConfig defaultConfig xmobarPipes
    xmonad $ withUrgencyHook NoUrgencyHook $ docks $ myConfig def xmobarPipes

This diff made the difference:

--- xmonad.hs.works     2024-03-07 13:55:30.779460177 +0100
+++ xmonad.hs.doesnt-work       2024-03-07 13:55:43.003617175 +0100
@@ -118,14 +118,40 @@
 myLayoutHook orig = avoidStrutsOn [U] (tall ||| Mirror tall ||| noBorders Full
     ||| simplestFloat)
 
-myConfig def = def
+xmobarCommand (S s) = unwords ["/home/hannah/bin/xmobar-launch", "-x", show s, "/home/hannah/.xmobar.config"]
+xmobarSpawn s = spawnPipe (xmobarCommand s)
+xmobarLog xmobarPipe =
+    dynamicLogWithPP xmobarPP
+        { ppOutput = hPutStrLn xmobarPipe
+        -- , ppTitle = xmobarColor "green" "" . shorten 115
+        , ppTitle = xmobarColor "green" "" . shorten 105
+        , ppUrgent = xmobarColor "red" "yellow"
+        }
+
+myLogHook orig xmobarPipes = do
+    mapM_ xmobarLog xmobarPipes
+    {-
+    dynamicLogWithPP xmobarPP
+        { ppOutput = hPutStrLn xmobarPipe
+        , ppTitle = xmobarColor "green" "" . shorten 115
+        } -}
+    setWMName "LG3D"
+    orig
+
+myConfig def xmobarPipes = def
     { terminal = "xterm"
     , workspaces = myWorkspaces
     , manageHook = myManagehook (manageHook def)
     , layoutHook = myLayoutHook (layoutHook def)
     , keys = myKeys (keys def)
     , mouseBindings = myMouseBindings (mouseBindings def)
+    , logHook = myLogHook (logHook def) xmobarPipes
     }
 
 main = do
-    xmonad $ withUrgencyHook NoUrgencyHook $ docks $ myConfig def
+    -- xmobarPipe <- spawnPipe "xmobar /home/hannah/.xmobar.config"
+    -- xmobarPipe <- spawnPipe "/home/hannah/bin/xmobar-launch /home/hannah/.xmobar.config"
+    nScreens <- countScreens
+    xmobarPipes <- mapM xmobarSpawn [0 .. (nScreens - 1)]
+    -- xmonad $ withUrgencyHook NoUrgencyHook $ myConfig defaultConfig xmobarPipes
+    xmonad $ withUrgencyHook NoUrgencyHook $ docks $ myConfig def xmobarPipes

Checklist

  • I've read CONTRIBUTING.md

  • I tested my configuration

    • With xmonad version 0.17.2-1+b1 (Debian unstable)
    • With xmonad-contrib version 0.17.1-2+b1 (Debian unstable)

I tested again: Apparently taking out the line + setWMName "LG3D" makes a difference. Apparently this was a workaround needed for some Java GUI programs. However I don't have any such programs anymore so I could test if they work now without this workaround.

So, perhaps either this issue can be seen as solved with this finding, or this could point to some documentation need, or even to the need of some robustness.

Thank you all for the great work in xmonad in any case!

I was wondering why that line was in the logHook; it is normally placed in the startupHook. Running it on every update does seem like it could disturb clients.

Thanks. I don't even remember why I put the line into logHook rather than startupHook. Apparently nowadays things work without setWMName, anyway (tested right now with intellij).

blaa commented

For the record: I had the same problem. My initial fix (removing chromium from system) worked until Signal/Riot updated to new Chromium and started to trigger the same behaviour. Thanks for hint. ;)