Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/playwright-core/src/server/bidi/bidiChromium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { kBrowserCloseMessageId } from './bidiConnection';
import { chromiumSwitches } from '../chromium/chromiumSwitches';
import { RecentLogsCollector } from '../utils/debugLogger';
import { waitForReadyState } from '../chromium/chromium';
import { hasGpuMac } from '../utils/hostPlatform';

import type { BrowserOptions } from '../browser';
import type { SdkObject } from '../instrumentation';
Expand Down Expand Up @@ -114,7 +115,7 @@ export class BidiChromium extends BrowserType {
throw new Error('Arguments can not specify page to be opened');
const chromeArguments = [...chromiumSwitches(options.assistantMode)];

if (os.platform() === 'darwin') {
if (os.platform() !== 'darwin' || !hasGpuMac()) {
// See https://issues.chromium.org/issues/40277080
chromeArguments.push('--enable-unsafe-swiftshader');
}
Expand Down
8 changes: 5 additions & 3 deletions packages/playwright-core/src/server/chromium/chromium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import path from 'path';
import { chromiumSwitches } from './chromiumSwitches';
import { CRBrowser } from './crBrowser';
import { kBrowserCloseMessageId } from './crConnection';
import { debugMode, headersArrayToObject, headersObjectToArray, } from '../../utils';
import { debugMode, hasGpuMac, headersArrayToObject, headersObjectToArray } from '../../utils';
import { wrapInASCIIBox } from '../utils/ascii';
import { RecentLogsCollector } from '../utils/debugLogger';
import { ManualPromise } from '../../utils/isomorphic/manualPromise';
Expand Down Expand Up @@ -313,8 +313,10 @@ export class Chromium extends BrowserType {
throw new Error('Arguments can not specify page to be opened');
const chromeArguments = [...chromiumSwitches(options.assistantMode, options.channel)];

// See https://issues.chromium.org/issues/40277080
chromeArguments.push('--enable-unsafe-swiftshader');
if (os.platform() !== 'darwin' || !hasGpuMac()) {
// See https://issues.chromium.org/issues/40277080
chromeArguments.push('--enable-unsafe-swiftshader');
}

if (options.headless) {
chromeArguments.push('--headless');
Expand Down
1 change: 1 addition & 0 deletions packages/playwright-core/src/server/registry/nativeDeps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ export const deps: any = {
firefox: [
'libasound2t64',
'libatk1.0-0t64',
'libavcodec60',
'libcairo-gobject2',
'libcairo2',
'libdbus-1-3',
Expand Down
15 changes: 15 additions & 0 deletions packages/playwright-core/src/server/utils/hostPlatform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* limitations under the License.
*/

import { execSync } from 'child_process';
import os from 'os';

import { getLinuxDistributionInfoSync } from './linuxUtils';
Expand Down Expand Up @@ -133,3 +134,17 @@ function toShortPlatform(hostPlatform: HostPlatform): ShortPlatform {
}

export const shortPlatform = toShortPlatform(hostPlatform);

let hasGpuMacValue: boolean | undefined;

export function hasGpuMac() {
try {
if (hasGpuMacValue === undefined) {
const output = execSync('system_profiler SPDisplaysDataType').toString();
hasGpuMacValue = output.includes('Metal: Supported') || output.includes('Metal Support: Metal');
}
return hasGpuMacValue;
} catch (e) {
return false;
}
}
Loading