mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Add a setting to disable gpu acceleration (fixes #15211)
This commit is contained in:
parent
841d89748a
commit
b73f9ec854
|
@ -37,7 +37,8 @@
|
|||
"launch.json",
|
||||
"tasks.json",
|
||||
"keybindings.json",
|
||||
"extensions.json"
|
||||
"extensions.json",
|
||||
"argv.json"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
89
src/main.js
89
src/main.js
|
@ -12,6 +12,8 @@ const lp = require('./vs/base/node/languagePacks');
|
|||
perf.mark('main:started');
|
||||
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const os = require('os');
|
||||
const bootstrap = require('./bootstrap');
|
||||
const paths = require('./paths');
|
||||
// @ts-ignore
|
||||
|
@ -113,16 +115,97 @@ async function onReady() {
|
|||
*/
|
||||
function configureCommandlineSwitches(cliArgs) {
|
||||
|
||||
// Force pre-Chrome-60 color profile handling (for https://github.com/Microsoft/vscode/issues/51791)
|
||||
app.commandLine.appendSwitch('disable-color-correct-rendering');
|
||||
// Read argv config
|
||||
const argvConfig = readArgvConfig();
|
||||
|
||||
// Append each flag to Electron
|
||||
Object.keys(argvConfig).forEach(flag => {
|
||||
const value = argvConfig[flag];
|
||||
if (value === true || value === 'true') {
|
||||
if (flag === 'disable-gpu') {
|
||||
app.disableHardwareAcceleration(); // needs to be called explicitly
|
||||
}
|
||||
|
||||
app.commandLine.appendArgument(flag);
|
||||
} else {
|
||||
app.commandLine.appendSwitch(flag, value);
|
||||
}
|
||||
});
|
||||
|
||||
// Support JS Flags
|
||||
const jsFlags = getJSFlags(cliArgs);
|
||||
if (jsFlags) {
|
||||
app.commandLine.appendSwitch('--js-flags', jsFlags);
|
||||
app.commandLine.appendSwitch('js-flags', jsFlags);
|
||||
}
|
||||
}
|
||||
|
||||
function readArgvConfig() {
|
||||
|
||||
// Read or create the argv.json config file sync before app('ready')
|
||||
const argvConfigPath = getArgvConfigPath();
|
||||
let argvConfig;
|
||||
try {
|
||||
argvConfig = JSON.parse(stripComments(fs.readFileSync(argvConfigPath).toString()));
|
||||
} catch (error) {
|
||||
if (error && error.code === 'ENOENT') {
|
||||
try {
|
||||
const argvConfigPathDirname = path.dirname(argvConfigPath);
|
||||
if (!fs.existsSync(argvConfigPathDirname)) {
|
||||
fs.mkdirSync(argvConfigPathDirname);
|
||||
}
|
||||
|
||||
// Create initial argv.json if not existing
|
||||
fs.writeFileSync(argvConfigPath, `// This configuration file allows to pass permanent command line arguments to VSCode.
|
||||
//
|
||||
// PLEASE DO NOT CHANGE WITHOUT UNDERSTANDING THE IMPACT
|
||||
//
|
||||
// If the command line argument does not have any values, simply assign
|
||||
// it in the JSON below with a value of 'true'. Otherwise, put the value
|
||||
// directly.
|
||||
//
|
||||
// If you see rendering issues in VSCode and have a better experience
|
||||
// with software rendering, you can configure this by adding:
|
||||
//
|
||||
// 'disable-gpu': true
|
||||
//
|
||||
// NOTE: Changing this file requires a restart of VSCode.
|
||||
{
|
||||
// Enabled by default by VSCode to resolve color issues in the renderer
|
||||
// See https://github.com/Microsoft/vscode/issues/51791 for details
|
||||
"disable-color-correct-rendering": true
|
||||
}`);
|
||||
} catch (error) {
|
||||
console.error(`Unable to create argv.json configuration file in ${argvConfigPath}, falling back to defaults (${error})`);
|
||||
}
|
||||
} else {
|
||||
console.warn(`Unable to read argv.json configuration file in ${argvConfigPath}, falling back to defaults (${error})`);
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to default
|
||||
if (!argvConfig) {
|
||||
argvConfig = {
|
||||
'disable-color-correct-rendering': true // Force pre-Chrome-60 color profile handling (for https://github.com/Microsoft/vscode/issues/51791)
|
||||
};
|
||||
}
|
||||
|
||||
return argvConfig;
|
||||
}
|
||||
|
||||
function getArgvConfigPath() {
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
if (vscodePortable) {
|
||||
return path.join(vscodePortable, 'argv.json');
|
||||
}
|
||||
|
||||
let dataFolderName = product.dataFolderName;
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
dataFolderName = `${dataFolderName}-dev`;
|
||||
}
|
||||
|
||||
return path.join(os.homedir(), dataFolderName, 'argv.json');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {ParsedArgs} cliArgs
|
||||
* @returns {string}
|
||||
|
|
|
@ -116,6 +116,7 @@ export interface IEnvironmentService {
|
|||
keybindingsResource: URI;
|
||||
keyboardLayoutResource: URI;
|
||||
localeResource: URI;
|
||||
argvResource: URI;
|
||||
|
||||
// sync resources
|
||||
userDataSyncLogResource: URI;
|
||||
|
|
|
@ -95,7 +95,6 @@ export class EnvironmentService implements IEnvironmentService {
|
|||
@memoize
|
||||
get userDataPath(): string {
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
|
||||
if (vscodePortable) {
|
||||
return path.join(vscodePortable, 'user-data');
|
||||
}
|
||||
|
@ -143,6 +142,16 @@ export class EnvironmentService implements IEnvironmentService {
|
|||
@memoize
|
||||
get localeResource(): URI { return resources.joinPath(this.userRoamingDataHome, 'locale.json'); }
|
||||
|
||||
@memoize
|
||||
get argvResource(): URI {
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
if (vscodePortable) {
|
||||
return URI.file(path.join(vscodePortable, 'argv.json'));
|
||||
}
|
||||
|
||||
return URI.file(path.join(this.userHome, product.dataFolderName, 'argv.json'));
|
||||
}
|
||||
|
||||
@memoize
|
||||
get isExtensionDevelopment(): boolean { return !!this._args.extensionDevelopmentPath; }
|
||||
|
||||
|
@ -182,7 +191,6 @@ export class EnvironmentService implements IEnvironmentService {
|
|||
}
|
||||
|
||||
const vscodePortable = process.env['VSCODE_PORTABLE'];
|
||||
|
||||
if (vscodePortable) {
|
||||
return path.join(vscodePortable, 'extensions');
|
||||
}
|
||||
|
|
|
@ -7,13 +7,19 @@ import { Action } from 'vs/base/common/actions';
|
|||
import * as nls from 'vs/nls';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { ISharedProcessService } from 'vs/platform/ipc/electron-browser/sharedProcessService';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
|
||||
export class ToggleDevToolsAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.toggleDevTools';
|
||||
static readonly LABEL = nls.localize('toggleDevTools', "Toggle Developer Tools");
|
||||
|
||||
constructor(id: string, label: string, @IElectronService private readonly electronService: IElectronService) {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IElectronService private readonly electronService: IElectronService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
|
@ -27,7 +33,11 @@ export class ToggleSharedProcessAction extends Action {
|
|||
static readonly ID = 'workbench.action.toggleSharedProcess';
|
||||
static readonly LABEL = nls.localize('toggleSharedProcess', "Toggle Shared Process");
|
||||
|
||||
constructor(id: string, label: string, @ISharedProcessService private readonly sharedProcessService: ISharedProcessService) {
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@ISharedProcessService private readonly sharedProcessService: ISharedProcessService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
|
@ -35,3 +45,22 @@ export class ToggleSharedProcessAction extends Action {
|
|||
return this.sharedProcessService.toggleSharedProcessWindow();
|
||||
}
|
||||
}
|
||||
|
||||
export class ConfigureRuntimeArgumentsAction extends Action {
|
||||
|
||||
static readonly ID = 'workbench.action.configureRuntimeArguments';
|
||||
static readonly LABEL = nls.localize('configureRuntimeArguments', "Configure Runtime Arguments");
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IEnvironmentService private readonly environmentService: IEnvironmentService,
|
||||
@IEditorService private readonly editorService: IEditorService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
async run(): Promise<void> {
|
||||
await this.editorService.openEditor({ resource: this.environmentService.argvResource });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions, Configur
|
|||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
||||
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
|
||||
import { ToggleSharedProcessAction, ToggleDevToolsAction } from 'vs/workbench/electron-browser/actions/developerActions';
|
||||
import { ToggleSharedProcessAction, ToggleDevToolsAction, ConfigureRuntimeArgumentsAction } from 'vs/workbench/electron-browser/actions/developerActions';
|
||||
import { ZoomResetAction, ZoomOutAction, ZoomInAction, CloseCurrentWindowAction, SwitchWindow, QuickSwitchWindow, ReloadWindowWithExtensionsDisabledAction, NewWindowTabHandler, ShowPreviousWindowTabHandler, ShowNextWindowTabHandler, MoveWindowTabToNewWindowHandler, MergeWindowTabsHandlerHandler, ToggleWindowTabsBarHandler } from 'vs/workbench/electron-browser/actions/windowActions';
|
||||
import { SaveWorkspaceAsAction, DuplicateWorkspaceInNewWindowAction } from 'vs/workbench/electron-browser/actions/workspaceActions';
|
||||
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
@ -98,6 +98,7 @@ import { IElectronService } from 'vs/platform/electron/node/electron';
|
|||
(function registerDeveloperActions(): void {
|
||||
const developerCategory = nls.localize('developer', "Developer");
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleSharedProcessAction, ToggleSharedProcessAction.ID, ToggleSharedProcessAction.LABEL), 'Developer: Toggle Shared Process', developerCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ConfigureRuntimeArgumentsAction, ConfigureRuntimeArgumentsAction.ID, ConfigureRuntimeArgumentsAction.LABEL), 'Developer: Configure Runtime Arguments', developerCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ReloadWindowWithExtensionsDisabledAction, ReloadWindowWithExtensionsDisabledAction.ID, ReloadWindowWithExtensionsDisabledAction.LABEL), 'Developer: Reload With Extensions Disabled', developerCategory);
|
||||
registry.registerWorkbenchAction(new SyncActionDescriptor(ToggleDevToolsAction, ToggleDevToolsAction.ID, ToggleDevToolsAction.LABEL), 'Developer: Toggle Developer Tools', developerCategory);
|
||||
|
||||
|
|
|
@ -89,6 +89,7 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
|
|||
this.keybindingsResource = joinPath(this.userRoamingDataHome, 'keybindings.json');
|
||||
this.keyboardLayoutResource = joinPath(this.userRoamingDataHome, 'keyboardLayout.json');
|
||||
this.localeResource = joinPath(this.userRoamingDataHome, 'locale.json');
|
||||
this.argvResource = joinPath(this.userRoamingDataHome, 'argv.json');
|
||||
this.backupHome = joinPath(this.userRoamingDataHome, BACKUPS);
|
||||
this.configuration.backupWorkspaceResource = joinPath(this.backupHome, options.workspaceId);
|
||||
this.configuration.connectionToken = options.connectionToken || getCookieValue('vscode-tkn');
|
||||
|
@ -146,6 +147,7 @@ export class BrowserWorkbenchEnvironmentService implements IWorkbenchEnvironment
|
|||
keybindingsResource: URI;
|
||||
keyboardLayoutResource: URI;
|
||||
localeResource: URI;
|
||||
argvResource: URI;
|
||||
settingsSyncPreviewResource: URI;
|
||||
userDataSyncLogResource: URI;
|
||||
machineSettingsHome: URI;
|
||||
|
|
Loading…
Reference in a new issue