-
-
Notifications
You must be signed in to change notification settings - Fork 235
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
WASM SIMD glitched on iPhone and crashes on iPad #312
Comments
Hello, thanks for reporting.
|
No, don't have access to MacOS devices.
I'll see what I can do. Maybe I'll get a minimal example working over the weekend... |
Same glitched output on an |
Other repositories seem to be experiencing similar issues. A minimal reproduction here would be great (e.g., expected vs. actual matrix values). Most operations in the "Update Camera" sequence are load/fmadd/splat/store, so it shouldn't be too difficult to debug (or cross-reference with some recent WebKit changes). |
I setup https://github.com/FrostKiwi/iOS-simd-bug to try and create a minimal reproduction, but failed. The issue seems to be more subtle than that. All devices give the same correct output. It's not the cglm calls, but a more delicate interaction. Just to be sure that I have not gone insane, I have disabled SIMD again on my WebApp via FrostKiwi/Mirrorball@c92cf22 and the issue is indeed gone. Maybe I'll try later again to nail down the specific line, which causes things to explode when SIMD is turned on... |
Are you compiling iOS-simd-bug w/ release or debug flags? With release the optimizer may be precomputing everything, e.g., At least from the perspective of It would also be nice to know if this issue reproduces on WebKitGTK ARM64. |
Good suggestion! I was indeed using -O3. Retried it with -O0, but the result is the same. So I'll retry next weekend to hunt down the reason. My guess was probably wrong and it may not even be the SIMD instructions generated by cglm cauing strange effects on iPhone. Might just be autovectorization. I'll go the other way next time, stripping down the webapp step-by-step instead. Also reconfirmed one more time: SIMD enabled = iPad ExceptionThrown and iPhone strange warping, SIMD disabled = iPad fine and iPhone fine. |
In my emscripten + C + WebGL project with cglm doing vector math, enabling SIMD via
-msimd128
produces broken floats, resulting in warping of the texture on screen, but only on an iPhone SE, iOS 16.4.1. On an iPad 9th gen, iOS 16.3.1, the WebApp straight up refuses to launch with SIMD active.Tested this behavior is browser independent, as both Safari and Edge are affected. According to https://webassembly.org/roadmap/, SIMD should work on these browsers.
Untitled.1.mp4
Since I'm still preparing my WebApp and don't expect users, I have purposefully left the WebApp in this broken state via commit FrostKiwi/Mirrorball@a065c5a#diff-76ed074a9305c04054cdebb9e9aad2d818052b07091de1f20cad0bbac34ffb52.
You can test this out live (until I revert SIMD usage in a week) by going to https://frostkiwi.github.io/frostorama/ clicking onReverted buggy SIMD again with FrostKiwi/Mirrorball@c92cf22Project image
and seeing the image glitch out, as opposed to having proper projection math applied on Android or a normal PC browser.I have not yet tracked down the specific line responsible, but highly suspect the vector operations from this line up to line 50 https://github.com/FrostKiwi/frostorama/blob/a065c5a7d62e3f89f2aed6a0e514134bd571cafe/src/render_loop.c#L22 . There are calculations happening preparing a Fullscreen quad to raytrace and passing these floats to a WebGL shader. I suspect, that enabling SIMD makes these calculations become invalid on the iPhone.
I was looking forward to enabling SIMD, since https://github.com/recp/cglm is purposefully designed to have WASM SIMD functions. However, I will have to revert the use of SIMD, since it breaks on iOS.
Version of emscripten/emsdk
Cross-posted this in the emscripten repo, since it affects that compiler directly as well: emscripten-core/emscripten#19619
The text was updated successfully, but these errors were encountered: