Skip to content

fix: append --disable-gpu switch in app.disableHardwareAcceleration() - #51817

Merged
jkleinsc merged 1 commit into
electron:mainfrom
termyanen:fix/disable-hw-accel-gpu-switch
Jul 16, 2026
Merged

jkleinsc merged 1 commit into
electron:mainfrom
termyanen:fix/disable-hw-accel-gpu-switch

Conversation

@termyanen

Copy link
Copy Markdown
Contributor

Description of Change

app.disableHardwareAcceleration() calls content::GpuDataManager::DisableHardwareAcceleration() but does not append --disable-gpu to the process command line. Starting with Chromium 139 (Electron 38), additional Chromium subsystems check the command line switch directly rather than querying GpuDataManager state, causing the GPU process to continue consuming GPU hardware resources.

This fix appends --disable-gpu to the command line when disableHardwareAcceleration() is called, ensuring all Chromium code paths respect the decision.

Tested on Windows: with the switch, Task Manager shows 0% GPU usage and no GPU engine activity. Without it, GPU process uses ~10.7% GPU and allocates ~375 MB GPU memory.

Fixes #51363

Checklist

Release Notes

Notes: Fixed app.disableHardwareAcceleration() not fully disabling GPU hardware usage on Windows starting from Electron 38.

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label May 31, 2026
@github-actions

Copy link
Copy Markdown
Contributor

