Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
mdrabkin
Regular Visitor

Is it possible to load WebAssembly file from custom visual?

Hi,

 

I'm experimenting with custom visuals development, and was trying to load a .wasm file.

Since it requires me to fetch the file, I keep getting cross origin error.

I couldn't find anywhere in the pbiviz.json a definition to include another resource in the packaging of the custom visual.

 

As a matter of fact, I couldn't even find a way to load any other blob, not even a regular image (all documentation guide to convert to data-url and use that)

 

Is there a way to package the .wasm file somehow, so that I'll be able to fetch it at runtime?

 

Thanks,

Maxim

5 REPLIES 5
v-viig
Community Champion
Community Champion

WASM is not supported by pbiviz tools. We're migrating to webpack that can compile WASM pretty well.

 

To load external resource such as JS or WASM a server must support CORS.

Otherwise, remote connection will be refused by browser.

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

 

I am trying to build a custom visual in power bi using a library called IFC.js. I have bundled it using webpack hoping that the .wasm files would get compiled. I have been trying to integrate this: 

 

https://github.com/IFCjs/web-ifc-viewer/tree/master/example

 

into the custom visual. So it runs perfectly in the local host but the IFC loader in in this does not load the ifc and gives an error like this: 

VM7233:70054 wasm streaming compile failed: TypeError: Failed to execute 'compile' on 'WebAssembly': Incorrect response MIME type. Expected 'application/wasm'.

falling back to ArrayBuffer instantiation,

VM7233:70045 failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 0d 0a 3c 21 @+0,

 

I have tried a lot of things to resolve this. I suspect it is because power bi is not able to access the .wasm files which are necessary to use the IFC loader from the library.

Thank you very much for the response!

 

Yes I know that loading external resources will require the server to enable CORS. 

As the visual is served from app.powerbi.com, I would need to configure powerbi to enable CORS. Is that possible?

Also if there is a way to host the visual ourselves, do you know where I could find some information about it?

 

Thanks,

Maxim

v-viig
Community Champion
Community Champion

We can not control CORS in Power BI. However, you can upload your wasm files to CDN or another server that supports CORS.

 

What do mean? Do you want to use a visual outside of Power BI?

 

Ignat Vilesov,

Software Engineer

 

Microsoft Power BI Custom Visuals

pbicvsupport@microsoft.com

I created a local server on my machine that hosts the .wasm file, but when I try to fetch it from the power bi visual project, it caused an error about CSP `because it violates the following Content Security Policy directive: "default-src <URL> data: blob: 'unsafe-inline' 'unsafe-eval'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.` How can I fix this, please help me !!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.