Bug 280631

Summary: [WPE][GTK] Add process monitor process and reenable web process suspend/resume
Product: WebKit Reporter: Michael Catanzaro <mcatanzaro>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: bugs-noreply, mcatanzaro, pgriffis
Priority: P2    
Version: Other   
Hardware: PC   
OS: Linux   
See Also: https://bugs.webkit.org/show_bug.cgi?id=280014

Michael Catanzaro
Reported 2024-09-30 12:52:43 PDT
In bug #280014 I disabled web process suspend/resume because it doesn't work robustly if the UI process crashes or is terminated uncleanly (e.g. using Ctrl+C). To bring this back, we need a new helper process to monitor all other WebKit auxiliary processes, which should be unlikely to crash and robust to SIGINT. The problem is that we currently rely on the web process to notice that its IPC socket to the UI process is closed, upon which it will quit. But if we have stopped the web process with SIGSTOP, then it's impossible for it to notice this condition, and it will just remain stopped forever. (Note that prior to 280061@main, bubblewrap sandbox would manage subprocesses, avoiding this problem. Bringing that back might make sense, if we could find some alternate solution for unsandboxed WebKit and flatpak sandbox.)
Attachments
Patrick Griffis
Comment 1 2026-06-08 16:50:01 PDT
I don't know that this directly fixes what you want, but I've played around with using cgroups to "freeze" processes like on Apple platforms: https://github.com/TingPing/WebKit/tree/pgriffis/process-freezing
Michael Catanzaro
Comment 2 2026-06-08 18:21:49 PDT
I mean: my complaint here is that suspended processes get leaked forever. As long as your implementation does not have that bug, then we should be good. I suggested a process monitor process because only I couldn't think of any other way to make this work. I didn't know you could do this using cgroups. Currently uresourced is responsible for putting web processes into cgroups, so it probably needs to be updated to accommodate your changes here. Probably it should just stop touching web processes if WebKit is going to do that itself.
Patrick Griffis
Comment 3 2026-06-09 13:01:40 PDT
OK, regarding the process leaking I think the same issue would apply here. How Apple handles it is that it's an external process managing the suspension. Which I guess is what we would need to do as well...
Patrick Griffis
Comment 4 2026-06-09 13:10:49 PDT
I believe this can be handled by `systemd`. 1. A TransientUnit is made for the UIProcess 2. When making a TransientUnit for the child processes, set `BindsTo=$parent` So when the UIProcess shuts down unexpectedly, all of the units bound to it are killed.
Michael Catanzaro
Comment 5 2026-06-09 13:16:37 PDT
Sure, but then you sabotage the watchdog thread to detect an out of control web process, which has been quite helpful for debugging hangs (especially in multimedia code). See again: 280061@main.
Patrick Griffis
Comment 6 2026-06-09 13:24:07 PDT
I'm not familiar with the watchdog but we can ask the child unit to cleanly stop or abandon it to remove it from systemd tracking entirely during shutdown.
Michael Catanzaro
Comment 7 2026-06-09 13:37:05 PDT
The watchdog thread is simple: crashAfter10Seconds in Source/WebKit/WebProcess/WebProcess.cpp.
Note You need to log in before you can comment on or make changes to this bug.