⚠️ This PR contains unsigned commits. This repository enforces commit signatures
for all incoming PRs. To get your PR merged, please sign those commits
(git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch
(git push --force-with-lease)

For more information on signing commits, see GitHub's documentation on Telling Git about your signing key.

@github-actions github-actions Bot added the needs-signed-commits Currently some or all of the commits in this PR are not signed label May 31, 2026
@termyanen
termyanen force-pushed the fix/disable-hw-accel-gpu-switch branch 2 times, most recently from 6886fec to 8e87c5e Compare May 31, 2026 21:56
@termyanen
termyanen force-pushed the fix/disable-hw-accel-gpu-switch branch from 8e87c5e to 2501b62 Compare May 31, 2026 21:57
@github-actions github-actions Bot removed the needs-signed-commits Currently some or all of the commits in this PR are not signed label May 31, 2026
@ckerr

ckerr commented Jun 2, 2026

Copy link
Copy Markdown
Member

Starting with Chromium 139 (Electron 38), additional Chromium subsystems check the command line switch directly rather than querying GpuDataManager state, causing the GPU process to continue consuming GPU hardware resources.

@termyanen do you have link(s) for the Chromium CLs where this changed? I'd like to do some background reading on this

@termyanen

Copy link
Copy Markdown
Contributor Author

Starting with Chromium 139 (Electron 38), additional Chromium subsystems check the command line switch directly rather than querying GpuDataManager state, causing the GPU process to continue consuming GPU hardware resources.

@termyanen do you have link(s) for the Chromium CLs where this changed? I'd like to do some background reading on this

I dug into the Chromium diff between 138 and 139 and the most likely culprit is kRemoveRedirectionBitmap being flipped from DISABLED_BY_DEFAULT to ENABLED_BY_DEFAULT:

So this new path kicks in and software rendering ends up touching real GPU — that's probably why Task Manager still shows GPU usage even with acceleration disabled.

DisableHardwareAcceleration() only touches GpuDataManager state and never sets --disable-gpu on the command line, so these paths don't know acceleration is off. I haven't fully traced the whole chain though, so happy to be corrected.

@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Jun 7, 2026
@jkleinsc jkleinsc added semver/patch backwards-compatible bug fixes target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. labels Jun 18, 2026
@termyanen

Copy link
Copy Markdown
Contributor Author

Hi @ckerr, gently following up on this. Did the breakdown of the Chromium CLs above give you enough to go on. Would really appreciate it if you could take another look when you have a moment.

@github-actions github-actions Bot added the target/44-x-y PR should also be added to the "44-x-y" branch. label Jul 1, 2026
@jkleinsc
jkleinsc merged commit 5efa458 into electron:main Jul 16, 2026
137 of 139 checks passed
@welcome

welcome Bot commented Jul 16, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

@release-clerk

release-clerk Bot commented Jul 16, 2026

Copy link
Copy Markdown

Release Notes Persisted

Fixed app.disableHardwareAcceleration() not fully disabling GPU hardware usage on Windows starting from Electron 38.

@trop

trop Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "41-x-y", please check out #52368

@trop trop Bot removed the target/41-x-y PR should also be added to the "41-x-y" branch. label Jul 16, 2026
@trop

trop Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "43-x-y", please check out #52369

@trop

trop Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "44-x-y", please check out #52370

@trop trop Bot removed the target/43-x-y PR should also be added to the "43-x-y" branch. label Jul 16, 2026
@trop

trop Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "42-x-y", please check out #52371

@trop trop Bot added in-flight/44-x-y in-flight/42-x-y merged/41-x-y PR was merged to the "41-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. and removed target/44-x-y PR should also be added to the "44-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/41-x-y in-flight/43-x-y in-flight/42-x-y in-flight/44-x-y labels Jul 16, 2026
MarshallOfSound pushed a commit that referenced this pull request Sep 24, 2026
Regression test for #51817, where disableHardwareAcceleration() stopped
appending the --disable-gpu switch. A small fixture app calls it before
ready and reports whether app.commandLine has the switch once ready.

Verified against Linux release builds: fails on 45.0.0-nightly.20260716,
passes on 45.0.0-nightly.20260720.
MarshallOfSound added a commit that referenced this pull request Sep 24, 2026
* test: cover app.disableHardwareAcceleration() adding --disable-gpu

Regression test for #51817, where disableHardwareAcceleration() stopped
appending the --disable-gpu switch. A small fixture app calls it before
ready and reports whether app.commandLine has the switch once ready.

Verified against Linux release builds: fails on 45.0.0-nightly.20260716,
passes on 45.0.0-nightly.20260720.

* test: check the default menu has no Help menu

Regression test for #50629, which moved the Electron project links out of
the menu every app gets by default and into the default app. The
default-menu fixture gains a --print-items mode that prints the roles and
labels of the top-level items, and the spec asserts the window menu is
there but no Help menu is.

Verified against Linux release builds: fails on 43.0.0-nightly.20260408,
passes on 43.0.0-nightly.20260413.

* test: check an unopened Menu can be garbage collected

Regression test for #50806, where a Menu that was built but never opened
was kept alive forever. The spec drops the last reference, holds a WeakRef
and requests async GCs until it clears.

Verified against Linux release builds: fails on 43.0.0-nightly.20260408,
passes on 43.0.0-nightly.20260413.

* test: check openDevTools() ignores an unknown dock mode

Regression test for #50646, where the dock mode string was spliced into a
script evaluated in the DevTools frontend. The spec passes a mode that
would break out of the string literal and set a global, waits for the
frontend host to round-trip, and asserts the global was never set. Uses
its own session partition so the dock state it leaves behind does not leak
into other DevTools tests.

Verified against Linux release builds: fails on 43.0.0-nightly.20260402,
passes on 43.0.0-nightly.20260406.

* test: check DevTools reopens in its last dock state

Regression test for #50807, where calling openDevTools() without a mode
always docked to the right instead of restoring the previous dock state.
The spec opens DevTools undocked, closes it, reopens with no options and
reads currentDockState back from the frontend preferences.

Verified against Linux release builds: fails on 43.0.0-nightly.20260408,
passes on 43.0.0-nightly.20260413.

* test: check a running app keeps serving its original asar after replacement

Regression test for #52283. File contents used to be re-read from whatever
file was at the archive's path using offsets from the header read at
startup, so replacing app.asar under a running app (as updaters do) served
the wrong bytes or failed. A fixture app loads a file from a temporary
asar in a BrowserWindow, renames a different archive over it, loads the
same file again and reports both results; the spec expects them to match
the original archive. Skipped on Windows, which does not allow renaming
over an archive that is held open.

Verified against Linux release builds: fails on 45.0.0-nightly.20260706,
passes on 45.0.0-nightly.20260716.

* test: check zygote children get their own process title on Linux

Regression test for #50509, where processes forked from the zygote kept
the zygote's command line as their process title, so ps and friends
showed every child as --type=zygote. The spec reads /proc/<pid>/cmdline
for the GPU, renderer and utility processes reported by getAppMetrics()
and expects each to carry its own --type switch, tolerating processes
that exit in the meantime.

Verified against Linux release builds: fails on 43.0.0-nightly.20260323,
passes on 43.0.0-nightly.20260402.

* test: check losing the X server exits the app instead of crashing

Regression test for #52603, where losing the display server connection
went straight to LOG(FATAL). The spec starts a private Xvfb (skipping if
none is available), launches a fixture app on it that logs when its window
is ready, kills the X server and expects the app to exit with a normal
exit code rather than die on a signal. Either Ozone (the app.exit(0) path
the fix added) or GTK (_exit(1)) can be the first to notice the dead
connection, so both codes are accepted. The X server is started inside the
test so mocha's in-job retries get a fresh one.

Verified against Linux release builds: the app dies with SIGTRAP on
45.0.0-nightly.20260805 and exits cleanly on 45.0.0-nightly.20260808.

* test: check a fully transparent titleBarOverlay color on Linux

Regression test for #51017, where a fully transparent overlay colour was
treated as unset and replaced with the default opaque one. Adds
captureDisplayPixels()/expectDisplayPixelsEventually() screen helpers that
read the primary display back through desktopCapturer and retry a set of
assertions until the compositor catches up, then uses them to show a red
page under a transparent overlay and assert that nearly all of the overlay
strip shows the page (only the caption glyphs differ).

The page carries a marker square so the check cannot pass on an unpainted
or stale surface, and colours are compared against each other rather than
constants because CI's 16-bit Xvfb screen quantises them. X11 only:
Wayland has no portal-free capture and other platforms draw native
caption buttons. Tagged serial since it reads the real screen.

Verified against Linux release builds: fails on 44.0.0-nightly.20260529,
passes on 44.0.0-nightly.20260701.

* test: check titleBarOverlay draws its background and buttons on Linux

Regression test for #52577, where the caption button container was not
shown at all on Linux. Using the same capture helpers, the spec shows a
red page with a blue overlay and white symbols and asserts that the
overlay strip is mostly not the page colour and that a second colour (the
button glyphs) is present within it.

Verified against Linux release builds: fails on 45.0.0-nightly.20260731,
passes on 45.0.0-nightly.20260803.

* test: check transparent frameless windows draw no border on Linux

Regression test for #50541, where the frame painted an opaque border
around transparent frameless windows on Linux. The spec puts a blue
backdrop window across the work area, shows a transparent frameless
window with two marker squares over it, captures the screen and asserts
that the only colours in and just around the window bounds are the
backdrop, the see-through area and the two markers, i.e. no frame, border
or shadow pixels. X11 only, tagged serial with the rest of the
"transparent" suite.

Verified against Linux release builds: fails on 43.0.0-nightly.20260323,
passes on 43.0.0-nightly.20260402.

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

45-x-y merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

app.disableHardwareAcceleration() no longer fully disables GPU usage on Windows Task Manager in Electron v38+ (worked in v37)

4 participants