emscripten-core / emscripten-core/emscripten

Blob construction fails with pthreads enabled...

Open
#15,314 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Hello.
I spent quite lot of time trying to optimize jpeg/png images loading performance.
And found - that fastest way is to load images in JS code, not in C++.

But I load the images in C++, and then provide memory view to the JS code:
JS:
...
var imageData = Module.getImageData(nImage);
var image_url = URL.createObjectURL(new Blob([imageData], { type: mime }));

var image = new Image();
image.src = image_url;
image.onload = function()
...

C++
val getImageData(int imId)
{
...
Containers::ArrayView imageData = importer->imageData2D(imId);

return val(typed_memory_view(imageData.size(), imageData.data()));
}

This code works fine without pthreads.

But when pthreads are enabled - it crashed with this error:
exception thrown: TypeError: Failed to construct 'Blob': The provided ArrayBufferView value must not be shared.

Question is is there way to provide data to JS code without copying data requirements?

If I have to copy anyway - how to modify the code?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.