Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webxdc: .wasm files don't work #2635

Closed
WofWca opened this issue Aug 11, 2023 · 5 comments
Closed

webxdc: .wasm files don't work #2635

WofWca opened this issue Aug 11, 2023 · 5 comments

Comments

@WofWca
Copy link
Collaborator

WofWca commented Aug 11, 2023

I get this error:

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

Responsible code:

String mimeType = MimeTypeMap.getSingleton().getMimeTypeFromExtension(ext);
if (mimeType == null) {
switch (ext) {
case "js": mimeType = "text/javascript"; break;
default: mimeType = "application/octet-stream"; Log.i(TAG, "unknown mime type for " + rawUrl); break;
}
}
String encoding = mimeType.startsWith("text/")? "UTF-8" : null;
InputStream targetStream = new ByteArrayInputStream(blob);
res = new WebResourceResponse(mimeType, encoding, targetStream);

In DC Desktop there is no MIME type "white-list"
Here's the relevant Desktop code:
https://github.com/deltachat/deltachat-desktop/blob/5accdc9718ebd93461c38e346daa518e2096364f/src/main/deltachat/webxdc.ts#L145-L192

Test file (rename to .xdc): doom.zip

Related: webxdc/webxdc-test#15

@r10s
Copy link
Member

r10s commented Aug 11, 2023

In DC Desktop there is no MIME type "white-list"

imu, also on android, there is no "White List": it just seems as if getMimeTypeFromExtension() does not recognise the correct mime type and we do not post-fix that and return .wasm and .wat as application/octet-stream (what would be the correct type?)

for doom.zip: that also does not work in a browser (tested firefox/mac and chrome/mac) - if not yet done, we should also add a test for .wasm and .wat to webxdc-test (webxdc/webxdc-test#15 generates on the fly but does not referece a file)

@WofWca
Copy link
Collaborator Author

WofWca commented Aug 12, 2023

imu, also on android, there is no "White List"

Whoops, you're right, I missed the if condition.

for doom.zip: that also does not work in a browser

Huh? How did you test? It works for me, with python3 -m http.server.

what would be the correct type?

The error implies that it's supposed to be 'application/wasm', which is the case for python3 -m http.server.

@r10s
Copy link
Member

r10s commented Aug 12, 2023

Huh? How did you test? It works for me, with python3 -m http.server.

i just opened index.html from the .xdc in a browser - usually, that should work (maybe in this case not as again the mime type is wrong)

@r10s
Copy link
Member

r10s commented Aug 12, 2023

i created a pr, #2636, CI should create and .apk that can be used for testing.

as doom.xdc is too large, please also add a little thing to webxdc-test.xdc - the current test does not involve .wasm files - then we can also check this on iOS, on xmpp etc.

@r10s
Copy link
Member

r10s commented Aug 12, 2023

closed by #2636

for the missing test in webxdc-test i created webxdc/webxdc-test#20 and assigned @WofWca - @WofWca if you cannot add the test for whatever reason, please un-assign yourself

@r10s r10s closed this as completed Aug 12, 2023
WofWca added a commit to webxdc/webxdc-test that referenced this issue Aug 13, 2023
A potential gotcha is MIME type. See
deltachat/deltachat-android#2635

Closes #20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants