Main process or renderer process


#1

I still don’t quite get the difference between the main process and the renderer processes: For instance, if I wanted to make a calculator app that has two windows (one for the input of the calculation and the other one for the output), where would I perform the actual calculation. I would think in the main process, as the renderer processes are only responsible for their respective windows, but calculating the result is something both windows are involved in. But then again, the main process is only responsible for managing the different windows, right? Do I need to make a whole other JS file that is responsible for the inner workings of the app?


#2

Let’s say The Main process is supporting full set of APIs and it acts like Node.js process which is the main entry point of the app. However, it does not have ability to show the UI or Views.

The UI/Views will be running in Renderer process with less features and more restricted since it is only for showing the UI and Javascript as in standard browsers with few more additional electron APIs. when you create BrowserWindow, the renderer process will be created to host that webpage.

If you would like to do the calculation in purely JavaScript, it can be either on Renderer or Main process as long as you don’t need some set of APIs which only available under main process for ex, retrieve system info, accessing directly to database or files.

for your example of 2 windows of calculator app. they are both running in renderer processes.

Hope this help.


#3

Render process is your UI/webview
Below link may clarify more https://medium.com/@ccnokes/deep-dive-into-electrons-main-and-renderer-processes-7a9599d5c9e2