Skip to content

Commit

Permalink
#227 disable offscreen with webkit
Browse files Browse the repository at this point in the history
but keep it enabled with chrome
  • Loading branch information
totaam committed Nov 27, 2023
1 parent 79fa02d commit e2e71ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion html5/connect.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

<script type="text/javascript" src="js/RgbHelpers.js"></script>
<script type="text/javascript" src="js/VideoDecoder.js"></script>
<script src="js/Utilities.js"></script>
<script
type="text/javascript"
src="js/OffscreenDecodeWorkerHelper.js"
></script>

<script src="js/lib/jquery.js"></script>
<script src="js/Utilities.js"></script>
<script src="js/MediaSourceUtil.js"></script>
<script src="js/lib/aurora/aurora.js"></script>
<!--
Expand Down
11 changes: 7 additions & 4 deletions html5/js/OffscreenDecodeWorkerHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,23 @@ const XpraOffscreenWorker = {
},

isAvailable() {
var isSafari = navigator.userAgent.toLowerCase().includes("safari");
if (isSafari && !this.isSafariVersionSupported()) {
if (Utilities.isSafari() && !this.isSafariVersionSupported()) {
return false;
}

var isFirefox = navigator.userAgent.toLowerCase().includes("firefox");
if (isFirefox && this.isFirefoxVersionSupported()) {
if (Utilities.isWebkit() && !Utilities.isChrome()) {
return false;
}

if (Utilities.isFirefox() && this.isFirefoxVersionSupported()) {
return false;
}

if (typeof OffscreenCanvas !== "undefined") {
//we also need the direct constructor:
try {
new OffscreenCanvas(256, 256);
console.log("offscreen canvas is available with", navigator.userAgent);
return true;
} catch (error) {
console.warn("unable to instantiate an offscreen canvas:", error);
Expand Down
4 changes: 4 additions & 0 deletions html5/js/Utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,10 @@ const Utilities = {
const ua = navigator.userAgent.toLowerCase();
return ua.includes("safari") && !ua.includes("chrome");
},
isWebkit() {
const ua = navigator.userAgent.toLowerCase();
return ua.includes("webkit");
},
isEdge() {
return navigator.userAgent.includes("Edge");
},
Expand Down

0 comments on commit e2e71ff

Please sign in to comment.