Signal-Desktop icon indicating copy to clipboard operation
Signal-Desktop copied to clipboard

high CPU usage in `signal-desktop` 7.0.0 when a chat is open

Open dkg opened this issue 1 year ago • 15 comments

Using a supported version?

  • [X] I have searched searched open and closed issues for duplicates.
  • [X] I am using Signal-Desktop as provided by the Signal team, not a 3rd-party package.

Overall summary

I was using Signal Desktop 6.47.1, and signal could sit idle without burning any significant CPU.

I upgraded to Signal Desktop 7.0.0 and as long as i have any chat open, signal consumes at least 2-3% cpu even when nothing is happening and i'm not interacting with it.

This seems like a regression back to #6544, though i don't know whether it is the same cause.

Steps to reproduce

  1. open Signal Desktop on an idle computer
  2. monitor which process has the highest CPU usage (e.g. with top)
  3. open a chat
  4. watch signal-desktop rise to the top of the list.
  5. close the chat (e.g. with ctrl-shift-c)
  6. watch signal-desktop drop down below 1% of CPU usage

Expected result

When nothing is happening and no one is interacting with Signal, it should be quiet and idle in the background and not consume any noticeable CPU.

Actual result

As long as a chat is open, it burns a noticeable fraction of a CPU.

Screenshots

No response

Signal version

7.0.0

Operating system

debian GNU/Linux (testing+unstable, debian 13 aka trixie), amd64, Linux 6.6.15

Version of Signal on your phone

6.47.5

Link to debug log

No response

dkg avatar Mar 02 '24 02:03 dkg

@dkg , thanks for the report. Some amount of CPU usage when a chat is opened -- in particular soon after opening -- is expected. Do you observe this happens more for some chats over others? Any patterns you've noticed?

trevor-signal avatar Mar 04 '24 14:03 trevor-signal

Hi @trevor-signal ! how soon is "soon after opening"? if a chat has only, say, 50 text and notification messages in its history, and i've waited a couple seconds after opening, should that be enough to stabilize CPU usage?

Below are the summary results table of pidstat -u 3 10 (from sysstat) on an otherwise idle machine, with a single instance of signal desktop the only significant process running.

all chats closed

Average:      UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command
Average:     1001       688    0.10    0.03    0.00    0.00    0.13     -  signal-desktop
Average:     1001       742    0.03    0.03    0.00    0.00    0.07     -  signal-desktop
Average:     1001       874    0.23    0.10    0.00    0.00    0.33     -  signal-desktop

group chat open, ~5 messages arriving to that chat

Average:      UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command
Average:     1001       688    1.36    0.27    0.00    0.23    1.63     -  signal-desktop
Average:     1001       742    0.57    0.17    0.00    0.00    0.73     -  signal-desktop
Average:     1001       874    7.99    0.87    0.00    0.43    8.85     -  signal-desktop
Average:     1001      1029    0.03    0.03    0.00    0.00    0.07     -  signal-desktop

group chat open, no incoming activity at all

Average:      UID       PID    %usr %system  %guest   %wait    %CPU   CPU  Command
Average:     1001       688    0.27    0.10    0.00    0.03    0.37     -  signal-desktop
Average:     1001       742    0.13    0.10    0.00    0.00    0.23     -  signal-desktop
Average:     1001       762    0.00    0.03    0.00    0.00    0.03     -  signal-desktop
Average:     1001       874    1.00    0.23    0.00    0.00    1.23     -  signal-desktop

dkg avatar Mar 05 '24 02:03 dkg

@dkg These numbers seem in the normal range to me. There are a couple background tasks that can happen when we open a group chat, including fetching updated profiles for all members, making sure we have the most up-to-date group state, sending sync messages to your other linked devices to keep read states in sync... it's possible those are responsible for much of this CPU usage.

Does the CPU usage generally drop off within ~1 minute of opening the chat?

trevor-signal avatar Mar 05 '24 14:03 trevor-signal

These measurements are all taken after waiting a minute after opening the chat in question. it is certainly possible that some remote read responses are coming in, and i wouldn't be able to tell that this is happening because it doesn't affect the UI.

in the normal range to me

Does this mean that it's to be expected that the CPU usage for no chat open is ~0.5%, but with a chat open it's ~2%? Or do you mean that there could be background activity that i'm unaware of (like read receipts coming in on other chats) and i'm just happening to capture CPU usage at alternate times? Maybe someone else can provide their measurements from comparable scenarios.

dkg avatar Mar 05 '24 18:03 dkg

confirmed using Signal Desktop v7.1.1 (snap) in xubuntu 22.04.4 LTS that's pretty annoying. we had "high cpu usage" in signal desktop a million times now in different versions. how about not doing this anymore? thank you very much.

FiSHYsolutions avatar Mar 08 '24 23:03 FiSHYsolutions

Since the last two versions of Signal-desktop on Linux, CPU usage is almost constant 100% on two cores. Is there a way to fix this?

artelse avatar Mar 19 '24 22:03 artelse

@artelse Does it change if you have a conversation open vs. not? Does it change over the course of your user session? Does the app seem responsive when this is happening? Would you be willing to give us a debug log (View -> Debug Log)?

scottnonnenberg-signal avatar Mar 19 '24 23:03 scottnonnenberg-signal

