esjeon / krohnkite

A dynamic tiling extension for KWin
MIT License
1.68k stars 70 forks source link

Windows freeze on startup #16

Closed kayg04 closed 5 years ago

kayg04 commented 5 years ago

Hello!

I've been using Krohnkite for a few days and while the functionality is good, the windows freeze / go unresponsive in the following cases:

I do have the jiggle option set but it takes multiple to-and-fro(s) for the window to unfreeze.

esjeon commented 5 years ago

Can you tell me what applications you were using? Some applications do have problems with tiling scripts in general. (e.g. emacs, xterm)

kayg04 commented 5 years ago

Konsole, Dolphin, Waterfox, Spotify and Telegram are the only 5 applications I almost always use. All of the misbehave in some way or the other.

Konsole would freeze on startup before displaying the prompt. When I open another instance, the previous one is resumed and the current one is frozen. Changing focus to the frozen instance unfreezes it sometimes.

Opening Dolphin would result in a frozen state where it wouldn't display any folders unless I trigger a refresh either by changing layout or switching workspaces. The same freeze happens when I try to open a folder, any folder.

Waterfox Spotify and Telegram also freeze erratically. While I'm typing this, waterfox has frozen two times without changing focus (i.e. without moving the cursor). Telegram freezes after I unlock it with the local PIN code and sometimes freezes while I'm typing.

None of the above behaviour is seen when I disable the script.

esjeon commented 5 years ago

Hmm, the only thing that crosses my mind is that there can be more than one instances of Krohnkite running. KWin currently cannot clear up all event listeners upon disabling scripts, which results in race condition b/w instances. This, by 100% chance, freezes every window within a few second.

Would you try again after restarting KWin? Re-login or kwin_x11 --replace on a terminal should work.

esjeon commented 5 years ago

Commit 5caa4e0 will disconnect all signals when the script is disabled.

kayg04 commented 5 years ago

Tried replacing, logging out and in and restarting. Uninstalled and reinstalled the script with the latest commit. However, the same behaviour persists. Should I make a gif showcasing what I mean?

esjeon commented 5 years ago

Hmmmm, that's quite strange. I think GIF isn't necessary yet, since freezing does happen in other cases too.

Would you let me know the following information:

  1. Distro
  2. KWin version (kwin_x11 --version)
  3. List of installed KWin scripts (a full screenshot of KWin Scripts dialog would suffice)

FYI, I'm developing/using this script on Arch, and test it on KDE Neon (based on Ubuntu 18.04 LTS).

kayg04 commented 5 years ago

1 & 2: screenshot_20181217_134831

3: screenshot_20181217_134756

esjeon commented 5 years ago

Up-to-date Arch, KWin 5.14.4, w/ Kvantum. I think your setup is overall the same as mine. It can be a hardware-specific (upstream) issue, or I can't think of any other places to look into.

I attached a debug-enabled version of the master branch. Would you try again with it?

To see the debug message, you have to restart KWin in a terminal (kwin_x11 --replace 2>&1 | tee -a ~/kwin.log). With an output dump, maybe I can figure out what's going on.

krohnkite-0.2.kwinscript.zip

kayg04 commented 5 years ago

kwin.log Here is the log. I forgot to mention that sometimes Waterfox and KDE System Settings window go into this deep freeze mode where it takes multiple refreshes (minimizing-maximizing, changing workspaces) to unfreeze them. Hope the log is helpful.

EDIT: Also, another thing that has changed with the latest commit is that Konsole now opens unfrozen, i.e shell prompt appears without any kind of refresh. Although subsequent windows (which are tiled) are frozen.

esjeon commented 5 years ago

Ah, okay. Now I see. There's a race condition where multiple invocations of re-arrangement collide with each other. I think this is the source of the problem.

One thing to note is that KWin script runs multiple jobs concurrently, unlike single-threaded Javascript. Active jobs often preempted by newer jobs, and, in this case, current re-arrangement job is preempted by new request for re-arrangement. What makes it worse is that these jobs preempt each other and resizing operation gets completely interleaved. The end result is completely unpredictable.

Simple flagging can prevent the race condition itself, but it can cause some timing issues like missing rearrangement requests.

esjeon commented 5 years ago

I've just pushed a quick fix(b5cc33e) to master. I hope this solves your problem.

kayg04 commented 5 years ago

make uninstall && reboot make install && reboot

No difference. :(

Here's another debug log kwin.log.

esjeon commented 5 years ago

'kay, sorry for bailing out for a while. I've been working on this issue behind the scene.

Commit 75e4151 unfreezes some applications that resizes themselves, like Firefox (and its variants) and many (or most) KDE applications that remembers last window position. I seriously hope this does fix this, even partially, or I'm gonna ragequit. lol

kayg04 commented 5 years ago

Hey, man, amazing work. No, really. Amazing work!

Although I'm testing on a different machine right now (used to have KDE on my laptop, now on PC), I experience no freezing whatsoever. Thank you and Merry Christmas!