Search code examples
google-chromebackground-processevaporate.js

Upload in chrome background tab


I am using evaporate to upload stuff to s3, and there's a lot of files to be uploaded. I really want this process to be seamless to the user. There's one problem though. Google Chrome has Throttle expensive background timers feature that drastically decreases the performance of the process.

I had a few ideas on how to handle this issue:

  • Ask the user to disable throttling for the tab. But I haven't found a way to do that for a specific tab and in some kind of Mobile permissions style. All you can do as a developer is show user a guide on how to do that by going to chrome://flags/#expensive-background-timer-throttling page and manually change the flag.
  • Playing a video/audio on the page is turning the throttling off according to the documentation. Seems hacky though :-\

I'd be glad to hear any advice on how to resolve this situation. Maybe somebody already faced the same problem and have some experience with it?


Solution

  • Web Workers solve the issue. You need to put all the code inside though. So, if you trigger heavy computation outside of the web worker - those triggerings WILL be throttled. If you trigger computations outside of the web worker - everything works fine.