3

Does anyone know if there is a way to force a new JavaScript thread for a new window?

I have an ExtJs application whose render steps are slaughtering user interaction. I can't toss the whole Ext application right now, so I've devised a way to make use of localStorage to manage passing events between browser windows and replacing a high activity data entry portion of the application with an Angular2 app spawned in a new window from the Ext app.

While things are performing wonderfully on the Angular2 side of things, when the parent window with the Ext application hangs during a render step, the window with the Angular2 application hangs as well causing users to lose keystrokes (which is bad).

Ideally being able to divorce the Angular2 app's JavaScript thread from the Ext one is what I would like to do.

Does anyone know if this is possible?

Sandwich
  • 61
  • 5
  • 1
    Why not just spawn a worker instead ? – adeneo Aug 08 '16 at 19:14
  • For which? A worker does me no good unless there is something I'm missing in how workers work? While the ExtJS app is in its render step it locks the main JS thread, which is the only thread that can interact with the DOM locking up both windows (aka data entry occurring in the other window). – Sandwich Aug 08 '16 at 19:26
  • Don't think there would be a cross-browser way to do it. Do note that if you were to do this while _I_ was browsing your site, I'd be really annoyed - I use Firefox and opening a new window seems to be terribly expensive for it (my addons don't seem to help) - opening a new window tends to cause all browser instances to hang for up to 10 seconds at a time. All because you thought `window.open` would _reduce_ the hanging. – VLAZ Aug 08 '16 at 19:28
  • This is a large enterprise ExtJS 4.2 single page application over PHP and RPG, not a consumer facing website. Sadly this _is_ more performant than performing the data entry in the actual application. – Sandwich Aug 08 '16 at 20:32

3 Answers3

0

Javascript is not a threaded language. But, there are some alternatives to use in order to run functions without blocking the UI. Most wide-spread solution is to make use of WindowTimer functions.

Read further upon it here: How can I create an Asynchronous function in Javascript?

Community
  • 1
  • 1
Ozan
  • 3,709
  • 2
  • 18
  • 23
  • JavaScript isn't a threaded language explicitly (excluding workers), [your browser will maintain different JS threads](http://stackoverflow.com/a/17169863/3508083), but if you're saying there is no way to force this in any browser that you're aware of I will accept your answer. – Sandwich Aug 08 '16 at 20:39
0

Actually it depends on browsers on how they want to tackle it.... Also depends on how you opened browser using what parameters. If the parent and child are coupled then it might be an issue. While if the parent and child are independent then you might have some help.

Check this answer https://stackoverflow.com/a/17169863/2219162

Community
  • 1
  • 1
Vinod Gubbala
  • 676
  • 6
  • 16
  • 1
    Yes, this is correct. The question is does anyone know of any way to _force_ a new thread in any browser? – Sandwich Aug 09 '16 at 12:33
0

There is no way to force a new JavaScript main thread for a new window.

Sandwich
  • 61
  • 5