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

fix: WASM MIME type error by specifying it in Info.plist template #1374

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

michaelkamphausen
Copy link
Contributor

Platforms affected

iOS

Motivation and Context

Fixes #1370 where WebAssembly cannot be loaded in iOS production build due to the error "Unexpected response MIME type. Expected 'application/wasm'". The error causes a blank app screen and prevents any user interaction.

Description

I added UTExportedTypeDeclarations to the Info.plist template file, specifying the expected MIME type for loading WASM files.

Testing

I modified my project's Info.plist file by adding the UTExportedTypeDeclarations key and value as shown in the commit, built and ran my project on the device, and verified that the app loads and is displayed as expected.

The automated tests don't run on my macOS version as it does not match CordovaLibTests’s deployment target. I don't know how to get the tests running.

Checklist

  • I've run the tests to see all new and existing tests pass
  • I added automated test coverage as appropriate for this change
  • Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • I've updated the documentation if necessary

@codecov-commenter
Copy link

codecov-commenter commented Sep 28, 2023

Codecov Report

Merging #1374 (f10ee32) into master (a1f3ace) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #1374   +/-   ##
=======================================
  Coverage   78.25%   78.25%           
=======================================
  Files          15       15           
  Lines        1789     1789           
=======================================
  Hits         1400     1400           
  Misses        389      389           

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -45,5 +45,25 @@
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UTExportedTypeDeclarations</key>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious if this also works if you use UTImportedTypeDeclarations as the key

I don't think we want to declare all Cordova apps as owners of the WebAssembly file type by default, so UTExportedTypeDeclarations seems like it might be the wrong key to use. Even with that though, I think injecting this when needed using config-file in config.xml for your app is probably a better choice that unconditionally including this declaration in the template for all Cordova apps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your idea of using UTImportedTypeDeclarations key instead! I tested it and I can confirm that it works as well.

I understand there are differing views on whether loading WebAssembly code should be supported by default or only when needed.

I would argue for making this a default because I assume quite a few developers will be unaware of the problem until it suddenly occurs in their Testflight or release build. The cause is not easy to find, because the problem does not seem to occur in debug builds, which makes debugging difficult. This could be confusing and will cost time. At the same time, I don't see any downside how the UTImportedTypeDeclarations entry could cause problems.

Nevertheless, at least the documentation should point out the WASM loading error in release builds and explain how to fix it when needed using config-file in config.xml.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe it's optimistic, but it would be great if we could have a script to detect if the code is using WASM or not, then warn users to enable usage of WASM in config.xml. But for now this could be enough to somehow easily enable WASM support in config.xml. Putting all those config lines in config.xml is not a minimal way to enable WASM. Maybe a boolean preference like EnableWASM makes sense.

<preference name="EnableWASM" value="true" />

@dpogue dpogue added this to the 7.1.0 milestone Mar 6, 2024
@erisu erisu changed the title (ios) fixes WASM MIME type error by specifying it in Info.plist template fix: WASM MIME type error by specifying it in Info.plist template Mar 6, 2024
Copy link
Member

@erisu erisu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@erisu erisu merged commit 902df96 into apache:master Mar 6, 2024
ishiguro-m-wing added a commit to dejiren/cordova-ios that referenced this pull request Mar 29, 2024
This reverts commit 1974dbb.

Revert "feat: add privacy-manifest config support (apache#1406)"

This reverts commit c97845a.

Revert "ci(gh-action): add Apache RAT & package license checker workflow w/ license header additions (apache#1408)"

This reverts commit d316558.

Revert "fix: use PROVISIONING_PROFILE_SPECIFIER for manual codesigning (apache#1405)"

This reverts commit af6335e.

Revert "feat: add PrivacyInfo.xcprivacy for CordovaLib & app template (apache#1383)"

This reverts commit b400b70.

Revert "fix: WASM MIME type error by specifying it in Info.plist template (apache#1374)"

This reverts commit 902df96.

Revert "chore: update package & package-lock (apache#1404)"

This reverts commit 2091208.

Revert "chore: bump 7.1.0-dev for next minor release (apache#1403)"

This reverts commit 766adcf.

Revert "chore(deps-dev): bump @babel/traverse from 7.21.4 to 7.23.2 (apache#1382)"

This reverts commit 92017bb.

Revert "chore: Update Slack signup link in SUPPORT_QUESTION.md (apache#1380)"

This reverts commit be4c884.

Revert "chore: bump version 7.0.2-dev"

This reverts commit a1f3ace.
ishiguro-m-wing pushed a commit to dejiren/cordova-ios that referenced this pull request Mar 29, 2024
…ache#1374)

* (ios) fixes WASM MIME type error by specifying it in Info.plist template
* changed key to UTImportedTypeDeclarations as we don't want to declare WebAssembly file ownership
@michaelkamphausen michaelkamphausen deleted the wasm-mime-type branch September 5, 2024 16:18
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

Successfully merging this pull request may close these issues.

wasm MIME type is not supported
5 participants