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

locateFile() not called for .js with EXPORT_ES6 #22508

Open
jozefchutka opened this issue Sep 5, 2024 · 2 comments
Open

locateFile() not called for .js with EXPORT_ES6 #22508

jozefchutka opened this issue Sep 5, 2024 · 2 comments

Comments

@jozefchutka
Copy link

jozefchutka commented Sep 5, 2024

Using emscripten 3.1.65 and -sEXPORT_ES6=1, the following .js is generated

function allocateUnusedWorker() {
                var worker;
                var workerOptions = {
                    type: "module",
                    name: "em-pthread"
                };
                worker = new Worker(new URL("ffmpeg-lgpl-simd.js",import.meta.url),workerOptions);
                PThread.unusedWorkers.push(worker)
            },


function findWasmBinary() {
            if (Module["locateFile"]) {
                var f = "ffmpeg-lgpl-simd.wasm";
                if (!isDataURI(f)) {
                    return locateFile(f)
                }
                return f
            }
            return new URL("ffmpeg-lgpl-simd.wasm",import.meta.url).href
        }

The problem is allocateUnusedWorker() is not calling locateFile() (as findWasmBinary() does) making it hard to customize the URL. Please enhance allocateUnusedWorker() to call locateFile() before constructing .js url

@sbc100
Copy link
Collaborator

sbc100 commented Sep 5, 2024

This is kind of unfortunate. Ideally we would just use new URL(import.meta.url) since we know we are trying to load the same file that is currently running.... however that apparently breaks bundlers. See #22140.

I wonder if we need a new settings such as BUNDLER_FRIENDLY here since by default it would be really nice to just use new URL(import.meta.url) when we know we want to load ourselves.

@jozefchutka
Copy link
Author

In my case, I am not using a standard https://... url, but a blob:https:// url as the main js. Same blob url I would like to use inside allocateUnusedWorker() to avoid any possible network related slow downs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants