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

Transfer from a worker to the main thread doesn't work in browser. #454

Closed
LeonidPolukhin opened this issue Jun 20, 2024 · 3 comments
Closed

Comments

@LeonidPolukhin
Copy link
Contributor

LeonidPolukhin commented Jun 20, 2024

Worker returns Transfer object like

const array = new Float32Array(data);
return new workerpool.Transfer(array, [array.buffer]);

In worker.js:

if (result instanceof Transfer) { 
    worker.send({
        id: request.id,
        result: result.message,
        error: null
    }, result.transfer);
}

but worker.send (message) takes only one argument skipping transfer so no transferring happens. See worker.js: 27

  worker.send = function (message) {
    postMessage(message);
  };
@LeonidPolukhin LeonidPolukhin changed the title Transfer from a webworker to the main thread doesn't work in browser. Transfer from a worker to the main thread doesn't work in browser. Jun 20, 2024
@KonghaYao
Copy link
Contributor

@LeonidPolukhin 我同样遇到了这个问题,我将 workerpool 的版本改为 9.1.1 就可以正常运行了
"I encountered the same issue. I changed the version of workerpool to 9.1.1, and it runs normally now."

@josdejong
Copy link
Owner

@KonghaYao this should be fixed in v9.1.3 via PR #455. Can you elaborate?

@josdejong
Copy link
Owner

Closing due to a lack of response.

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

3 participants