question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make the WASM location configurable

See original GitHub issue

So far we have been working on the assumption that the WASM file is in the root directory of the project. However, this may not always be the case, and it would be interesting if the user could define where their WASM file is. I’ve had to set this up by hand for the Three.js IFC Loader, and I think it would be interesting to incorporate it into web-ifc.

The path to the WASM file resides in the wasmBinaryFile variable generated by Emscripten.

image

The solution provided for Three.js was to add a global variable containing the relative path of the WASM that could be set through a function of the API. Something like:

var WasmPath = "";

//...

var wasmBinaryFile = WasmPath + "web-ifc.wasm";

//...

var IfcAPI = class {
   //...
   SetWasmPath(path){
     WasmPath = path;
   }
};

export {
  IfcAPI,
  ms
};

This setter function will be also present in web-ifc-three. This way, we will be able to use the Loader like this:

   const IfcLoader = new IfcLoader();
   ifcLoader.SetWasmPath("./whatever/path/");
   ifcLoader.load();

A minimal example of how this looks can be found here.

I suppose that the SetWasmPath can be added to web-ifc-api.ts. As for the global variable and the wasmBinaryFile initialization, we can probably write a JS file with a script to add these two lines to the bundled file.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
tomvandigcommented, May 20, 2021

Would vote against this, the WASM file as a standalone web resource enables browsers to cache the compiled code, reducing subsequent startup times by skipping compilation. More info here: https://v8.dev/blog/wasm-code-caching

I am by no means a chrome expert, but I expect this caching to break if we somehow bundle the wasm inside the js resource, they specifically mention:

Cached compiled code is associated with the URL of the .wasm resource, which makes it easy to look up without having to scan the actual resource. This means that changing the URL of a resource (including any query parameters!) creates a new entry in our resource cache, which also requires a complete recompile and creates a new code cache entry.

Could be this info is out of date though, no idea.

0reactions
agviegascommented, May 20, 2021

Hum, might be. Feel free to dig into this, could be nice if it removes the WASM file handling!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Make the WASM location configurable · Issue #22 · IFCjs/web-ifc
The path to the WASM file resides in the wasmBinaryFile variable generated by Emscripten. ... The solution provided for Three.js was to add...
Read more >
Config in wasmtime - Rust
Configures the maximum amount of stack space available for executing WebAssembly code. WebAssembly has well-defined semantics on stack overflow. This is ...
Read more >
webassembly (C) How can I create configuration files?
I would like to create configuration for my webassembly app. It just needs to be able to store some key-value pairs: whether it's...
Read more >
build - Hello wasm-pack!
The wasm-pack build command creates the files neccessary for JavaScript ... If no path is given, the build command will run in the...
Read more >
ASP.NET Core Blazor configuration - Microsoft Learn
Learn about configuration of Blazor apps, including app settings, authentication, and logging configuration.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found