Coder Social home page Coder Social logo

Comments (7)

Murderlon avatar Murderlon commented on June 20, 2024 2

I don't think it's very feasible. Web workers don't have DOM access, so all our UIs are already problematic. There are also many event listeners in an uploader which can't be set, such as drag & drop but also checks so see whether you are online. I'm not sure you can even read out a file input from a web worker. All our remote providers, which require OAuth flows, wouldn't work either.

It's not as simple as replacing two instances of window to globalThis. Perhaps it could be possible to run only @uppy/core and @uppy/xhr-upload, but if you need any feedback to the user you would have to write some communication between the threads and build a new UI based on those events, rather than uppy events.

from uppy.

Murderlon avatar Murderlon commented on June 20, 2024 2

I would accept a PR which replaces the window instances to globalThis to make a minimal use case workable for you. But I don't think we can make all of Uppy workable in web workers.

from uppy.

Murderlon avatar Murderlon commented on June 20, 2024

This is a XY Problem, why would you want to run Uppy from a web worker?

from uppy.

AntonOfTheWoods avatar AntonOfTheWoods commented on June 20, 2024

I might be missing something. Is there some reason I wouldn't want to run it in a web/service worker? Are there some performance or technical issues I'm missing?
Particularly for offline-first usecases, having the option of organising one's code to make more use of workers can add freedom.

from uppy.

JammingBen avatar JammingBen commented on June 20, 2024

We recently attempted to run Uppy in a Web Worker and encountered the same issue. Our goal was to increase stability by offloading work from the main thread and to prevent issues caused by browser tab throttling when an upload is running in the background.

from uppy.

Murderlon avatar Murderlon commented on June 20, 2024

Closing this as I don't think we can do this at this point. Could've been interesting if you design an uploader from the start with this in mind (might play with this) but at this point I don't think we can with Uppy.

We can reopen if needed.

from uppy.

AntonOfTheWoods avatar AntonOfTheWoods commented on June 20, 2024

Thanks for the response but wow, it's also pretty disappointing. I saw uppy as modular and well-defined... The core and others like xhr and add-file don't seem to need any user interaction or interface, and I can't for the life of me understand why they need document at all. Obviously there is a good argument for stuff needing user interaction to just have window and be done with it but I really don't understand actively forcing window for parts of the application that don't need it... Obviously we can just try and hack a sed to replace but that is problematic with many libraries so you have to make sure it's only done on uppy. Particularly given my understanding is that all modern browsers will just treat globalThis as window in the window context, I'm not certain I see a downside... Maybe I'm just an idiot though...

from uppy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.