hezral / clips

Multi format clipboard manager with extra features
GNU General Public License v3.0
39 stars 1 forks source link

Excessive number of processes #28

Closed Antolius closed 2 years ago

Antolius commented 2 years ago

After using the app for a while the number of spawned processes (mostly WebKitWebProces) seems excessive:

$ pstree 1668
flatpak-bwrap───flatpak-bwrap───com.github.hezr─┬─WebKitNetworkPr───232*[{WebKitNetworkPr}]
                                                ├─222*[WebKitWebProces───7*[{WebKitWebProces}]]
                                                └─229*[{com.github.hezr}]

1668 is, in my case, Clips' root pid. This causes performance problems and ultimately fills up the maximum number of xorg clients, preventing future launches of any GUI apps (including Clips itself):

$ flatpak run com.github.hezral.clips 
Maximum number of clients reachedUnable to init server: Could not connect: Connection refused
Maximum number of clients reachedUnable to init server: Could not connect: Connection refused

(com.github.hezral.clips:2): Gtk-CRITICAL **: 22:56:17.127: gtk_clipboard_get_for_display: assertion 'display != NULL' failed
Traceback (most recent call last):
  File "/app/bin/com.github.hezral.clips", line 36, in <module>
    from clips import main
  File "/app/share/com.github.hezral.clips/clips/main.py", line 28, in <module>
    from .shake_listener import ShakeListener
  File "/app/share/com.github.hezral.clips/clips/shake_listener.py", line 9, in <module>
    from pynput import mouse
  File "/app/lib/python3.8/site-packages/pynput/__init__.py", line 40, in <module>
    from . import keyboard
  File "/app/lib/python3.8/site-packages/pynput/keyboard/__init__.py", line 31, in <module>
    backend = backend(__name__)
  File "/app/lib/python3.8/site-packages/pynput/_util/__init__.py", line 76, in backend
    raise ImportError('this platform is not supported: {}'.format(
ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":99.0": b\'Maximum number of clients reached\'', DisplayConnectionError(':99.0', b'Maximum number of clients reached'))

Try one of the following resolutions:

 * Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly

Granted, I currently have a little over 1000 clips saved in the app. Most of it just snippets of text either from my local Code editor or from documentation sites online (which might contain some styling info like font color etc.). I could probably reduce the number of processes by deleting those clips, perhaps by running the housekeeping option in the Clips app itself. However, this is made a bit difficult by the fact that I can't currently launch the GUI.

This situation could probably be avoided by tweaking some of the housekeeping related settings. But it might be a good idea to put some restriction on the number of processes in the code itself, so that sloppy users such as myself don't shoot themselves in the foot with unfortunate combination of settings.

P.S. I otherwise love Clips! I can't imagine my workflow without a clipboard manager.

hezral commented 2 years ago

Hi, thanks for reporting this. This is interesting, i might need to rethink limiting the loading of the clips items. I'm guessing the 1000s of clips contains lots of html type contents?

You can for now, clean the cache manually, by moving out the files from ~/.var/app/com.github.hezral.clips/cache/com.github.hezral.clips This will remove all clips.

If you're familiar, you can also remove the clips you don't need through the sqlite database, this way you can still retain some of the clips

Can you check your settings here and disable shake-reveal if its enabled? The above output seems to show that it is.

~/.var/app/com.github.hezral.clips/config/glib-2.0/settings

[com/github/hezral/clips] first-run=false protected-mode=false persistent-mode=true quick-paste=false sticky-mode=true hide-on-startup=true shake-reveal=false min-column-number=3 theme-optin=false prefer-dark-style=false shake-sensitivity=4 excluded-apps=[] always-on-top=true show-close-button=false

hezral commented 2 years ago

Just comparing, i have 152 clips and here's my pstree output, that's half compared to yours just by the numbers. Something seems off.

flatpak-bwrap───flatpak-bwrap───com.github.hezr─┬─WebKitNetworkPr───116*[{WebKitNetworkPr}]
                                                ├─106*[WebKitWebProces───7*[{WebKitWebProces}]]
                                                └─113*[{com.github.hezr}]
hezral commented 2 years ago

Did a bit of research, it seems webkitwebview is very hungry.. i need to rethink this. i have 250+ clips now, most are html clips and it started to crawl on a 6gb ram system.

hezral commented 2 years ago

found a workaround, will be using thumbnails instead.

Antolius commented 2 years ago

Tnx for the quick followup! I've cleaned my cache and limited retention to 2 days in the meantime. With that setup my history doesn't get large enough to cause issues. But I'm happy to hear you have a more permanent solution in mind!

Eldhrimer commented 2 years ago

I came here to file this very same issue but not only I found it was already reported, but there's a fix on the works. Amazing job @hezral!

hezral commented 2 years ago

Thanks, putting some final checks, will be in 1.0.5 release to be submitted this week

hezral commented 2 years ago

Fixed with https://github.com/hezral/clips/releases/tag/1.0.5

Pending https://github.com/elementary/appcenter-reviews/pull/180 for AppCenter release