I’ve spent the last two months working on an Electron app for personal knowledge repository which supports high quality PDF and HTML annotations.
Initially I was making steady progress but now I’m in a quagmire of IPC.
I think this is starting to look like an anti-pattern.
In one sense the multi-process model is great because apps are separated but if you’re in the SAME app you spend a ton of time thinking about maintaining and sharing state and passing messages back and forth between processes and windows.
Typescript makes things easier because you can at least type the messages so you have a good schema for what’s being sent but state and lifecycle become a huge problem.
What context is this code in? Renderer? Main? It’s hard to keep track.
What if you’re communicating between two windows? What if one of the windows vanishes? Do you restart it? How to you get that window to resume state?
You now have to maintain order to determine when the second window is open and when it’s ready to receive messages.
I mean I guess you could solve #2 and #3 by making your entire app crash if any of the windows are closed. You’re still stuck with IPC but maybe you could make it less hectic.
I think if the ‘window as an isolated process’ model were fixed this wouldn’t be as much of a problem. This way two renderer models could run in the same process.
Additionally, it seems silly for local apps to have two processes (main and renderer) if they’re just going to render and work with local content.
The model is inherited from the web world where it makes sense of course - just not much sense for our typical usage in a desktop model.
I’m not sure the main/renderer model could be broken though unless you embedded Node within Chromium…