How does JS task scheduling between main process and renderer process work?


#1

The reason I ask is because the only way to share references to functions and other non-serializable references, between BrowserWindows and other things that contain webContents, is if those references live on the main-process global and they are accessed with Electron.remote.getGlobal().

It seems that all renderer processes’ JS event loops are tightly coupled to the main process (so if an infinite while loop freezes the main process, all renderer processes are also frozen).

It seems like this is needed in order to prevent race conditions. Because, if renderer processes could share references, then there’d be race conditions because their event loops are not in sync (and that would be bad).

So, I’m just curious, how does the event loop in the main process relate to the event loops in the renderer processes? Are the renderer process event loops controlled by the main process? Or something? Curious to have an overview of how that works.