@scottnonnenberg-signal A conversation open or closed makes no difference. The app remains responsive and over the course not much changes in terms of CPU usage. What I did notice today, it that the high CPU had disappeared when my laptop came out of suspended (sleep) mode. When I than restart the app, it has high CPU again. Let it sleep/awake and it's gone again, so this is completely reproducible. Here's the debug log: https://debuglogs.org/desktop/7.2.1/f7eedc23fab755bf5bbf86d4195139aa81cf8dcda0106cd88066dd31961569ae.gz

artelse avatar Mar 20 '24 16:03 artelse

@artelse I took a look at your log, and there's nothing particularly interesting about it. And we have a lot of Signal users on various platforms that haven't reported this. Maybe you could gather some low-level metrics about Signal Desktop from your system, like what files are being accessed, and more information about exactly when CPU is high and when it's not, so we can correlate that against your log?

scottnonnenberg-signal avatar Mar 20 '24 16:03 scottnonnenberg-signal

i am now using Signal v7.2.1 (snap) in xubuntu 22.04.4 LTS

the system was hibernated and is now awaked. i have an inactive multiuser-chat in foreground (means open conversation, but nothing happens ATM), no gif's, only textmessages. this window causes a constant high cpu-usage and load. %CPU of PID 989096 toggles between 20% and 40%. the usage drops immediately below 1% when the window loses it's focus, and increases immediately over 20% if the window gets it's focus back again.

2024-03-20_18-01

i recognized this behaviour with the upgrade to v7.0 and it's not the first time this happened after an upgrade. please take note: i am not using the beta-channel of the snap-package. it's the stable-package i am talking about.

here's another debug log: https://debuglogs.org/desktop/7.2.1/1353642bd3b544753fda892dcffbddb350228aaa5033d62ca5d5bcac29108898.gz

FiSHYsolutions avatar Mar 20 '24 17:03 FiSHYsolutions

@FiSHYsolutions Thanks! Your hardware stats could be interesting as well?

scottnonnenberg-signal avatar Mar 20 '24 17:03 scottnonnenberg-signal

T470 i5-7300U ; 2x CMSX64GX4M2A2666C18 ; 1x TS240GMTS420S ; 1x CT2000MX500SSD1

FiSHYsolutions avatar Mar 20 '24 19:03 FiSHYsolutions

@artelse I took a look at your log, and there's nothing particularly interesting about it. And we have a lot of Signal users on various platforms that haven't reported this. Maybe you could gather some low-level metrics about Signal Desktop from your system, like what files are being accessed, and more information about exactly when CPU is high and when it's not, so we can correlate that against your log?

@scottnonnenberg-signal How can I help? What kind of information do you need?

artelse avatar Mar 21 '24 10:03 artelse

@artelse If you could try to figure out what Desktop is doing during that time, that would really help. Is it accessing files? Is it thrashing in the UI? Is the CPU happening in the main process or the renderer process? Is it happening in Electron code, or in our code?

scottnonnenberg-signal avatar Mar 21 '24 17:03 scottnonnenberg-signal

@scottnonnenberg-signal A few hints on how to proceed with profiling would be great. I tried operf but it errored out:

sudo operf signal-desktop --no-sandbox
operf: Profiler started
Set Windows Application User Model ID (AUMID) { AUMID: 'org.whispersystems.signal-desktop' }
NODE_ENV production
NODE_CONFIG_DIR /opt/Signal/resources/app.asar/config
NODE_CONFIG {}
ALLOW_CONFIG_MUTATIONS undefined
HOSTNAME undefined
NODE_APP_INSTANCE undefined
SUPPRESS_NO_CONFIG_WARNING undefined
SIGNAL_ENABLE_HTTP undefined
userData: /root/.config/Signal
config/start: Did not find user config file (or it was empty), cache is now empty object
config/start: Did not find ephemeral config file (or it was empty), cache is now empty object
making app single instance
Authorization required, but no authorization protocol specified
[65844:0321/200138.015213:ERROR:ozone_platform_x11.cc(244)] Missing X server or $DISPLAY
[65844:0321/200138.015273:ERROR:env.cc(257)] The platform failed to initialize.  Exiting.
profiled app exited with the following status: 1

WARNING: Lost samples detected! See /home/artelse/oprofile_data/samples/operf.log for details.
Lowering the sampling rate may reduce or eliminate lost samples.
See the '--events' option description in the operf man page for help.

Profiling done.

artelse avatar Mar 21 '24 19:03 artelse

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Jun 20 '24 07:06 stale[bot]

This issue has been closed due to inactivity.

stale[bot] avatar Jun 28 '24 00:06 stale[bot]

Seeing this on 7.7.0 on Ubuntu 24.04.

sanity avatar Jul 03 '24 18:07 sanity

A few releases ago, the issue has been resolved for me. My current version is 7.15.0.

artelse avatar Jul 03 '24 19:07 artelse

I've just seen Signal 7.16.0 hover around 10% CPU when the app is closed and I'm not even logged in on the desktop (on Windows 11). Over the past few hours, it used more battery than any other of my apps. I believe the usage should have been close to 0, I don't understand why it needs to do anything.

image

tuetschek avatar Jul 31 '24 09:07 tuetschek