Skip to content

Commit

Permalink
Disable WebGL2 on Safari (#799)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdevaev committed Oct 23, 2021
1 parent a5f0765 commit 52adcc4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion html/src/components/terminal/index.tsx
Expand Up @@ -217,11 +217,31 @@ export class Xterm extends Component<Props> {
}
};

const isSafari = () => {
// https://stackoverflow.com/questions/9847580
if (/constructor/i.test(String(window["HTMLElement"]))) {
return true;
}
if (!window.top["safari"]) {
return false;
}
return String(window.top["safari"].pushNotification) === "[object SafariRemoteNotification]";
};

const isIos = () => {
// https://stackoverflow.com/questions/9038625
// https://github.com/lancedikson/bowser/issues/329
return !!navigator.platform && (
/iPad|iPhone|iPod/.test(navigator.platform)
|| (navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1 && !window["MSStream"])
);
};

const { terminal } = this;
switch (value) {
case 'webgl':
if (this.webglAddon) return;
if (isWebGL2Available()) {
if (isWebGL2Available() && !isSafari() && !isIos()) {
this.webglAddon = new WebglAddon();
terminal.loadAddon(this.webglAddon);
console.log(`[ttyd] WebGL renderer enabled`);
Expand Down

0 comments on commit 52adcc4

Please sign in to comment.