Tkinter/Python3 app launch slow down each time it is killed instead of closed
The bug is present in the following setup:
- Ubuntu 18.04.3 LTS (tested also on 20.04 LTS beta)
- gnome-shell package is version 3.28.4-0ubuntu18.04.2
- Linux x 4.15.0-96-generic #97 (closed)-Ubuntu SMP Wed Apr 1 03:25:46 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Tested and problem reproducible on:
- GNOME Flashback (Compiz) - default on my machine
- Ubuntu on Wayland
- GNOME on Xorg
Tested and problem is not detected on:
- Live Kubuntu 18.04 LTS on other machine
- vanilla LXDE installed in my Ubuntu 18.04.3 LTS
The problem is whenever a Tkinter/Python3 application I am working on is killed with Ctrl-C or killall python3 the subsequent launch of the application takes more time. When the window is closed with the X button no time is added to subsequent runs. When the user logs out and logs in launch time is back to the original.
I have attached a simple python script (slow.py) that demonstrates the issue. I also attached a bash script (runme) that runs the script in a loop and uses grep to print relevant time.
Steps to reproduce:
- run ./runme
- Close the window using the X symbol a number of time (e.g. 10 times)
20640 0.206 0.000 0.206 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 0.209 0.000 0.209 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 0.233 0.000 0.233 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 0.217 0.000 0.217 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 0.207 0.000 0.207 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 0.230 0.000 0.230 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 0.215 0.000 0.215 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 0.215 0.000 0.215 0.000 {method 'call' of '_tkinter.tkapp' objects}
The second column indicating time spent in all calls of the "call" method is consistent between calls.
- Kill the application, I use killall python3 run in a separate window. Do this a number of times (e.g. 10).
- Close the application with X (the first close reports wrong time, so please do this a couple of times)
20640 1.331 0.000 1.331 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 1.383 0.000 1.383 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 1.321 0.000 1.321 0.000 {method 'call' of '_tkinter.tkapp' objects}
20640 1.377 0.000 1.377 0.000 {method 'call' of '_tkinter.tkapp' objects}
Now the time spend in the "call" method is significantly higher.
- When the user logs out and in the time is back to about 0.210 until the app is killed with killall python3 or Ctrl-C
The problem is that the launch time of the app increased. The expected behavior is that there is no rise in launch time of the application. On other window managers - LXDE and KDE the problem does not manifest itself.
For the application I am working on the launch time increase is significant. Killing the application once adds about 6 seconds to the launch time.