Merge pull request #4678 from Tyriar/vscode189753

Workaround crash that can happen in Electron/Chromium
This commit is contained in:
Daniel Imms
2023-08-15 07:01:28 -07:00
committed by GitHub
2 changed files with 10 additions and 4 deletions
+9 -4
View File
@@ -3,6 +3,8 @@
* @license MIT
*/
import { isElectron } from 'common/Platform';
export interface IStyleSheet {
dispose: () => void;
setCss: (value: string) => void;
@@ -37,9 +39,12 @@ const createStyleElement = (parent: HTMLElement): IStyleSheet => {
};
export const createStyle = (parent: HTMLElement): IStyleSheet => {
try {
return createCssStyleSheet(parent.ownerDocument);
} catch {
return createStyleElement(parent);
// The combination of the CSP workaround and the DOM renderer can trigger a crash in electron
// https://github.com/microsoft/vscode/issues/189753
if (!isElectron) {
try {
return createCssStyleSheet(parent.ownerDocument);
} catch { /* Fall through */ }
}
return createStyleElement(parent);
};
+1
View File
@@ -17,6 +17,7 @@ export const isNode = (typeof navigator === 'undefined') ? true : false;
const userAgent = (isNode) ? 'node' : navigator.userAgent;
const platform = (isNode) ? 'node' : navigator.platform;
export const isElectron = userAgent.includes('Electron');
export const isFirefox = userAgent.includes('Firefox');
export const isLegacyEdge = userAgent.includes('Edge');
export const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);