voxeet / voxeet-sdk-web

The Dolby.io Communications SDK for Web.
https://www.npmjs.com/package/@voxeet/voxeet-web-sdk
Other
4 stars 2 forks source link

WASM warnings when joining a conference #25

Closed slicertech closed 8 months ago

slicertech commented 10 months ago

Hi,

It seems, everytime we call await VoxeetSDK.conference.join(conference, joinOptions);

joinOptions:

constraints: {audio: true, video: false}
preferRecvMono: false
preferSendMono: false
spatialAudio: true

we see the below warnings:

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

falling back to ArrayBuffer instantiation

if (J(),
    r.instantiateWasm)
        try {
            return r.instantiateWasm(e, t)
        } catch (e) {
            return p("Module.instantiateWasm callback failed with error: " + e),
            !1
        }
    (m || "function" != typeof WebAssembly.instantiateStreaming || te(L) || "function" != typeof fetch ? o(n) : fetch(L, {
            credentials: "same-origin"
        }).then((function(t) {
            return WebAssembly.instantiateStreaming(t, e).then(n, (function(e) {
                return p("wasm streaming compile failed: " + e),
                p("falling back to ArrayBuffer instantiation"),
                o(n)
            }
            ))
        }

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

Aborted(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 64 6f @+0)

Can we get some advice on what this is and the effect this may have?

Thanks.

FabienLavocat commented 10 months ago

@slicertech where are you loading the wasm files from? (vsl_impl.wasm, dapm_impl.wasm, dvdnr.wasm, dvwc_impl.wasm) This error comes from the web browser preventing the Wed Assembly libraries from being loaded if they were not loaded from a secure / trusted place. In your case, the MIME type of the files that are downloaded must be application/wasm. This seems like an update you can make on the backend that serves the files.

slicertech commented 10 months ago

Hi @FabienLavocat , Thanks for the reply. If I grep for WASM in our code base, I find the file here:

*/node_modules/@voxeet/voxeet-web-sdk/dist/vsl_impl.wasm

We serve our react application via AWS S3 and Cloudfront. I found this guide: https://arne.xyz/2020/08/21/aws-s3-cloudfront-unity3d-webgl/ So I am trying to find where the *.wasm files are hosted.

FabienLavocat commented 10 months ago

You need to copy all the files from the dist folder in your application directory. If you're using WebPack, here's an example: https://github.com/dolbyio-samples/dolbyio-web-file-presentation-service/blob/main/webpack.config.js#L32C1-L40C12

slicertech commented 10 months ago

Thanks, @FabienLavocat, I will try this and get back to you. We are just waiting for a chance to test our changes.

FabienLavocat commented 9 months ago

I'm going to close this issue for now, if you still have questions, don't hesitate to reach out.

slicertech commented 9 months ago

Hi @FabienLavocat ,

Apologies, I just got to test my code. I am still getting the issue. I copied this: https://github.com/dolbyio-samples/dolbyio-web-file-presentation-service/blob/main/webpack.config.js#L32C1-L40C12

new CopyWebpackPlugin({ patterns: [ { from: './node_modules/@voxeet/voxeet-web-sdk/dist/dvwc_impl.wasm', noErrorOnMissing: true, }, { from: './node_modules/@voxeet/voxeet-web-sdk/dist/voxeet-dvwc-worker.js', noErrorOnMissing: true, }, { from: './node_modules/@voxeet/voxeet-web-sdk/dist/voxeet-worklet.js', noErrorOnMissing: true, }, { from: './node_modules/@voxeet/voxeet-web-sdk/dist/vsl_impl.bin', noErrorOnMissing: true, }, { from: './node_modules/@voxeet/voxeet-web-sdk/dist/vsl_impl.wasm', noErrorOnMissing: true, }, ], }),

Still the same issue.

slicertech commented 9 months ago

In our build file:

rw-r--r--@ 1 jg staff 5442 12 Dec 13:11 asset-manifest.json drwxr-xr-x@ 11 jg staff 352 12 Dec 13:10 customers -rw-r--r--@ 1 jg staff 2997945 12 Dec 13:11 dvwc_impl.wasm -rw-r--r--@ 1 jg staff 1047 12 Dec 13:10 favicon.ico -rw-r--r--@ 1 jg staff 54915 12 Dec 13:10 gamecastsdk-0.1.0.min.js -rw-r--r--@ 1 jg staff 2118 12 Dec 13:11 index.html -rw-r--r--@ 1 jg staff 34769 12 Dec 13:10 logo192.png -rw-r--r--@ 1 jg staff 121199 12 Dec 13:10 logo512.png -rw-r--r--@ 1 jg staff 504 12 Dec 13:10 manifest.json -rw-r--r--@ 1 jg staff 67 12 Dec 13:10 robots.txt drwxr-xr-x@ 5 jg staff 160 12 Dec 13:11 static -rw-r--r--@ 1 jg staff 933 12 Dec 13:10 videoPlayer.html -rw-r--r--@ 1 jg staff 176341 12 Dec 13:11 voxeet-dvwc-worker.js -rw-r--r--@ 1 jg staff 13801 12 Dec 13:11 voxeet-worklet.js -rw-r--r--@ 1 jg staff 508384 12 Dec 13:11 vsl_impl.bin -rw-r--r--@ 1 jg staff 1771142 12 Dec 13:11 vsl_impl.wasm

FabienLavocat commented 9 months ago

Could you please share the Network tab of the web console from Chrome. I'd like to see the failing requests. Also, make sure your server know the mime type application/wasm.

slicertech commented 9 months ago
Screenshot 2023-12-13 at 14 14 39 Screenshot 2023-12-13 at 14 14 53 Screenshot 2023-12-13 at 14 18 11 Screenshot 2023-12-13 at 14 18 25
slicertech commented 9 months ago

Do I need to make server changes? I found this: https://arne.xyz/2020/08/21/aws-s3-cloudfront-unity3d-webgl/ ?

FabienLavocat commented 9 months ago

The problem is described in the link you shared.

.wasm, .wasm.gz or .wasm.br files should be served with a Content-Type: application/wasm response header.

Since you run this website locally (at least in the screenshots), you need to add the mime type to your local computer.

slicertech commented 9 months ago

I will take a look and get report back

slicertech commented 9 months ago

Screenshot 2023-12-15 at 11 12 25 Screenshot 2023-12-15 at 11 13 31 Screenshot 2023-12-15 at 11 13 39

slicertech commented 9 months ago

@FabienLavocat deployed my changes to AWS S3 bucket. As you can see, the files have been copied to the base path. If I look in AWS, the *.wasm files have the correct content-type.

Thoughts?

FabienLavocat commented 9 months ago

You should check your network tab, the log entry says that it's not returned as "application/wasm".

slicertech commented 8 months ago

@FabienLavocat can you tell me where dapm_impl.wasm comes from? That looks to be the offending file. This was not in the list of files to be copied to the base path.

FabienLavocat commented 8 months ago

https://github.com/voxeet/voxeet-sdk-web/blob/master/dvwc_impl.wasm The file is in both this GitHub repo and NPM package. You should indeed copy this file to your project (or S3 bucket).

slicertech commented 8 months ago

Hi @FabienLavocat , OK, progress. I added the file above and also moved the files to the correct folder. Now, the WASM files load correctly. I now see this new error :-)

Screenshot 2024-01-03 at 14 13 36 Screenshot 2024-01-03 at 14 13 46 Screenshot 2024-01-03 at 14 13 58

Any help here?

FabienLavocat commented 8 months ago

Do you have this file audio_dnr.bin on your S3 storage? Make sure all the files from the NPM package are copied over.

slicertech commented 8 months ago

Hey @FabienLavocat ,

So all the files in node_modules/@voxeet/voxeet-web-sdk/dist should be copied over?

FabienLavocat commented 8 months ago

Yes

slicertech commented 8 months ago

@FabienLavocat OK that has fixed most of the issues :-) thanks!

The last warning that shows is: INFO: Created TensorFlow Lite XNNPACK delegate for CPU. (dapm_impl.wasm?2febc590a084ffcb3bb2bfb2b8da4a15:0x446c6 INFO: Created TensorFlow Lite XNNPACK delegate for CPU.)

I don't think this is an issue.

FabienLavocat commented 8 months ago

It's an INFO, everything is good there.