Add THREADS_ENABLED macro in order to compile Godot to run on the main thread

This commit is contained in:
Adam Scott
2023-12-01 13:39:09 -05:00
parent 107f2961cc
commit bd70b8e1f6
33 changed files with 447 additions and 72 deletions

View File

@@ -23,7 +23,7 @@
<link id="-gd-engine-icon" rel="icon" type="image/png" href="favicon.png">
<link rel="apple-touch-icon" type="image/png" href="favicon.png">
<link rel="manifest" href="manifest.json">
<title>Godot Engine Web Editor (@GODOT_VERSION@)</title>
<title>Godot Engine Web Editor (___GODOT_VERSION___)</title>
<style>
*:focus {
/* More visible outline for better keyboard navigation. */
@@ -294,7 +294,7 @@ a:active {
<br >
<img src="logo.svg" alt="Godot Engine logo" width="1024" height="414" style="width: auto; height: auto; max-width: min(85%, 50vh); max-height: 250px">
<br >
@GODOT_VERSION@
___GODOT_VERSION___
<br >
<a href="releases/">Need an old version?</a>
<br >
@@ -384,7 +384,9 @@ window.addEventListener('load', () => {
});
}
const missing = Engine.getMissingFeatures();
const missing = Engine.getMissingFeatures({
threads: ___GODOT_THREADS_ENABLED___,
});
if (missing.length) {
// Display error dialog as threading support is required for the editor.
document.getElementById('startButton').disabled = 'disabled';

View File

@@ -136,6 +136,7 @@ body {
<script src="$GODOT_URL"></script>
<script>
const GODOT_CONFIG = $GODOT_CONFIG;
const GODOT_THREADS_ENABLED = $GODOT_THREADS_ENABLED;
const engine = new Engine(GODOT_CONFIG);
(function () {
@@ -213,7 +214,9 @@ const engine = new Engine(GODOT_CONFIG);
initializing = false;
}
const missing = Engine.getMissingFeatures();
const missing = Engine.getMissingFeatures({
threads: GODOT_THREADS_ENABLED,
});
if (missing.length !== 0) {
const missingMsg = 'Error\nThe following features required to run Godot projects on the Web are missing:\n';
displayFailureNotice(missingMsg + missing.join('\n'));

View File

@@ -3,14 +3,14 @@
// that they need an Internet connection to run the project if desired.
// Incrementing CACHE_VERSION will kick off the install event and force
// previously cached resources to be updated from the network.
const CACHE_VERSION = "@GODOT_VERSION@";
const CACHE_PREFIX = "@GODOT_NAME@-sw-cache-";
const CACHE_VERSION = "___GODOT_VERSION___";
const CACHE_PREFIX = "___GODOT_NAME___-sw-cache-";
const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION;
const OFFLINE_URL = "@GODOT_OFFLINE_PAGE@";
const OFFLINE_URL = "___GODOT_OFFLINE_PAGE___";
// Files that will be cached on load.
const CACHED_FILES = @GODOT_CACHE@;
const CACHED_FILES = ___GODOT_CACHE___;
// Files that we might not want the user to preload, and will only be cached on first load.
const CACHABLE_FILES = @GODOT_OPT_CACHE@;
const CACHABLE_FILES = ___GODOT_OPT_CACHE___;
const FULL_CACHE = CACHED_FILES.concat(CACHABLE_FILES);
self.addEventListener("install", (event) => {
@@ -22,7 +22,7 @@ self.addEventListener("activate", (event) => {
function (keys) {
// Remove old caches.
return Promise.all(keys.filter(key => key.startsWith(CACHE_PREFIX) && key != CACHE_NAME).map(key => caches.delete(key)));
}).then(function() {
}).then(function () {
// Enable navigation preload if available.
return ("navigationPreload" in self.registration) ? self.registration.navigationPreload.enable() : Promise.resolve();
})