-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Compiling function #67 failed: Invalid opcode 0xfe (enable with --experimental-wasm-threads) #13152
Comments
This probably means that WebAssembly threading (and SharedArrayBuffer which it requires) is not enabled. Enabling SharedArrayBuffer outside of desktop chrome requires special HTTP headers. See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer#Security_requirements |
Oh, sorry, I see you are trying to build without USE_PTHREADS. In that case I think probably what is happening is that you are compiling some object files with atomics enabled ( Perhaps chrome for android does not yet support that feature? @tlively do you know the status? In which case the safest option is to find and remove any |
Maybe chrome for android dosn't support thread or atomics, can I add the options "-- disable-pthreads " to avoid this error ? emconfigure ./configure |
Hmm, it would be sad if Chrome on Android didn't support atomic instructions with unshared memories. @dtig, do you know what the status is there?
I agree that this is the best fix in the meantime. You could examine the output with |
I had added the flags "--disable-pthreads --disable-w32threads " yesterday. It can run on chrome mobile now,but it is inefficient. It will spent 50 ms to decode a h264 high profile frame. |
IIRC, this should be supported by default everywhere - this used to be behind a flag in the backend, but now should be enabled everywhere. I don't see anything specific to Android here, except perhaps an older Chrome version that does not support this? @schyjxy Could you update this thread with the version of Chrome you are currently using? |
Unfortunately just getting atomic operations to work on chrome mobile won't be enough to improve performance. You would need real threading support with SharedArrayBuffer and shared WebAssembly memories to see an improvement. I'm not sure what the timeline for supporting those on mobile looks like. |
I though that all worked now as long as you setup you http headers correctly: https://web.dev/coop-coep/. Am I wrong? |
@tlively Chrome for mobile(version 87.0.4280.101) is disabled by default, you can open url chrome://flags/ to enable WebAssembly threads support. |
@sbc100 SharedArrayBuffers are not available by default on Android, so that is probably the gating issue. From the Web.dev article linked, "Shared Array Buffer on Android Chrome will be available from Chrome 88.". |
It's a feasible measure to put the video code on a webworker. |
emscripten version 2.011
ffmpeg version 4.2.2, when the android brower load the wasm file, it print the error:
failed to asynchronously prepare wasm: CompileError: WebAssembly.instantiate(): Compiling function #67 failed: Invalid opcode 0xfe (enable with --experimental-wasm-threads) @+16226
this is my build scripts:
emcc -I "./include"
-O2
-s WASM=1
-lavcodec -lavformat -lavutil -lswscale
-s TOTAL_MEMORY=${TOTAL_MEMORY}
-L ./lib
-s ASSERTIONS=1
-s EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS}"
ffmpegTest.c
-s RESERVED_FUNCTION_POINTERS=14
-s ALLOW_MEMORY_GROWTH=1
-s USE_PTHREADS=0
-o ffmpeghelper.js
The text was updated successfully, but these errors were encountered: