-
Notifications
You must be signed in to change notification settings - Fork 834
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
iOS mobile phone encountered "Failed to create memory" problem when loading .wasm #4343
Comments
It sounds like you are running into a limitation imposed by iOS, namely that programs aren't allowed to generate machine code at runtime and execute it. The reason you see the You may have some luck by pre-compiling the WebAssembly module on your own laptop and loading it with |
Hello, Interestingly, I am seeing the same issue on a project I'm working on right now. I have a solution that works for a "Full" iOS app, but not for an iOS App Clip. Some explanations:
Now, the problem with App Clips is that they have access to a subset of these capabilities, and "Extended Virtual Addressing" is obviously not one of them. I really need the wasm program to run as part of the App Clip too. I tried the Our wasm program is also pre-compiled (using Cranelift right now, trying LLVM soon). Would you have any ideas? |
As this is a pretty urgent blocker on my project (a blocker for iOS, as it runs fine on Android), I could propose to make an open-source iOS repository that reproduces this error? Maybe as a way for you to reproduce and maybe if you have some ideas around how to configure the wasmer VM differently? You would just need a MacOS machine to run that XCode project. |
Hello @Michael-F-Bryan I created an Open-Source project that reproduces the issue: https://github.com/oliveeyay/SwiftWasmer It uses some simple examples that you can launch through various buttons:
The last two examples are not working on iOS natively. Would you be able to help figure out this issue @Michael-F-Bryan ? |
Hey @oliveeyay, thanks for following up on the issue. I'd love to follow up with a meeting to see how we can help further (I assume you are doing this work as part of Solana?). Feel free to create a meeting in https://cal.com/syrus to follow up |
Hello @syrusakbary Thanks for the quick response! Yeah, that's part of one project at Solana indeed. Booked for tomorrow, thanks again. |
hi @oliveeyay Can you provide an oc project for your open source reproducible demonstration? I would be very grateful if you could take the time to provide it. |
hi @Michael-F-Bryan Have we released a new fixed version for this case? thanks |
Hey y'all, @zhangtianhao1230 @Michael-F-Bryan @syrusakbary After chatting with Syrus, I experimented with the
Here is a reproducer open source project that contains both solutions, alongside instructions on how to build etc.: https://github.com/oliveeyay/SwiftWasmer Additional note: since JIT-compiling is unofficially forbidden on iOS, I would advise you to use a headless mode with Wasmer (i.e. ahead of time compilation) to avoid issues with the approval process on the App Store. |
iOS is going to be supported in Wasmer 5.0, which introduces interpreters. We are in the process of merging the release PR into main; after that, users will be able to test and use wasmer on their iOS devices. |
Summary
iOS mobile phone encountered "Failed to create memory" problem when loading .wasm
Additional details
Provide any additional details here.
I tested the results of loading .wat and .wasm on an iOS phone based on the examples in the project "examples". The summary said that .wat could be loaded normally, but an error was encountered when loading .wasm.
let instance: Instance = match Instance::new(&mut store, &module, &import_object) { Ok(instance) => instance, Err(error) => { eprintln!("Instanc fail,Error: {:?}", error); return Err(anyhow::Error::new(error)); } };
When placed in an iOS project and executed, an error message "Link(Resource("Failed to create memory: Error when allocating memory: Cannot allocate memory (os error 12)"))"
What can I do to get rid of this error
The text was updated successfully, but these errors were encountered: