Skip to content

Commit 58bee28

Browse files
fix: force gtk version 3 to avoid Electron 36 from crashing (#32372)
* Fix: force gtk version 3 to avoid https://www.electronjs.org/blog/electron-36-0\#behavior-changed-gtk-4-is-the-default-when-running-on-gnome * Update cli/CHANGELOG.md Co-authored-by: Mike McCready <[email protected]> * add suggestions from code review * empty --------- Co-authored-by: Mike McCready <[email protected]>
1 parent d39eee3 commit 58bee28

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

.circleci/workflows.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ mainBuildFilters: &mainBuildFilters
3838
- /^release\/\d+\.\d+\.\d+$/
3939
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
4040
- 'update-v8-snapshot-cache-on-develop'
41-
- 'chore/updates_post_15'
41+
- 'fix/set_fixed_gtk_version'
4242

4343
# usually we don't build Mac app - it takes a long time
4444
# but sometimes we want to really confirm we are doing the right thing
@@ -49,7 +49,7 @@ macWorkflowFilters: &darwin-workflow-filters
4949
- equal: [ develop, << pipeline.git.branch >> ]
5050
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
5151
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
52-
- equal: [ 'chore/updates_post_15', << pipeline.git.branch >> ]
52+
- equal: [ 'fix/set_fixed_gtk_version', << pipeline.git.branch >> ]
5353
- matches:
5454
pattern: /^release\/\d+\.\d+\.\d+$/
5555
value: << pipeline.git.branch >>
@@ -60,7 +60,7 @@ linuxArm64WorkflowFilters: &linux-arm64-workflow-filters
6060
- equal: [ develop, << pipeline.git.branch >> ]
6161
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
6262
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
63-
- equal: [ 'chore/updates_post_15', << pipeline.git.branch >> ]
63+
- equal: [ 'fix/set_fixed_gtk_version', << pipeline.git.branch >> ]
6464
- matches:
6565
pattern: /^release\/\d+\.\d+\.\d+$/
6666
value: << pipeline.git.branch >>
@@ -83,7 +83,7 @@ windowsWorkflowFilters: &windows-workflow-filters
8383
- equal: [ develop, << pipeline.git.branch >> ]
8484
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
8585
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
86-
- equal: [ 'chore/updates_post_15', << pipeline.git.branch >> ]
86+
- equal: [ 'fix/set_fixed_gtk_version', << pipeline.git.branch >> ]
8787
- matches:
8888
pattern: /^release\/\d+\.\d+\.\d+$/
8989
value: << pipeline.git.branch >>
@@ -157,7 +157,7 @@ commands:
157157
name: Set environment variable to determine whether or not to persist artifacts
158158
command: |
159159
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
160-
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "chore/updates_post_15" ]]; then
160+
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "fix/set_fixed_gtk_version" ]]; then
161161
export SHOULD_PERSIST_ARTIFACTS=true
162162
fi' >> "$BASH_ENV"
163163
# You must run `setup_should_persist_artifacts` command and be using bash before running this command

cli/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ _Released 08/26/2025 (PENDING)_
1010
**Bugfixes:**
1111

1212
- Fixed an issue where OS distributions and releases were sometimes not properly populated for Module API results and Cloud recordings. Fixes [#30533](https://github.com/cypress-io/cypress/issues/30533). Addressed in [#32283](https://github.com/cypress-io/cypress/pull/32283).
13+
- Fixed an issue where Cypress would fail to run on GNOME if GTK 4 and GTK 2/3 were detected in the Electron process. Addresses [#32361](https://github.com/cypress-io/cypress/issues/32361).
1314
- Fixed an issue where the open Studio button would incorrectly show for component tests. Addressed in [#32315](https://github.com/cypress-io/cypress/pull/32315).
1415
- Fixed an issue where the TypeScript compiler wasn't being resolved correctly when `@cypress/webpack-batteries-included-preprocessor` was used as a standalone package. Fixes [#32338](https://github.com/cypress-io/cypress/issues/32338).
1516

packages/server/lib/util/chromium_flags.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,10 @@ export const formatElectronFlags = (flags) => {
113113

114114
export const DEFAULT_CHROME_FLAGS = formatChromeFlags(DEFAULT_FLAGS)
115115

116-
export const DEFAULT_ELECTRON_FLAGS = formatElectronFlags(DEFAULT_CHROME_FLAGS)
116+
export const DEFAULT_ELECTRON_FLAGS = [
117+
...formatElectronFlags(DEFAULT_CHROME_FLAGS),
118+
// NOTE: Can likely be removed with Electron upgrade to 37+.
119+
// @see https://github.com/electron/electron/issues/46538
120+
// @see https://github.com/cypress-io/cypress/issues/32361
121+
...formatElectronFlags(['--gtk-version=3']),
122+
]

packages/server/test/unit/environment_spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ describe('lib/environment', () => {
4444
return process.env['CYPRESS_INTERNAL_ENV'] = env
4545
})
4646

47+
// @see https://github.com/electron/electron/issues/46538
48+
// @see https://github.com/cypress-io/cypress/issues/32361
49+
context('sets gtk-version=3 in Electron >= 36', () => {
50+
it('sets launch args', () => {
51+
sinon.stub(app.commandLine, 'appendSwitch')
52+
require(`../../lib/environment`)
53+
expect(app.commandLine.appendSwitch).to.have.been.calledWith('--gtk-version', '3')
54+
})
55+
})
56+
4757
context('parses ELECTRON_EXTRA_LAUNCH_ARGS', () => {
4858
let restore = null
4959

0 commit comments

Comments
 (0)