Remove unnecessary rigmarole around importing the script as a blob (#17642)

This commit is contained in:
Joe Osborn 2025-03-01 17:34:05 -08:00 committed by GitHub
parent 23170b82ec
commit f2a86f34d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 15 deletions

View File

@ -118,7 +118,7 @@ ifeq ($(HAVE_WASMFS), 1)
endif
ifeq ($(PROXY_TO_PTHREAD),1)
LIBS += -sUSE_ES6_IMPORT_META=0 -sENVIRONMENT=worker,web
LIBS += -sENVIRONMENT=worker,web
LIBS += -sPROXY_TO_PTHREAD -sOFFSCREENCANVAS_SUPPORT
DEFINES += -DUSE_OFFSCREENCANVAS=1 -DPROXY_TO_PTHREAD=1
else

View File

@ -461,6 +461,11 @@ static uint64_t frontend_emscripten_get_free_mem(void)
}
void emscripten_bootup_mainloop(void *argptr) {
if(retro_started) {
/* A stale extra call to bootup_mainloop for some reason */
RARCH_ERR("[Emscripten] unexpected second call to bootup_mainloop after rarch_main called\n");
return;
}
if(filesystem_ready) {
args_t *args = (args_t*)argptr;
emscripten_cancel_main_loop();

View File

@ -216,24 +216,15 @@ $(function() {
loadCore(core);
});
async function downloadScript(src) {
let resp = await fetch(src);
let blob = await resp.blob();
return blob;
}
function loadCore(core) {
// Make the core the selected core in the UI.
var coreTitle = $('#core-selector a[data-core="' + core + '"]').addClass('active').text();
$('#dropdownMenu1').text(coreTitle);
downloadScript("./"+core+"_libretro.js").then(scriptBlob => {
Module.mainScriptUrlOrBlob = scriptBlob;
import(URL.createObjectURL(scriptBlob)).then(script => {
script.default(Module).then(mod => {
Module = mod;
}).catch(err => { console.error("Couldn't instantiate module",err); throw err; });
}).catch(err => { console.error("Couldn't load script",err); throw err; });
});
import("./"+core+"_libretro.js").then(script => {
script.default(Module).then(mod => {
Module = mod;
}).catch(err => { console.error("Couldn't instantiate module",err); throw err; });
}).catch(err => { console.error("Couldn't import module"); throw err; });
}
const setupWorker = new Worker("libretro.worker.js");