mullvadvpn-app icon indicating copy to clipboard operation
mullvadvpn-app copied to clipboard

Automatically recover after OOM manager kills GUI

Open qirlib opened this issue 2 years ago • 3 comments

Issue report

Debian 11 Mullvad 2022.2

Issue description

Sometimes, after a memory-heavy workload, Mullvad window's contents suddenly become a white rectangle. Most likely culprit is my early oom manager, namely, earlyoom, it, as total memory usage creeps up to 90%, recognizing mullvad-gui as the biggest memory hog on the system and killing it (note that SIGKILL is sent if SIGTERM was not successful):

earlyoom[549]: sending SIGTERM to process 2241 uid 1000 "mullvad-gui": badness 874, VmRSS 64 MiB
earlyoom[549]: process exited after 0.2 seconds

Tray icon and the VPN connection itself remain functional; I just can't bring up the window and switch the connection or quit the app in a "natural" way. That happens quite often. Please add code to recognize this situation and recover gracefully from this.

qirlib avatar Jun 30 '22 08:06 qirlib

It's strange that it just becomes white and unresponsive. If the frontend receives a SIGTERM it should exit cleanly, it does for me here. Maybe you have so little memory left that it can't function properly? May I ask how much ram you have on this machine?

faern avatar Jun 30 '22 11:06 faern

6 (8 on another machine) GBs, earlyoom set up to send SIGTERM at <10% memory, SIGKILL at <5% memory; per the logs, SIGKILL hasn't been used. After mullvad window becomes a white rectangle it stays that way, even if I free up GiBs of memory. Here's an illustration of memory condititions:

Jun 29 13:22:37 earlyoom[549]: mem avail:   632 of  5899 MiB (10.72%), swap free:    0 of    0 MiB ( 0.00%)
Jun 29 13:47:16 earlyoom[549]: mem avail:   572 of  5899 MiB ( 9.70%), swap free:    0 of    0 MiB ( 0.00%)
Jun 29 13:47:16 earlyoom[549]: low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
Jun 29 13:47:16 earlyoom[549]: sending SIGTERM to process 1648 uid 1000 "qbittorrent": badness 993, VmRSS 239 M>
Jun 29 13:47:25 earlyoom[549]: process exited after 8.7 seconds
Jun 29 14:21:48 earlyoom[549]: mem avail:   547 of  5899 MiB ( 9.28%), swap free:    0 of    0 MiB ( 0.00%)
Jun 29 14:21:48 earlyoom[549]: low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
Jun 29 14:21:49 earlyoom[549]: sending SIGTERM to process 1663 uid 1000 "megasync": badness 973, VmRSS 63 MiB
Jun 29 14:21:49 earlyoom[549]: process exited after 0.1 seconds
Jun 29 14:21:49 earlyoom[549]: mem avail:   588 of  5899 MiB ( 9.97%), swap free:    0 of    0 MiB ( 0.00%)
Jun 29 14:21:49 earlyoom[549]: low memory! at or below SIGTERM limits: mem 10.00%, swap 10.00%
Jun 29 14:21:49 earlyoom[549]: sending SIGTERM to process 2241 uid 1000 "mullvad-gui": badness 874, VmRSS 64 MiB
Jun 29 14:21:49 earlyoom[549]: process exited after 0.2 seconds
Jun 29 14:22:53 earlyoom[549]: mem avail:   980 of  5899 MiB (16.61%), swap free:    0 of    0 MiB ( 0.00%)
Jun 29 15:22:59 earlyoom[549]: mem avail:  1122 of  5899 MiB (19.02%), swap free:    0 of    0 MiB ( 0.00%)

Here's also a screenshot if memory values of mullvad-gui's threads can tell you something: Mullvad1

qirlib avatar Jun 30 '22 13:06 qirlib

We have been able to reliably reproduce this internally. So, your OOM manager sends SIGTERM to the renderer process, not the Electron parent process. We gracefully handle the latter, but not when sent to the renderer process. The renderer is what takes up the most memory, so earlyoom decides to kill it, even if it's just a subprocess of a larger application.

We will look into better handling of having the renderer terminated. Thank you for reporting this.

faern avatar Jul 01 '22 11:07 faern

This should be fixed in the latest release (2022.5). We've changed the behavior of the app to not disconnect when it quits for any other reason than the user pressing "Quit". We've also made sure that the whole application will quit if the renderer process is killed.

Let me know if you're still experiencing issues and I'll reopen this issue.

raksooo avatar Nov 23 '22 10:11 raksooo