Initialize SharedWorker in its own process?

46 Views Asked by At

I'm working on a web app that needs to load very large datasets on the browser, additionally, I also need to load a lot of data on a SharedWorker.

The current browsers (Chrome?) limitations set a limit of around 8GB of used memory for a single process/tab.

My app makes use of different windows (one for each computer's screen) and each of them is open with the noopener attribute to ensure a dedicated process is used. This allows each window to use 8GB rather than sharing the limit across pages.

Now I would need to also do the same for the SharedWorker, currently it shares the limits with whatever page spawns it.

The only solution I found is to open a noopener popup, spawn the SharedWorker, and then close the popup. But this is very intrusive for the user.

I tried to use sandboxed iframes but as soon I add the allow-same-origin directive the iframe starts sharing the process with its parent window.

Is anyone aware of any other solution to this problem?

1

There are 1 best solutions below

0
Jerico On

I went through some of my own apps and saw that the way I went around this
or what I did similarly working with Chrome, was by creating a new window and creating an iframe running on that. (which I know you don't want but is kinda hard to do without) If you could create 2 pages with half the data running on one and then the rest on the other page could work too. Another solution I somewhat tested but don't know if it fully works is loading the first round of data and placing it into your DOM (Assuming you have HTML or some kinda of generator), closing your noopener and sharedWorker or serviceWorker as you said, and then loading the other half after the first half is done loading (Creating or initializing a second sharedWorker or getting more data.). You could potentially do that like I was doing through a small chain of functions.

Note: I assumed you have a DOM because Chrome apps have some sort of HTML or DOM most of the time.

Hope this Comment if you somewhat get the idea or need further knowledge :)