Skip to content

Fix battery drain from Web Audio #29203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 29, 2025
Merged

Fix battery drain from Web Audio #29203

merged 6 commits into from
Apr 29, 2025

Conversation

mbachry
Copy link
Contributor

@mbachry mbachry commented Feb 5, 2025

Element audio notifications cause a small, but noticeable battery drain on my Linux laptop, both with Firefox and Chromium. The drain is constant and disappears only after closing Element tab or the browser. In Firefox merely launching Element starts the battery issues, in Chromium it happens after the first notification arrives.

Here's a screenshot from pw-top long after a notification happened:

pipewire

pw-cli info confirms the bogus stream is an Element tab.

Web Audio doc says: "The suspend() method of the AudioContext Interface suspends the progression of time in the audio context, temporarily halting audio hardware access and reducing CPU/battery usage in the process — this is useful if you want an application to power down the audio hardware when it will not be using an audio context for a while."

Copy link
Member

@t3chguy t3chguy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like some test stubs need updating

@mbachry
Copy link
Contributor Author

mbachry commented Feb 6, 2025

I moved the initial suspend (apparently required by Firefox) away from the constructor. This fixes the tests locally.

@CLAassistant
Copy link

CLAassistant commented Mar 21, 2025

CLA assistant check
All committers have signed the CLA.

t3chguy added 2 commits April 29, 2025 11:17
Signed-off-by: Michael Telatynski <[email protected]>
@t3chguy t3chguy added this pull request to the merge queue Apr 29, 2025
Merged via the queue into element-hq:develop with commit 02dd79f Apr 29, 2025
29 checks passed
snowping pushed a commit to Novaloop-AG/element-web that referenced this pull request Jun 22, 2025
* Fix battery drain from Web Audio

* move suspend away from constructor

* await on resume()

* Delint

Signed-off-by: Michael Telatynski <[email protected]>

---------

Signed-off-by: Michael Telatynski <[email protected]>
Co-authored-by: Michael Telatynski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-Enhancement Z-Community-PR Issue is solved by a community member's PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants