Skip to content

Commit b5f5da0

Browse files
authored
Added WebAssembly support check
1 parent a21115d commit b5f5da0

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title></title>
6+
</head>
7+
<body>
8+
<div>
9+
Your browser doesn't support <a href="https://developer.mozilla.org/en-US/docs/WebAssembly">WebAssembly</a>
10+
</div>
11+
12+
<br />
13+
14+
<div>
15+
For more information on WebAssembly browser support please follow <a href="https://caniuse.com/#search=webassembly">this link</a>.
16+
</div>
17+
18+
</body>
19+
</html>

Jellyfin.HardwareVisualizer/Client/wwwroot/index.html

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,38 @@
4545
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/loader.js" async=""></script>
4646
<script src="_content/BlazorMonaco/lib/monaco-editor/min/vs/editor/editor.main.js" async=""></script>
4747
<script src="BlazorJsonSchemaHelper.js" async=""></script>
48-
<script src="_framework/blazor.webassembly.js"></script>
48+
<!--prevent autostarting-->
49+
<script src="_framework/blazor.webassembly.js" autostart="false"></script>
50+
51+
<script>
52+
53+
//check if webassembly is supported
54+
const webassemblySupported = (function () {
55+
try {
56+
if (typeof WebAssembly === "object"
57+
&& typeof WebAssembly.instantiate === "function") {
58+
const module = new WebAssembly.Module(
59+
Uint8Array.of(0x0, 0x61, 0x73, 0x6d,
60+
0x01, 0x00, 0x00, 0x00));
61+
if (module instanceof WebAssembly.Module)
62+
return new WebAssembly.Instance(module)
63+
instanceof WebAssembly.Instance;
64+
}
65+
} catch (e) {
66+
}
67+
return false;
68+
})();
69+
70+
// Modern browsers e.g. Microsoft Edge
71+
if (webassemblySupported) {
72+
Blazor.start({});
73+
}
74+
// Older browsers e.g. IE11
75+
else {
76+
window.location = window.location + "BrowserNotSupported.html";
77+
}
78+
79+
</script>
4980
</body>
5081

5182
</html>

0 commit comments

Comments
 (0)