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

Webworker imports generate error because of absence of window #1433

Open
orabazu opened this issue Nov 20, 2022 · 0 comments
Open

Webworker imports generate error because of absence of window #1433

orabazu opened this issue Nov 20, 2022 · 0 comments

Comments

@orabazu
Copy link

orabazu commented Nov 20, 2022

🌈Hey ml5 community 🌈

β†’ Step 1: Describe the issue πŸ“

While i was trying to load ml5 via a webworker I am getting an error message due to absence of window. Since webworkers provide an isolated environment it has no access to window or other web apis. Isn't there a way to make it export without being dependent on window object. I am using a K-means classifier but it freezes the browser for 2-7 secs dependent on the case. Initial idea was using a webworker to prevent freezing of UI Thread. Do you have any suggestion or a work around for this?

β†’ Step 2: Screenshots or Relevant Documentation πŸ–Ό

Error due to absence of window inside web worker

Screen Shot 2022-11-20 at 13 45 23

β†’ Step 3: Share an example of the issue πŸ¦„

Trying to import like this using webpack. Imports work fine with other libraries such as antd
ml-worker.js

import ml5 from 'ml5';

self.onmessage = ({ data: { question } }) => {
  console.log(question);
  console.log(ml5.version);
  self.postMessage({
    answer: 1, // TODO: replace with ml5
  });
};

export default null;

β†’ Describe your setup πŸ¦„

Here's some helpful information about my setup...

  • Chrome Version 107.0.5304.110 (Official Build) (arm64):
  • macos big sur 11.6.5:
  • ml5: 0.12.2:
@orabazu orabazu changed the title Webworker imports generate error because of absence ofwindow Webworker imports generate error because of absence of window Nov 20, 2022
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

1 participant