Skip to content

Commit 5a53737

Browse files
committed
Removing browser detection workaround for mac now that electron has been patched/upgraded
1 parent cc1ee42 commit 5a53737

File tree

4 files changed

+1
-82
lines changed

4 files changed

+1
-82
lines changed

packages/launcher/lib/darwin/detection-workaround.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

packages/launcher/lib/darwin/util.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ import { log } from '../log'
22
import { notInstalledErr } from '../errors'
33
import { utils } from '../utils'
44
import * as fs from 'fs-extra'
5-
import * as os from 'os'
65
import * as path from 'path'
76
import * as plist from 'plist'
8-
import * as semver from 'semver'
9-
import type { FoundBrowser } from '../types'
10-
import * as findSystemNode from '@packages/server/lib/util/find_system_node'
117

128
/** parses Info.plist file from given application and returns a property */
139
export function parsePlist (p: string, property: string): Promise<string> {
@@ -105,20 +101,3 @@ export function findApp ({ appName, executable, appId, versionProperty }: FindAp
105101

106102
return tryMdFind().catch(tryFullApplicationFind)
107103
}
108-
109-
export function needsDarwinWorkaround (): boolean {
110-
return os.platform() === 'darwin' && semver.gte(os.release(), '20.0.0')
111-
}
112-
113-
export async function darwinDetectionWorkaround (): Promise<FoundBrowser[]> {
114-
const nodePath = await findSystemNode.findNodeInFullPath()
115-
let args = ['./detection-workaround.js']
116-
117-
if (process.env.CYPRESS_INTERNAL_ENV === 'development') {
118-
args = ['-r', '@packages/ts/register.js', './detection-workaround.ts']
119-
}
120-
121-
const { stdout } = await utils.execa(nodePath, args, { cwd: __dirname })
122-
123-
return JSON.parse(stdout)
124-
}

packages/launcher/lib/detect.ts

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import _, { compact, extend, find } from 'lodash'
33
import os from 'os'
44
import { browsers } from './browsers'
55
import * as darwinHelper from './darwin'
6-
import { needsDarwinWorkaround, darwinDetectionWorkaround } from './darwin/util'
76
import { notDetectedAtPathErr } from './errors'
87
import * as linuxHelper from './linux'
98
import { log } from './log'
@@ -141,44 +140,13 @@ function checkOneBrowser (browser: Browser): Promise<boolean | HasVersion> {
141140
}
142141

143142
/** returns list of detected browsers */
144-
export const detect = (goalBrowsers?: Browser[], useDarwinWorkaround = true): Bluebird<FoundBrowser[]> => {
143+
export const detect = (goalBrowsers?: Browser[]): Bluebird<FoundBrowser[]> => {
145144
// we can detect same browser under different aliases
146145
// tell them apart by the name and the version property
147146
if (!goalBrowsers) {
148147
goalBrowsers = browsers
149148
}
150149

151-
// BigSur (darwin 20.x) and Electron 12+ cause huge performance issues when
152-
// spawning child processes, which is the way we find browsers via execa.
153-
// The performance cost is multiplied by the number of binary variants of
154-
// each browser plus any fallback lookups we do.
155-
// The workaround gets around this by breaking out of the bundled Electron
156-
// Node.js and using the user's Node.js if possible. It only pays the cost
157-
// of spawning a single child process instead of multiple. If this fails,
158-
// we fall back to to the slower, default method
159-
// https://github.com/cypress-io/cypress/issues/17773
160-
if (useDarwinWorkaround && needsDarwinWorkaround()) {
161-
log('using darwin detection workaround')
162-
if (log.enabled) {
163-
// eslint-disable-next-line no-console
164-
console.time('time taken detecting browsers (darwin workaround)')
165-
}
166-
167-
return Bluebird.resolve(darwinDetectionWorkaround())
168-
.catch((err) => {
169-
log('darwin workaround failed, falling back to normal detection')
170-
log(err.stack)
171-
172-
return detect(goalBrowsers, false)
173-
})
174-
.finally(() => {
175-
if (log.enabled) {
176-
// eslint-disable-next-line no-console
177-
console.timeEnd('time taken detecting browsers (darwin workaround)')
178-
}
179-
})
180-
}
181-
182150
const removeDuplicates = (val) => {
183151
return _.uniqBy(val, (browser: FoundBrowser) => {
184152
return `${browser.name}-${browser.version}`

packages/launcher/test/unit/detect_spec.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { utils } from '../../lib/utils'
77
import sinon, { SinonStub } from 'sinon'
88
import os from 'os'
99
import { log } from '../log'
10-
import * as darwinUtil from '../../lib/darwin/util'
1110

1211
const isWindows = () => {
1312
return os.platform() === 'win32'
@@ -169,25 +168,4 @@ describe('browser detection', () => {
169168
.and.contain('Firefox newer than or equal to 86')
170169
})
171170
})
172-
173-
// https://github.com/cypress-io/cypress/issues/17773
174-
context('darwin performance workaround', () => {
175-
let browsers
176-
177-
beforeEach(() => {
178-
sinon.stub(os, 'platform').returns('darwin')
179-
sinon.stub(os, 'release').returns('20.0.0')
180-
181-
browsers = []
182-
183-
sinon.stub(darwinUtil, 'darwinDetectionWorkaround').resolves(browsers)
184-
})
185-
186-
it('uses workaround when on darwin 20.0.0+', async () => {
187-
const result = await detect()
188-
189-
expect(darwinUtil.darwinDetectionWorkaround).to.be.called
190-
expect(result).to.equal(browsers)
191-
})
192-
})
193171
})

0 commit comments

Comments
 (0)