Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hardware accel warning #352

Merged
merged 2 commits into from
Sep 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions global/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5260,4 +5260,18 @@ input[type='range']:focus::-ms-fill-upper {
}
.osekai__tab-page-content-inner.osekai__otab-hidden .osekai__2col-panels {
/* position: fixed !important; */
}

.osekai__noaccel {
display: flex;
align-items: center;
background-color: rgba(var(--accent), 1) !important;
}

.osekai__noaccel span {
margin-left: auto;
background-color: #fffc;
color: rgba(var(--accent), 1);
padding: 8px 12px;
border-radius: 4px;
}
83 changes: 79 additions & 4 deletions global/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,9 @@ window.openDialog = function (title, header, message, buttons = [], content = nu
modal_overlay_panel.appendChild(modal_overlay_panel_top);
modal_overlay_panel.appendChild(modal_overlay_panel_bottom);

var title = Object.assign(document.createElement("h1"), { innerText: title });
var sub = Object.assign(document.createElement("h3"), { innerText: header });
var message = Object.assign(document.createElement("p"), { innerText: message });
var title = Object.assign(document.createElement("h1"), { innerHTML: title });
var sub = Object.assign(document.createElement("h3"), { innerHTML: header });
var message = Object.assign(document.createElement("p"), { innerHTML: message });

modal_overlay_panel_bottom.appendChild(title);
modal_overlay_panel_bottom.appendChild(sub);
Expand Down Expand Up @@ -735,7 +735,7 @@ function insertParam(key, value) {

url.search = params;
url = url.toString();
window.history.pushState({url: url}, null, url);
window.history.pushState({ url: url }, null, url);

}

Expand Down Expand Up @@ -896,4 +896,79 @@ function checkPermission(permission) {
}
}
return false;
}

function hardwareAccelLearnMore() {
openDialog(GetStringRawNonAsync("navbar", "misc.hardwareAccel.popup.title"),
GetStringRawNonAsync("navbar", "misc.hardwareAccel.popup.subtitle"),
GetStringRawNonAsync("navbar", "misc.hardwareAccel.popup.content"), [
{
"text": GetStringRawNonAsync("general", "ok"),
"callback": function () { },
"highlighted": true,
},
{
"text": GetStringRawNonAsync("navbar", "misc.hardwareAccel.popup.hide"),
"callback": function () {
localStorage.setItem("hideHardwareAccelWarning", true);
document.getElementById("noHardwareAccel").classList.add("hidden");

},
"highlighted": false,
}
]);
}

var canvas = document.createElement('canvas');
var gl;
var debugInfo;
var vendor;
var renderer;

try {
gl = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
} catch (e) {
}

if (gl) {
debugInfo = gl.getExtension('WEBGL_debug_renderer_info');
vendor = gl.getParameter(debugInfo.UNMASKED_VENDOR_WEBGL);
renderer = gl.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL);
}

console.log(debugInfo);
console.log(vendor);
console.log(renderer);

// !chrome
// no acccel:
// vendor: Google Inc. (Google)
// renderer: ANGLE (Google, Vulkan 1.3.0 (SwiftShader Device (Subzero) (0x0000C0DE)), SwiftShader driver)
// accel:
// vendor: Google Inc. (NVIDIA Corporation)
// renderer: ANGLE (NVIDIA Corporation, NVIDIA GeForce RTX 3060 Ti/PCIe/SSE2, OpenGL 4.5.0)
//!firefox
// no acccel:
// vendor: NVIDIA Corporation
// renderer: NVIDIA GeForce GTX 980/PCIe/SSE2
// accel:
// vendor: NVIDIA Corporation
// renderer: NVIDIA GeForce GTX 980/PCIe/SSE2
//? sadly no way to detect firefox, so we'll just check chrome

if (renderer.includes("SwiftShader")) {
if (localStorage.getItem("hideHardwareAccelWarning") == null) {
document.getElementById("noHardwareAccel").classList.remove("hidden");
if (localStorage.getItem("noaccelSwitched") == null) {
localStorage.setItem("noaccelSwitched", true);
setTheme("lightweight");
}
}
} else {
if (localStorage.getItem("noaccelSwitched") == "true") {
localStorage.removeItem("noaccelSwitched");
localStorage.removeItem("hideHardwareAccelWarning");
setTheme("colourful");
document.getElementById("hardwareAccelOn").classList.remove("hidden");
}
}
9 changes: 8 additions & 1 deletion global/lang/en_GB/navbar.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,12 @@
"otherApps.userGroups": "User Groups",
"misc.cantContactOsu": "Osekai cannot contact osu!'s servers. This may be because osu! is down, or you could be connected to a private server. If you are connected to a private server, please disconnect from it.",
"misc.restriction.title": "Your account on Osekai has been restricted.",
"misc.restriction.description": "To appeal this, please contact us on the <a href=\"https://discord.com/invite/8qpNTs6\">osu! Medal Hunters Discord server</a>"
"misc.restriction.description": "To appeal this, please contact us on the <a href=\"https://discord.com/invite/8qpNTs6\">osu! Medal Hunters Discord server</a>",
"misc.hardwareAccel.warning": "Your browser does not have hardware acceleration on. Osekai will likely run slower than usual. We've automatically enabled lightweight mode.",
"misc.hardwareAccel.learnMore": "Learn more.",
"misc.hardwareAccel.popup.title": "Your browser does not have hardware acceleration on.",
"misc.hardwareAccel.popup.subtitle": "This means Osekai will likely be laggy.",
"misc.hardwareAccel.popup.content": "Hardware acceleration means that your browser uses your computer's GPU to render the page, and at the moment, your browser seemingly has this disabled. Please check your browser settings to see if you can turn it on.<br><br>On Chromium-based browsers (Edge, Opera, Chrome, etc) this will likely be under the [System] tab. And in Firefox, it will be in the [Performance] section of the General tab.",
"misc.hardwareAccel.popup.hide": "Hide Warning",
"misc.hardwareAccel.fixed": "Your browser now has hardware acceleration on. We've reset your theme back to default. Refresh to hide this notification."
}
7 changes: 7 additions & 0 deletions global/php/navbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ class="hidden">
<div class="osekai__navbar-warning hidden" id="cantContactOsu">
<?= GetStringRaw("navbar", "misc.cantContactOsu"); ?>
</div>
<div class="osekai__navbar-warning osekai__noaccel hidden" id="noHardwareAccel">
<?= GetStringRaw("navbar", "misc.hardwareAccel.warning"); ?>
<span onclick="hardwareAccelLearnMore()"><?= GetStringRaw("navbar", "misc.hardwareAccel.learnMore"); ?></span>
</div>
<div class="osekai__navbar-warning osekai__noaccel hidden" id="hardwareAccelOn">
<?= GetStringRaw("navbar", "misc.hardwareAccel.fixed"); ?>
</div>
<?php if (isRestricted()) { ?>
<div class="osekai__navbar-restriction">
<div class="osekai__navbar-restriction-icon">
Expand Down