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

SharedArrayBuffer error #1

Open
mgerhardy opened this issue Mar 6, 2023 · 2 comments
Open

SharedArrayBuffer error #1

mgerhardy opened this issue Mar 6, 2023 · 2 comments

Comments

@mgerhardy
Copy link

mgerhardy commented Mar 6, 2023

I am compiling my code with emscripten pthread support and get this error.

Uncaught TypeError: Blob constructor: ArrayBufferView branch of ((ArrayBufferView
or ArrayBuffer) or Blob or USVString) can't be a SharedArrayBuffer or an
ArrayBufferView backed by a SharedArrayBuffer

Caused by this line:

  a.href = URL.createObjectURL(new Blob([new Uint8Array(Module["HEAPU8"].buffer, 
           buffer, buffer_size)], {type: UTF8ToString(mime_type)}));
@mgerhardy
Copy link
Author

mgerhardy commented Mar 11, 2023

here is the fix for download (upload doesn't need to be fixed) - first copy into an ArrayBuffer and then use that one.

  /// Offer a buffer in memory as a file to download, specifying download filename and mime type
  var a = document.createElement('a');
  a.download = UTF8ToString(filename);
  var bufferCopy = new ArrayBuffer(buffer_size);
  var uint8Array = new Uint8Array(bufferCopy);
  uint8Array.set(new Uint8Array(Module["HEAPU8"].buffer, buffer, buffer_size));
  a.href = URL.createObjectURL(new Blob([uint8Array], {type: UTF8ToString(mime_type)}));
  a.click();

@themancalledjakob
Copy link

nice, this worked for me as well.

I had a slightly different error (maybe just wording?)

Uncaught TypeError: Failed to construct 'Blob': The provided ArrayBufferView value must not be shared.

any reason why this shouldn't be adjusted in the repo?

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