[Web] Add missing features warning in editor and export shell.

This commit is contained in:
Fabio Alessandrelli 2022-09-17 11:33:53 +02:00
parent 6bbde346ab
commit 51484028fd
2 changed files with 19 additions and 22 deletions

View File

@ -259,31 +259,20 @@
>Web editor documentation</a> for usage instructions and limitations. >Web editor documentation</a> for usage instructions and limitations.
</p> </p>
</div> </div>
<div id="welcome-modal-description-no-cross-origin-isolation" style="display: none"> <div id="welcome-modal-missing-description" style="display: none">
<p> <p>
The web server does not support cross-origin isolation, <strong>The following features required by the Godot Web Editor are missing:</strong>
which is required for the Godot Web Editor to function. <ul id="welcome-modal-missing-list">
</p>
<p>
<strong>Reasons for cross-origin isolation being disabled:</strong>
<ul>
<li id="welcome-modal-reason-not-secure">
This page is not served from a secure context (HTTPS <i>or</i> localhost).
</li>
<li>
This page may not be served with cross-origin isolation headers
(check with the developer tools' Network tab).
</li>
</ul> </ul>
</p> </p>
<p> <p>
If you are self-hosting the web editor, If you are self-hosting the web editor,
refer to refer to
<a <a
href="https://docs.godotengine.org/en/latest/tutorials/export/exporting_for_web.html#threads" href="https://docs.godotengine.org/en/latest/tutorials/export/exporting_for_web.html"
target="_blank" target="_blank"
rel="noopener" rel="noopener"
>Exporting for the Web - Threads</a> for more information. >Exporting for the Web</a> for more information.
</p> </p>
</div> </div>
<div style="text-align: center"> <div style="text-align: center">
@ -394,16 +383,22 @@
}); });
} }
if (!crossOriginIsolated) { const missing = Engine.getMissingFeatures();
if (missing.length) {
// Display error dialog as threading support is required for the editor. // Display error dialog as threading support is required for the editor.
setButtonEnabled('startButton', false); setButtonEnabled('startButton', false);
document.getElementById("welcome-modal-description").style.display = "none"; document.getElementById("welcome-modal-description").style.display = "none";
document.getElementById("welcome-modal-description-no-cross-origin-isolation").style.display = "block"; document.getElementById("welcome-modal-missing-description").style.display = "block";
document.getElementById("welcome-modal-dismiss").style.display = "none"; document.getElementById("welcome-modal-dismiss").style.display = "none";
document.getElementById("welcome-modal-reason-not-secure").style.display = window.isSecureContext ? "none" : "list-item"; const list = document.getElementById("welcome-modal-missing-list");
for (let i = 0; i < missing.length; i++) {
const node = document.createElement("li");
node.innerText = missing[i];
list.appendChild(node);
}
} }
if (!crossOriginIsolated || localStorage.getItem("welcomeModalDismissed") !== 'true') { if (missing.length || localStorage.getItem("welcomeModalDismissed") !== 'true') {
document.getElementById("welcome-modal").style.display = "block"; document.getElementById("welcome-modal").style.display = "block";
document.getElementById("welcome-modal-dismiss").focus(); document.getElementById("welcome-modal-dismiss").focus();
} }

View File

@ -215,8 +215,10 @@ $GODOT_HEAD_INCLUDE
initializing = false; initializing = false;
}; };
if (!Engine.isWebGLAvailable()) { const missing = Engine.getMissingFeatures();
displayFailureNotice('WebGL not available'); if (missing.length !== 0) {
const missingMsg = 'Warning!\nThe following features required to run Godot projects on the Web are missing:\n';
displayFailureNotice(missingMsg + missing.join("\n"));
} else { } else {
setStatusMode('indeterminate'); setStatusMode('indeterminate');
engine.startGame({ engine.startGame({