xterm.js icon indicating copy to clipboard operation
xterm.js copied to clipboard

Does not work in WKWebView

Open litherum opened this issue 4 years ago • 3 comments

The check in https://github.com/xtermjs/xterm.js/blob/master/src/common/Platform.ts#L21:

export const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent);

doesn't seem to catch WKWebView, which is the browser engine powering Safari. Safari's user agent string (on an iPad) is:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/15.4 Safari/605.1.15

Whereas WKWebView's user agent string (on an iPad) is:

Mozilla/5.0 (iPad; CPU OS 15_4 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148

This is causing the demo on https://xtermjs.org to not show any content in WKWebView.

litherum avatar Dec 14 '21 05:12 litherum

@litherum do you know of an easy way to test a wkwebview on a macbook?

Tyriar avatar Dec 14 '21 15:12 Tyriar

@litherum I have applied a quick workaround on my own SSH app (now using Xterm.js).

A simple fix could be : wkWebView.customUserAgent = @"Anything Safari";

Then the WebGL rendering is disabled and the terminal works as it should.

isontheline avatar Jan 26 '22 06:01 isontheline

Yeah we check for "safari" in the user agent right now: https://github.com/xtermjs/xterm.js/issues/3357#issuecomment-993172813

This just needs someone with a device that can verify a fix works for the webkit webview and doesn't break Chrome, etc. since user agents are a mess.

Tyriar avatar Jan 26 '22 14:01 Tyriar

I believe this can be close now

daonb avatar Jan 23 '23 13:01 daonb