Skip to content

Commit 3991da0

Browse files
trop[bot]termyanen
andauthored
fix: append --disable-gpu switch in app.disableHardwareAcceleration() (#52368)
Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Roman Termyanen <[email protected]>
1 parent 68cf8b7 commit 3991da0

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

‎shell/browser/api/electron_api_app.cc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "content/public/browser/gpu_data_manager.h"
4040
#include "content/public/browser/network_service_instance.h"
4141
#include "content/public/browser/render_frame_host.h"
42+
#include "content/public/common/content_switches.h"
4243
#include "crypto/crypto_buildflags.h"
4344
#include "electron/mas.h"
4445
#include "media/audio/audio_manager.h"
@@ -1147,6 +1148,14 @@ void App::DisableHardwareAcceleration(gin_helper::ErrorThrower thrower) {
11471148
return;
11481149
}
11491150

1151+
// Append --disable-gpu to the command line so that all Chromium subsystems
1152+
// that check the switch (e.g. GpuProcessHost, viz compositor) respect the
1153+
// decision. The switch must be set before GpuDataManager is initialised
1154+
// because InitializeGpuModes() reads it to decide which GPU modes to add.
1155+
auto* command_line = base::CommandLine::ForCurrentProcess();
1156+
if (!command_line->HasSwitch(::switches::kDisableGpu))
1157+
command_line->AppendSwitch(::switches::kDisableGpu);
1158+
11501159
// If the GpuDataManager is already initialized, disable hardware
11511160
// acceleration immediately. Otherwise, set a flag to disable it in
11521161
// OnPreCreateThreads().

0 commit comments

Comments
 (0)