Skip to content

Commit

Permalink
Merge pull request #4836 from xiaoxiaobt/safari-legacy-fix
Browse files Browse the repository at this point in the history
Allow xterm.js to run on legacy versions of Safari when Webgl2 support is explicitly enabled
  • Loading branch information
Tyriar committed Nov 2, 2023
2 parents c9f1545 + 0d7cc9e commit 139bf36
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion addons/addon-webgl/src/WebglAddon.ts
Expand Up @@ -11,6 +11,7 @@ import { EventEmitter, forwardEvent } from 'common/EventEmitter';
import { Disposable, toDisposable } from 'common/Lifecycle';
import { getSafariVersion, isSafari } from 'common/Platform';
import { ICoreService, IDecorationService, ILogService, IOptionsService } from 'common/services/Services';
import { IWebGL2RenderingContext } from './Types';
import { WebglRenderer } from './WebglRenderer';
import { setTraceLogger } from 'common/services/LogService';

Expand All @@ -31,7 +32,16 @@ export class WebglAddon extends Disposable implements ITerminalAddon , IWebglApi
private _preserveDrawingBuffer?: boolean
) {
if (isSafari && getSafariVersion() < 16) {
throw new Error('Webgl2 is only supported on Safari 16 and above');
// Perform an extra check to determine if Webgl2 is manually enabled in developer settings
const contextAttributes = {
antialias: false,
depth: false,
preserveDrawingBuffer: true
};
const gl = document.createElement('canvas').getContext('webgl2', contextAttributes) as IWebGL2RenderingContext;
if (!gl) {
throw new Error('Webgl2 is only supported on Safari 16 and above');
}
}
super();
}
Expand Down

0 comments on commit 139bf36

Please sign in to comment.