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

EMSCRIPTEN - RuntimeError: operation does not support unaligned accesses #884

Open
MichealReed opened this issue Aug 8, 2024 · 3 comments

Comments

@MichealReed
Copy link
Contributor

MichealReed commented Aug 8, 2024

Hey @mackron long time, hope all is well! I'm working on a PR DaniilAlpha/minisound#6 here to add recorder and generator support and on wasm, I see RuntimeError: operation does not support unaligned accesses. This appears to only happen some of the time when trying to play with multiple engines. You can find all the build files in the minisound_ffi/src folder of that PR.

The reproduction in Flutter Web:

  • Start the app.
  • Engine#1 initializes, loads a sound, and starts on the device.
  • Engine#2 and Engine#3 initialize but do not start.
  • Start then stop recording.
  • Click Play sound. (Engine#1)
  • Results in RuntimeError: operation does not support unaligned accesses.
  • Recording and waves continue to work. (Engine#2 and Engine#3)
  • Engine#1 when attempting to play the loaded sound continues to face the unaligned accesses error.

The recorder loads a sound the same way, but the engine keeps working without issue.

I can probably work around this with better handling of multiple engines in engine.c but wanted to let you know there might be an alignment issue with wasm, maybe a race condition with device?

Let me know what you think.

@MichealReed
Copy link
Contributor Author

"It only happens (was happen) ones the engine initialized a sound"

according to the original creator, so seems after one engine plays a sound the others cannot on emscripten but this is not true for WASAPI.

@mackron
Copy link
Owner

mackron commented Aug 8, 2024

Is there any additional information to narrow it down a bit? Hard to know exactly what's causing it. How are the sounds and engines being allocated?

On an unrelated note, the fact that you have more than one ma_engine is extremely unusual. I highly doubt having multiple engine's is causing this specific issue, but typically a program would have only a single ma_engine object. What's the rationale for having multiple engines?

@MichealReed
Copy link
Contributor Author

MichealReed commented Aug 9, 2024

Is there any additional information to narrow it down a bit? Hard to know exactly what's causing it. How are the sounds and engines being allocated?

On an unrelated note, the fact that you have more than one ma_engine is extremely unusual. I highly doubt having multiple engine's is causing this specific issue, but typically a program would have only a single ma_engine object. What's the rationale for having multiple engines?

It probably will not be needed and the only reason I discovered this is from an example. We have the engine, recorder, and generator as separate objects and in the example we spawn all three. Not pressing at all, will allow the main engine to be passed via constructor for our uses.

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

No branches or pull requests

2 participants