Bug 280180

Summary: [GTK] WebKitWebProcess left running when WebView is freed
Product: WebKit Reporter: Milan Crha <mcrha>
Component: WebKitGTKAssignee: Nobody <webkit-unassigned>
Status: RESOLVED DUPLICATE    
Severity: Normal CC: bugs-noreply, mcatanzaro
Priority: P2    
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
reproducer (wk2.c) none

Description Milan Crha 2024-09-23 05:22:24 PDT
Created attachment 472638 [details]
reproducer (wk2.c)

Moving this from a downstream bug report:
https://gitlab.gnome.org/GNOME/evolution/-/issues/2855

In short, when a user moves between mails in Evolution, each newly showed mail adds a new WebKitWebProcess and leaves behind running "the previous" WebKitWebProcess. This is new in the WebKitGTK 2.46.0 release.

While it's much easier to reproduce under Evolution, I managed to reproduce something similar in an outside application (attached here). The first line contains how to compile and run it.

Steps:
1. run `./wk2` - one WebKitWebProcess (with *two* of its bwrap-s) are running
2. click on the "Add Web View" button - two  WebKitWebProcess-es (with *two* of its bwrap-s for each) are running
3. click on the "Reload" button near the bottom of the window - three  WebKitWebProcess-es (with *two* of its bwrap-s for each) are running
4. click the "X" button beside the "Reload" button - two  WebKitWebProcess-es (with *two* of its bwrap-s for each) are running

The test app shows which WebKitWebView-s had been created and when they are freed, confirming they do not leak.

I ran `ps ax | grep WebKitWebP` after each step and it shows this:

$ ps ax | grep WebKitWebP   (after step 1.)
   7192 pts/0    S+     0:00 /usr/bin/bwrap --args 129 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 16 121 120
   7193 pts/0    S+     0:00 /usr/bin/bwrap --args 129 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 16 121 120
   7194 pts/0    SLl+   0:00 /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 16 121 120
   7228 pts/1    S+     0:00 grep --color=auto WebKitWebP
$ ps ax | grep WebKitWebP   (after step 2.)
   7192 pts/0    S+     0:00 /usr/bin/bwrap --args 129 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 16 121 120
   7193 pts/0    S+     0:00 /usr/bin/bwrap --args 129 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 16 121 120
   7194 pts/0    SLl+   0:00 /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 16 121 120
   7231 pts/0    S+     0:00 /usr/bin/bwrap --args 139 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 26 131 133
   7232 pts/0    S+     0:00 /usr/bin/bwrap --args 139 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 26 131 133
   7233 pts/0    SLl+   0:00 /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 26 131 133
   7250 pts/1    S+     0:00 grep --color=auto WebKitWebP
$ ps ax | grep WebKitWebP   (after step 3.)
   7231 pts/0    S+     0:00 /usr/bin/bwrap --args 139 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 26 131 133
   7232 pts/0    S+     0:00 /usr/bin/bwrap --args 139 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 26 131 133
   7233 pts/0    SLl+   0:00 /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 26 131 133
   7253 pts/0    S+     0:00 /usr/bin/bwrap --args 142 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 33 133 136
   7254 pts/0    S+     0:00 /usr/bin/bwrap --args 142 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 33 133 136
   7255 pts/0    SLl+   0:00 /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 33 133 136
   7273 pts/0    S+     0:00 /usr/bin/bwrap --args 146 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 38 137 139
   7274 pts/0    S+     0:00 /usr/bin/bwrap --args 146 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 38 137 139
   7277 pts/0    SLl+   0:00 /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 38 137 139
   7289 pts/1    S+     0:00 grep --color=auto WebKitWebP
$ ps ax | grep WebKitWebP   (after step 4.)
   7253 pts/0    S+     0:00 /usr/bin/bwrap --args 142 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 33 133 136
   7254 pts/0    S+     0:00 /usr/bin/bwrap --args 142 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 33 133 136
   7255 pts/0    SLl+   0:00 /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 33 133 136
   7273 pts/0    S+     0:00 /usr/bin/bwrap --args 146 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 38 137 139
   7274 pts/0    S+     0:00 /usr/bin/bwrap --args 146 -- /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 38 137 139
   7277 pts/0    SLl+   0:00 /usr/libexec/webkit2gtk-4.1/WebKitWebProcess 38 137 139
   7294 pts/1    S+     0:00 grep --color=auto WebKitWebP
Comment 1 Michael Catanzaro 2024-09-23 05:56:49 PDT
Unfortunately I'm totally unable to reproduce this in Evolution, which makes it hard to help. I'll try running your test application, though, and let you know what I see in the other bug report.

*** This bug has been marked as a duplicate of bug 279914 ***