-
Notifications
You must be signed in to change notification settings - Fork 15.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blocking rendering on IPC is a bug? #12098
Comments
Thanks for reaching out! Because we treat our issues list as the team's backlog, we close issues that are questions since they don't represent a task needing to be completed. For most questions about Electron there are a lot of options. |
There are potential action items here, once some questions are answered. |
Related reading material from that twitter thread: https://medium.com/actualbudget/the-horror-of-blocking-electrons-main-process-351bf11a763c |
One possible way to make this better without touching/breaking too much code is to use node's ability to create IPC server via We can have both IPC implementations supported, but in the docs, we can encourage people to use newer node-based one unless they have very specific reason not to. If that will help, I can do a prototype with comparison of two IPC approaches |
In addition to Answering obvious question on why this should be in core and not in userland modules - I think electron should have a decent IPC that is truly non-blocking so it will benefit a lot of apps that receive a critique of being slow and unresponsive lately (sure, IPC is not always to blame, I get that). I'd be happy to work on the prototype/discuss API unless there are strong objections on such approach. |
Important note - we need to be very careful with permissions on such pipes, to make sure that (by default) pipes are readable/writeable only by app itself. Kudos to @paulcbetts for bringing that up |
If anyone wants to easily reproduce the issue, I made test app from
|
I'm really beginning to think this is a serious limitation of Electron's architecture that is relatively unknown and doesn't only show itself when explicitly calling IPC. For example we were doing currentWindow.getSize() inside of a throttled resize handler and it still completely locked the renderer while resizing a window, took a long time to realize what was going on. (That getSize uses IPC behind the scenes because it's remote) |
@YurySolovyov what would it look like to restrict permissions of the file to that specific app? How do you do that? I'm converting to a domain socket with websockets, but I'm not sure what the extra security would bring. If you can access the websocket file, you most likely can access the whole sqlite db that has all my app's data anyway. |
@jlongster I think you can set permissions for the pipe to be only readable/writeable by certain user or group just like you would for plain files. |
You can, but that doesn't restrict it to the app specifically. Unless you're storing encrypted data that is unencrypted at launch, I don't think permissions is really an issue. Anybody who can get to that file can probably just read your application data directly. |
I see. Not sure, but you may look at file locking ( |
I have another question - what can we do on Windows? I've implemented unix domain sockets on macOS but then realized that it won't work on Windows. What is a secure ICP mechanism on Windows? |
Node uses named pipes on win. They should work the same for the most part, the only difference is naming scheme/format. See https://nodejs.org/api/net.html#net_identifying_paths_for_ipc_connections |
Very nice, thanks! I am currently using the |
I think ws has the ability to listen on domain sockets. |
This no longer happens after electron 5.0 beta 3 AFAICT. Please reopen otherwise. |
@nitsakh do you know what changed to fix this? |
@nitsakh what process are you using to test? I may be looking at the wrong thing, but I'm think still seeing performance lag in 5.0.0-beta.5 similar to the results when testing in Electrons 3 and 4. I tested this using @magne4000's repro, enabled nodeIntegration and webviewTag to match 5.0's new defaults, then clicked the "start stress (main process)" button, then clicked between the |
@ckerr Completely blocking the main process is going to make the app freeze no matter what we do. This is the demo I made as an example of the renderer IPC changes in C73 https://gist.github.com/MarshallOfSound/6653351ec40c750e8c2a0336d0c6ed02 Run that gist in Fiddle for 3/4 and then |
Following this thread: https://twitter.com/NumaanAshraf/status/968496732278374400:
How to reproduce
I know this behaviour is due to some technical constraints, but shouldn't there be a way to not block main thread while handling IPC?
Or at least do the work in chunks.
This could be a major responsiveness booster for a lot of apps out there.
Can someone enumerate why is it the way it is?
Maybe this way we'll have some ideal for possible solutions to make it block less or not block at all?
The text was updated successfully, but these errors were encountered: