electron: Globalmenu consumes 100% CPU and does not work

  • Electron version: 1.4.15
  • Operating system: Arch Linux, Linux yoga 4.7.6-1-ARCH #1 SMP PREEMPT Fri Sep 30 19:28:42 CEST 2016 x86_64 GNU/Linux.

I’m running Electron under KDE Plasma 5.9, but judging from https://github.com/atom/atom/issues/6255 and https://github.com/atom/atom/issues/5970, it could be also reproduced with other versions. This also affects Atom for obvious reasons 😉.

Expected behavior

  • Global menu should work (like in other programs).
  • Electron apps shouldn’t consume 100% CPU for no reason.

Actual behavior

  • Global menu is visible, but pressing any action does nothing.
  • Electron apps consume 100% CPU.

Workaround

Use ELECTRON_FORCE_WINDOW_MENU_BAR=1 (disables globalmenu integration).

How to reproduce

  • Install Plasma 5.9 (for other options see linked issues above).
  • Run electron under Plasma 5.9 with an enabled global menu (I’m using the menu button in the window titlebar option).
  • Observe CPU usage, e.g. with htop.
  • Try to click any entries in the globalmenu, e.g. Quit — they do nothing.

Screenshots

Without ELECTRON_FORCE_WINDOW_MENU_BAR: spectacle x22161

With ELECTRON_FORCE_WINDOW_MENU_BAR: spectacle y22161

What the menu looks like: spectacle b22161

None of the actions work, not even the File → Quit one.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 16
  • Comments: 69 (17 by maintainers)

Most upvoted comments

Is there any hope for a fix?

@andreyorst Hey, about that workaround. Try pasting this in console ELECTRON_FORCE_WINDOW_MENU_BAR=1 yourApp & It’s probably easier than opening from different user;)

Simply create a ~/.config/plasma-workspace/env/electron.sh with

export ELECTRON_FORCE_WINDOW_MENU_BAR=1

as madrzazg suggested and relogin. Yes the global menu is missing, but it works 😃

Global menu works now with electron 1.6.12 beta release !

Nobody at electron seems to care. It’s a half year now since it was discovered and nothing has changed.

This is an electron bug. Please fix it. It’s not only causing increased CPU, but it is leading plasmashell to consume up to 60% of my memory. When I tell electron to not use global menus, plasmashell stays at about 5%. It’s making slack use entirely too much memory and cpu as well, unless global menu is disabled. No other installed applications cause this problem on my machine.

Just a reminder: the workaround has been listed here from the start in the very first post of this thread 😉.

As a persistent solution, I recommend placing ELECTRON_FORCE_WINDOW_MENU_BAR=1 in ~/.pam_environment for now (if that is enabled), instead of all other desktop- or shell-dependent methods.

Have this problem on plasma 5.9.2, manjaro, too. Full cpu usage and cannot operate on all electron apps: messenger, vscode, atom.

Maybe it’s a dumb question but I’m not overly technical and I don’t work in IT.

We were talking here about the framework - sort of base behind apps. To see the result in any given electron app, this app needs to be re-created/recompiled/changed with the new version of the framework and then we need to install that version to have the fix? Right?

So the fix will vary from app to app and we may wait quite some time for it? Or am I completely wrong?

@andreyorst Most likely you still have ELECTRON_FORCE_WINDOW_MENU_BAR enabled.

electron does not check its value, it checks its presense, setting it to 0, 1, or even to an empty string disables the dbusmenu integration.

To fix that persistently:

  1. Check that the value is present: env | grep ELECTRON_FORCE_WINDOW_MENU_BAR
  2. If it’s present — remove it completely from wherever it is being set.
  3. Relogin.

To fix that only for the current termilal session:

unset ELECTRON_FORCE_WINDOW_MENU_BAR

@michaldybczak seems like it’s not specific to Plasma any more. The wire/wire-desktop#661 was also noted on i3.

I confirm, I’m on Arch and I’ve used KDE and had the bug. I’ve just switched to Gnome and there isn’t this problem.

I can reproduce it too under KDE Neon. I suggest changing the linux_distribution_specific to Linux KDE since this is not a problem of one distro only, but KDE.

What exact updates?

The updates to the menu from the application. Properties like enabled are dynamic and can be changed at any time so it would be possible for Electron to have a different menu each time about-to-show is fired.

See testcase in #8455 (comment) — even that simple testcases causes the loop here.

Yeah, I can definitely reproduce this, just trying to figure out the best fix.