Closed pulsejet closed 4 years ago
Hmm, looking at the demo in that link, that wasm at least is not optimized, wasm-opt -O
shrinks it by 40%.
Running wasm-opt -O
on the original and optimized wasm, the optimized one takes half the time and memory. It's possible a wasm VM would have a similar pattern. So if Safari is close to the memory limit, the wasm being unoptimized might make it fail.
Still, it's not a huge wasm file, just 1MB (600K optimized), so it is surprising it OOMs on WebKit, might be worth filing a bug there.
As for why it works for a while and then crashes, one possibility is that it starts up in their low tier compiler which uses little memory. Meanwhile it runs the full compiler in the background. When that OOMs, it brings the whole thing down.
I would think this isn't related to wasm optimization, since I have the exact same issue with the game engine I am porting (mkxp), using O3
for everything. I tried this on two devices, and strangely enough, I can reproduce the issue for the linked project every time on an iPad 5 only intermittently on an iPad 6. The game crashes consistently on both devices though.
I also do have a JetsamEvent emitted for each crash; iOS noob here but I think this means jetsam is killing the tab sensing a memleak? Not sure how/where to report this.
P.S. @kripken you and your work have been an inspiration for me in many different ways. Thanks and it is an honor to get a reply from you 😅
I'd report it on the WebKit tracker - the real solution may be for their compiler to use less memory somehow, or not fire up the full optimizing compiler when not enough memory is available.
Reported this to Apple; fixed in iOS 14 beta 1. Thanks again @kripken!
Building mruby (for any optimization level) mysteriously crashes iOS Safari 13 on my iPad after a few seconds, apparently because it runs out of memory. I have profiled it on chrome desktop and there are no memory leaks. It does work initially, but after around 5-10 seconds, the tab just crashes. Any pointers?
The demo for this project compiling mruby to wasm also crashes.