Skip to content

pthread error #12473

Open
Open

Description

@imlihang

I'm using pthreads with -s TOTAL_MEMORY=671088640 -s USE_PTHREADS=1 -s PROXY_TO_PTHREAD with EMSDK 2.0.6.
I run my unit test in Chrome browser with version 86.0.4240.75.
I got the following error message.

xxx.worker.js:1 Refused to execute script from 'xxx.js' because its MIME type ('text/plain') is not executable.
worker.js onmessage() captured an uncaught exception: NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'xxx.js' failed to load.
Error: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'xxx.js' failed to load.
pthread sent an error! xxx.worker.js:1: Uncaught NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at xxx.js failed to load.
Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at xxx.js failed to load.

How can I solve this problem?
Thank you.

Activity

  1. stale commented on Apr 17, 2022

    @stale

    This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

  2. Glavin001 commented on Sep 7, 2022

    @Glavin001

    @imlihang Did you figure this out? I just stumbled upon the same issue:

    worker.js onmessage() captured an uncaught exception: NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://REDACTED.wasm.6a6ab926.js' failed to load.
    
    Error: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://REDACTED.wasm.6a6ab926.js' failed to load.
        at self.onmessage (data:application/javascript;base64,...==:1:1013)
        
        Uncaught DOMException: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'https://REDACTED/file.wasm.6a6ab926.js' failed to load.
        at self.onmessage 
    
  3. ensisoft commented on Jan 25, 2024

    @ensisoft

    I'm seeing what seems to be the same issue.

    Chrome
    Version 120.0.6099.227 (Official Build) (64-bit)

    Windows 10 22H2 Os Build 19045.3930

    Emscripten
    emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.0.0 (3fd52e1)
    clang version 14.0.0 (https://github.com/llvm/llvm-project 4348cd42c385e71b63e5da7e492172cff6a79d7b)
    Target: wasm32-unknown-emscripten
    Thread model: posix

    Using EmSDK 3.0.0

    Top Chrome errors

    Refused to execute script from 'http://localhost:8000/GameEngine.js' because its MIME type ('text/plain') is not executable.
    self.onmessage @ GameEngine.worker.js:1
    
    worker.js onmessage() captured an uncaught exception: NetworkError: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:8000/GameEngine.js' failed to load.
    threadPrintErr @ GameEngine.worker.js:1
    self.onmessage @ GameEngine.worker.js:1
    
    GameEngine.worker.js:1 Error: Failed to execute 'importScripts' on 'WorkerGlobalScope': The script at 'http://localhost:8000/GameEngine.js' failed to load.
        at self.onmessage (GameEngine.worker.js:1:1386)
    
    Refused to execute script from 'http://localhost:8000/GameEngine.js' because its MIME type ('text/plain') is not executable.
    self.onmessage @ GameEngine.worker.js:1
    

    and a whole bunch of other crap.
    Under chrome dev tools in the "Network" tab each .js file has type "text/javascript". Smells like something gets gloriously messed up somewhere.

  4. andynewman10 commented on Jun 18, 2024

    @andynewman10

    I confirm this behavior. I am also using Chrome on Windows.

    I am using a manually built opencv.js runtime (emscripten 3.1.58).

    • from a web worker script, if I enable WASM threads, I get the error described in this issue. If I do not enable WASM threads, I get no error.
    • when using opencv.js from the main page (not from a web worker script), even if WASM threads are enabled, there is no error

    Full repro code (I'm using WSL):

    $ cd
    $ cd emsdk
    $ ./emsdk activate latest
    $ source ./emsdk_env.sh
    $ cd ..
    $ git clone https://github.com/opencv/opencv.git
    

    Now either try:

    $ emcmake python3 ./opencv/platforms/js/build_js.py build_wasmthreads --build_wasm --threads
    $ emcmake python3 ./opencv/platforms/js/build_js.py build_wasm --build_wasm
    

    Then:

    • load opencv.js
    • await cv;. This line of code will fail when WASM threads are enabled, and the call is performed from a web worker.
  5. sbc100 commented on Jun 18, 2024

    @sbc100
    Collaborator

    @andynewman10 what error message do you see in the pthread case?

    Can you confirm if you get the same issue with emsdk install tot && emsdk activate tot?

  6. andynewman10 commented on Jun 19, 2024

    @andynewman10

    @sbc100 I am getting the same result with emsdk install tot && emsdk activate tot.

    The error I am getting is actually different :

    Refused to execute script from 'http://localhost:56523/undefined' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

    I am not opening any page and doing anything special beyond spawning a web worker and calling importScripts in that worker, at the beginning, and only once.

    The importScripts('http://localhost:56523/opencv.js') statement in the web worker is successful (raises no exception).

    The URL of the main page is http://localhost:56523/#/test and the URL of the worker is http://localhost:56523/worker.js.

    The same code works fine from the main thread (opencv.js loaded through a script tag in this case).

  7. sbc100 commented on Jun 19, 2024

    @sbc100
    Collaborator

    @andynewman10 should we open a new issue for this? It seems unlikely this this is the same issue for back in 2020.

    I assume this is a regression that that the same code worked fine with some older version of emscripten? I'm guessing that this is part of the fallout from #21701, since that was a major pthread change that landed in 3.1.58. Can you confirm that it works in 3.1.57?

  8. andynewman10 commented on Jun 19, 2024

    @andynewman10

    @sbc100 I am happy to test with previous versions of emscripten.

    Can I switch to a specific version using emsdk install XXX && emsdk activate XXX ?

  9. andynewman10 commented on Jun 19, 2024

    @andynewman10

    It does not work with emscripten 3.1.57 either.

    Followed your advice and opened #22117.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions