Nixpkgs: libreoffice constant high cpu usage.

Created on 23 Mar 2018  Â·  40Comments  Â·  Source: NixOS/nixpkgs

Issue description

libreoffices cpu usage is constantly on 100% (one core).

Steps to reproduce

$ libreoffice
javaldx: Could not find a Java Runtime Environment!
Warning: failed to read path from javaldx

look with a taskmanager at libreoffices cpu usage.

Technical details

libreoffice-5.4.5.1

  • system: "x86_64-linux"
  • host os: Linux 4.14.27, NixOS, 18.03pre131327.0e7c9b32817 (Impala)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 2.0
  • channels(mcd): ""
  • channels(root): "nixos-18.03pre131327.0e7c9b32817, nixos-1709-17.09.3194.edf1079d43f"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
stale

Most helpful comment

Try executing with the environment

~
SAL_USE_VCLPLUGIN=gen
~

this avoids the issue on my system. From what I recall the issue is with the current version of glib.

All 40 comments

Hm. Setting JAVA_HOME fixes the javaldx problem, but not the CPU consumption itself

Try executing with the environment

~
SAL_USE_VCLPLUGIN=gen
~

this avoids the issue on my system. From what I recall the issue is with the current version of glib.

@coreyoconnor yes, that fixes it.

Is it time to create a LibreOffice wrapper then? JAVA_HOME, SAL_USE_VCLPLUGIN, starting DBus if not already running…

I was unaware of "JAVA_HOME". Definitely for that one.

As for SAL_USE_VCLPLUGIN. That may indicate a bug in glib that effects other applications and should be patched in glib. Pulling back up the history of why I did that:

Not sure what glib is TBH. Is that "gnulib" in nixpkgs?

glib is the basic library for GTK that defines the GTK object system (GTK is written in C but it is very object-oriented), wrappers for things like input-output (I think GIO did not get separated from glib), timers, etc.

If it is unclear what breaks what, we can either take a patch from some distribution that does patch that, or start with a wrapper and then hope next GNOME release ships a better glib

Same issue here, the SAL_USE_VCLPLUGIN=gen workaround fixes it too.

Is there a preferred way to go for fixing this, between fixing glib and adding this variable to the environment through a wrapper? Or just waiting for glib / libreoffice to release a fixed version, as it's not a real blocker?

IMO, given the stance of making it work "as expected" for end users: add to a wrapper now.

I have just pushed a wrapper into master. Any testers? (No LibreOffice rebuild needed, the wrapper is a separate derivation)

Can confirm on master there doesn't seem to be the 100% CPU usage issue any longer. Thanks! :grinning:

This is indeed fixed in master; could this fix be backported to 18.03 ?

OK, picked.

The wrapper script seems to have broken something else. When I start soffice I get the following output:

mkdir: cannot create directory ‘/run/user/1000/libreoffice-dbus’: File exists
dbus[16856]: Unknown group "netdev" in message bus configuration file
dbus[16856]: Unknown username "pulse" in message bus configuration file
dbus[16856]: Unknown group "netdev" in message bus configuration file
dbus-daemon[16856]: Failed to drop supplementary groups: Operation not permitted
dbus-daemon[16856]: Failed to start message bus: Failed to set GID to 4: Operation not permitted
I18N: Operating system doesn't support locale ""
I18N: Operating system doesn't support locale "en_US"

It starts and is usable, but the theme is wrong.

libreoffice theming

Cropped. The font is wrong, and the menu colors are wrong too.

My $DBUS_SESSION_BUS_ADDRESS is set to unix:abstract=/tmp/dbus-Rc0rWjnibW,guid=e445347ae05104306f7ac08e5ac68e7f and $DBUS_SYSTEM_BUS_ADDRESS is unset. It works normally if I run it directly, without the wrapper.

Ah, so a fake system bus is not needed when session bus exists, and is even actively harmful. I think I have pushed a fix to master (only the wrapper is rebuilt) to ignore the idea of system bus completely, could you try it? It works on my no-running-DBus system.

e471376982d5c404c0d5fb376f1e48fa4b7859ba didn't solve the font problem for me.

Can confirm, the font problem is the same as of master today @ a5ae3b57314. The DBus error messages are gone though. I looked into it a little more, SAL_USE_VCLPLUGIN is for setting the windowing toolkit to get the theme from. See here. So setting it to gen means no theme, and we shouldn't be surprised the fonts are wrong.

I'm not seeing high CPU usage when running LibreOffice, regardless of if I use the wrapper or not. GLib was upgraded from 2.54.3 to 2.56.0 in 0973618e4ec61578de2eaf5531d4be661e4fa20a, which wasn't in the version of nixpkgs @castilma was using when reporting this. So it's possible the original issue is fixed now and we can drop the wrapper. I never saw the problem in the first place though.

@castilma is the CPU problem still there without the wrapper?

@enolan I would keep the wrapper because of Java (and in rare circumstances DBus) but drop SAL_USE_VCLPLUGIN if it is not needed anymore.

how do I install the unwrapped version?
I have the wrapped /nix/store/gps4y0fnlsl8lshps3zpiy976147v4ph-libreoffice-5.4.5.1/bin/libreoffice in my profile. and this file calls /nix/store/1nv742r3m75iljjpbd1mvrmzh6fj14mj-libreoffice-5.4.5.1/bin/libreoffice. invoking the second one directly still shows the problem.

Well, if this is a new enough version, that means that your system still
needs the wrapper.

You could install by using
nix-env -iA libreoffice.libreoffice
which should give you the same executable as you have launched after
inspecting the wrapper script.

It seems to me like it would be best to revert the wrapper; the cure for the high CPU usage issue seems far worse than the disease. The interface is quite unusable due to the theme issues introduced by the wrapper.

@bgamari if you use the unwrapped libreoffice.libreoffice version, does the original issue even happen for you?

@7c6f434c I can't get Writer over 1% no matter what, in Calc I can go as "high" as 5% by dragging a semi-difficult formula to the thousands, but it sits at 1% at idle as well, so nothing I would even remotely call a bug.

I also think the wrapper should be reverted as soon as possible because without installing libreoffice.libreoffice this package is unusable and it's difficult to find this issue with keywords like "no theme libreoffice" to solve the problem.

… so that means that we have two types of setups, one where LibreOffice is unusable _without_ wraper and one where it is unusable _with_ wrapper? @castilma anything you can guess about your DE etc.?

Also, @castilma could you try running LibreOffice (unwrapped) in a more or less minimal environment, maybe nix-shell --pure? Is the problem still there?

guess about my DE? well, I guess it's xfce.

libreoffice after nix-shell --pure -p libreoffice.libreoffice still has the problem.

 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.37, NixOS, 18.03.132192.ce0d9d638de (Impala)`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.0.1`
 - channels(mcd): `""`
 - channels(root): `"nixos-18.03.132192.ce0d9d638de"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs`

Heres my system configuration.
configuration.nix.gz

Well, I wondered if you could guess what else about your environment could be relevant.

Hopefully the wrapper can be adjusted to make sure it only sets the nuclear options in the case where it is needed.

(Maybe I can reproduce it in a VM…)

Doesn't seem to happen in a VM built from that configuration…

I have also observed the high CPU usage. I've not looked into it as I generally avoid using Libreoffice when possible.

However, in general I would prefer a warm lap but usable Libreoffice than a cool lap but unreadable interface. :)

What separately annoys me is that the problem seems non-trivial to reproduce…

FWIW I also had the 100% CPU problem. However now I can no longer reproduce it using either libreoffice.libreoffice or libreoffice-fresh.libreoffice.

(in the meantime, I commented out the toolkit override in the wrapper, but preserved the DBus fallback)

Is anybody still seeing this?

I'm still seeing this, on current 18.03. The SAL_USE_VCLPLUGIN workaround worked well.

I'm also still seeing this on current 18.03. However, the SAL_USE_VCLPLUGIN workaround doesn't work for me as it messes up the fonts.

Does setting SAL_USE_VCLPLUGIN to gtk or kde give you both fonts and normal CPU usage? If it doesn't help, could you try to set OOO_FORCE_DESKTOP to none but SAL_USE_VCLPLUGIN to gtk or something like that.

On my system, SAL_USE_VCLPLUGIN=kde seems to do nothing (it behaves the same as not setting SAL_USE_VCLPLUGIN).
SAL_USE_VCLPLUGIN=gtk changes to a different and usable theme, but the 100% CPU usage remains.
SAL_USE_VCLPLUGIN=gen changes to a different but unusable/ugly theme. The 100% CPU usage disappears.
OOO_FORCE_DESKTOP=none, with or without setting SAL_USE_VCLPLUGIN apparently has no effect either on the theme or on the CPU usage.

BTW, this issue is 100% reproducible for me. The 100% CPU usage begins immediately after starting libreoffice.

Hm. OK, thanks. Interesting. I still have no idea how to fix/work-around this issue…

Let's see if #68414 fixes it.

Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the
    related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on
    irc.freenode.net.

No activity in a while - please reopen if the problem persists.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ayyess picture ayyess  Â·  3Comments

rzetterberg picture rzetterberg  Â·  3Comments

sid-kap picture sid-kap  Â·  3Comments

ghost picture ghost  Â·  3Comments

teto picture teto  Â·  3Comments