Forum Discussion

mdrabkin's avatar
mdrabkin
Regular Visitor
8 years ago

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

  • v-viig's avatar
    v-viig
    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

    [email protected]

     

    • mdrabkin's avatar
      mdrabkin
      Regular Visitor

      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's avatar
        v-viig
        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

        [email protected]

    • yashdesai's avatar
      yashdesai
      Regular Visitor

      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.