From 918d658f956db5c4e8a47ed0b13a5b4d9dbd534a Mon Sep 17 00:00:00 2001 From: Richard Geldreich Date: Fri, 23 Oct 2026 14:38:56 -0400 Subject: [PATCH] webgl encoder: accept mainScriptUrlOrBlob in threaded builds (Emscripten 6.0.x) Newer Emscripten (6.0.x) no longer includes mainScriptUrlOrBlob in its default INCOMING_MODULE_JS_API, so the threaded encoder loaded via importScripts() in ktx2_studio/encode-worker.js ignored it and the pthread pool never came up (the worker hangs while loading). Add it explicitly (Emscripten's default list plus mainScriptUrlOrBlob), as in the development tree. Co-Authored-By: Claude Opus 5.5 --- webgl/encoder/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/webgl/encoder/CMakeLists.txt b/webgl/encoder/CMakeLists.txt index 478c0cd..1af6352 100644 --- a/webgl/encoder/CMakeLists.txt +++ b/webgl/encoder/CMakeLists.txt @@ -149,7 +149,10 @@ if(EMSCRIPTEN) endif() endif() - set(LINK_THREADS "-s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=32 -s ENVIRONMENT=web,worker") + # INCOMING_MODULE_JS_API: Emscripten's default list plus mainScriptUrlOrBlob, which newer Emscripten (6.0.x) no longer accepts by default. + # ktx2_studio/encode-worker.js loads the threaded encoder via importScripts() and must pass mainScriptUrlOrBlob, otherwise the pthread + # pool is spawned from the wrong script and the encoder module never finishes loading (silent hang). + set(LINK_THREADS "-s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=32 -s ENVIRONMENT=web,worker -s INCOMING_MODULE_JS_API=['ENVIRONMENT','arguments','canvas','dynamicLibraries','elementPointerLock','instantiateWasm','locateFile','monitorRunDependencies','noExitRuntime','noInitialRun','onAbort','onExit','onRuntimeInitialized','postRun','preInit','preRun','print','printErr','setStatus','statusMessage','stderr','stdin','stdout','thisProgram','wasm','websocket','mainScriptUrlOrBlob']") set(LINK_WASM64 "-s MEMORY64=1 -sWASM_BIGINT=1 --profiling-funcs") # Helper to avoid repetition