Utilize a single WebAssembly instance within two separate Web Workers

After compiling a wasm file from golang (version 1.3.5), I noticed that certain functions using goroutines are not supported. When these functions are called, they run in the current thread and slow down my worker significantly.

To address this issue, I would like to create a worker within my current worker to execute the function in question in a multi-threaded manner.

I'm currently utilizing webpack's worker-loader to build my web worker.

My main query is whether it's possible to share a WebAssembly instance between two web workers?

Answer №1

Sharing WebAssembly instances between workers is not supported at the moment. However, you can create the same module on multiple workers and share memory using a SharedArrayBuffer. This method is commonly used by emscripten for implementing pthreads.

Keep in mind that this approach will only function properly on browsers that support SharedArrayBuffers and have implemented the WebAssembly threads proposal.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

"Automating the process of toggling the edit mode of a contenteditable element – how is

Is there a specific event I can use to programmatically start or stop editing a contenteditable element, similar to when the user focuses or blurs it? I have tried using .focus(), .click(), and even setting the selection to its content, but none of them se ...

Unable to modify the appearance of an HTML element when injected via a Chrome extension

I am currently developing a unique chrome extension that uses Ajax to inject custom HTML into the current tab. This extension appends a <div> element to the body, and now I need to manipulate it using JavaScript. Specifically, I want it to dynamical ...

What potential problem is arising from Jest's use of "transformIgnorePatterns" and how does it impact importing scoped CSS in a React application?

Currently facing a challenge with Jest testing in my React application following the addition of transformIgnorePatterns to the Jest settings. The default settings I included in the "jest" section of the root package.json file are as follows: "transfo ...

Limiting the dropdown results in v-autocomplete: A simple guide

Image Link After receiving 100-200 results from the axios api, I am looking for a way to display only the first 10 items. However, I also need to show the total count of all items retrieved. Unfortunately, this cannot be achieved directly from the api call ...

Connecting VueJS with Firebase: Syncing authentication keys with users collection

When using VueJS, my goal is to establish a collection within the Firebase database named users. This particular collection will contain relevant data for users who have successfully authenticated themselves. The unique identifier (id) of each authentica ...

The mistake is indicating the npm title of a package that is not present

https://i.sstatic.net/5bywN.png An issue has arisen - the module cannot be found, even though such a module does not actually exist. The correct module name should be babel-plugin-proposal-class-properties (and the error is showing as 'babel-plugin-t ...

Oops! There seems to be a mistake - the provider setPageProvider is not recognized

Struggling to implement pagination on my page using the AngularJS framework. Encountering the error Error: [$injector:unpr] Unknown provider: setPageProvider <- setPage. Despite rearranging the code, the issue persists. Attempted following a tutorial fr ...

Issue when attempting to update user profile picture using Mongoose schema and Cloudinary

updateProfile: async function(req, res) { try { const update = req.body; const id = req.params.id; if (!req.files || Object.keys(req.files).length === 0) { return res.status(400).send('No files were uploaded.&a ...

What is the best way to retrieve data from multi-dimensional JSON structures?

Looking to extract specific values from my JSON file. console.log( objects.assignments.header.report_type ); I need to display HOMEWORK Javascript $.ajax({ url: "/BIM/rest/report/assignment", type: "POST", dataTyp ...

Generate a one-of-a-kind geometric shape by combining a sphere and a cylinder in Three.js

I'm currently working on creating a unique bead-like object using Three.js, specifically a sphere with a cylinder passing through it. While I can create these two components individually, I'm struggling to match the heights of the sphere and cyli ...

Indicate the end of the row in JavaScript when using the match() function

What's the best way to identify the end of a row when using the match() function? I'm trying to extract "2021 JANUARY 18 MONDAY" from this page. If there is additional text after the desired string, I typically use this code: var content = UrlFe ...

Displaying dynamic content in JavaScript using Galleria module

Hello and thank you for taking the time to check out my question. I've encountered a little issue that I can't seem to solve by myself. I'm hoping someone could lend me a hand. On my website, there is a dynamic field filled with a code from ...

The loading feature fails to activate when attempting to execute a function

I recently encountered an issue with my loading effect code implementation. It appears that the loading effect does not work when I click the button, but it works perfectly fine without the function running. The function seems to interfere with the loadi ...

Experiencing a Number TypeError Issue with Mongoose Schema?

The server encountered a 500 internal error with the message: Error: TypeError: path must be a string The specific line causing the error in ItemCtrl.js is line 35. console.log('Error: ' + data); The stack trace for this error is as follows: ...

Is it possible to retrieve the original array after removing filters in Angular?

Within my component, I have an array that I am filtering based on a search string. The filtering works as expected when the user inputs characters into the search field. However, I am encountering an issue when attempting to display all records again after ...

Converting JavaScript CanvasRenderingContext2D states array into a serialized format

Looking for a way to serialize a canvas' state in order to save it to a database for later restoration. Want to store the data as an object rather than a bitmap file. I've tried using .save() and .restore() on the context object, but they only m ...

Activate the Jquery-ui Tooltip with a click event

Here is the code I'm using: function DrawTipsProgress(postid, ajaxurl) { var data = { action: 'ajax_action', post_id: postid } jQuery('#dashicon-' + postid).on("click", function () { jQuery.p ...

"Use casperjs to click on a variable instead of a specific selector

Is there a way to interact with a page element in CasperJS without specifying a selector? For example, instead of using: casperjs.thenClick('#test'); I have the variable: var testV = document.querySelector('#test'); And I would like ...

Using React to Filter cards according to the selected value from an Autocomplete feature

I'm currently developing a React application that utilizes Material-UI's Autocomplete component to filter cards based on selected car brands. These cards represent various models, and the goal is to update them when a user picks a brand from the ...

Add array as an element within another array

After initializing the data, I have an object structured like this and I am able to push data using the method below: myObj = { 1: ["a", "b", "c"], 2: ["c", "d", "e"], } data: { types: {} }, methods: { pushValue(key, value) { var ...