Skip to content
Snippets Groups Projects
Closed JOB_Web demos fail with "import object field 'create_object' is not a Function"
  • View options
  • JOB_Web demos fail with "import object field 'create_object' is not a Function"

  • View options
  • Closed Issue created by Michalis Kamburelis

    I'm trying to run the JOB_Web demos from the Pas2js repository:

    • demo/wasienv/button/
    • demo/wasienv/dom/

    I'm using

    I had to make these 2 modifications to the examples:

    1. To build demo/wasienv/dom/ WASM part I had to fix uses clauses in pas2js/demo/wasienv/dom/WasiDomTest1.lpr, the NoThreads unit was used there twice.

    2. I had to also fix both

      • pas2js/demo/wasienv/dom/WasiDomTest1.lpr
      • pas2js/demo/wasienv/button/WasiButton1.lpr

      In both cases I commented out "exports JOBCallback" inside the lpr, otherwise trying to load them in browsers resulted in errrors "duplicate import". There is a comment "workaround: fpc wasm does not yet support exporting functions from units" in both above files, possibly this is outdated comment now and FPC exports JOBCallback from Job.JS unit OK now? Because there is exports JOBCallback; inside https://gitlab.com/freepascal.org/fpc/source/-/blob/main/packages/wasm-job/src/job.js.pas?ref_type=heads#L4986 .

    Still, after doing AD 1 and AD 2, running the examples in the browsers shows errors about create_object . Here's how I try to run them:

    cd ~/sources/pas2js/demo/wasienv/dom
    pas2js -Jc -Jirtl.js -Tbrowser BrowserDomTest1.lpr
    fpc -Twasi -Pwasm32 WasiDomTest1.lpr
    mv -f WasiDomTest1 WasiDomTest1.wasm
    compileserver --port=3000

    This fails:

    • In Firefox: "Instantiating of WebAssembly from WasiDomTest1.wasm failed import object field 'create_object' is not a Function"

    • In Vivaldi (based on Chromium): "Instantiating of WebAssembly from WasiDomTest1.wasm failed WebAssembly.instantiate(): Import #39 "job" "create_object": function import requires a callable"

    Doing it with demo/wasienv/button is similar, here's what I do:

    cd ~/sources/pas2js/demo/wasienv/button
    pas2js -Jc -Jirtl.js -Tbrowser BrowserButton1.lpr
    fpc -Twasi -Pwasm32 WasiButton1.lpr -Fu../dom/
    mv -f WasiButton1 WasiButton1.wasm
    compileserver --port=3000

    ... with the exact same errors from Firefox and Vivaldi.

    I'm attaching the screenshots with errors.

    v

    f

    Linked items 0

  • Link items together to show that they're related or that one is blocking others.

    Activity

    • All activity
    • Comments only
    • History only
    • Newest first
    • Oldest first
    Loading Loading Loading Loading Loading Loading Loading Loading Loading Loading