SerenityOS / serenity

The Serenity Operating System 🐞
https://serenityos.org
BSD 2-Clause "Simplified" License
30.69k stars 3.19k forks source link

Ladybird: WebContent remains as a zombie process in certain scenarios #23729

Open kuchikuu opened 7 months ago

kuchikuu commented 7 months ago

Issue: WebContent may remain present after closing Ladybird.

Reproducing difficulty: Very easy with certain websites

HEAD at testing time: commit 41cc8e75f2087d61bb56930136e268e32ddb1bf0 (HEAD -> master, origin/master, origin/HEAD) (As as a reference when was this tested)

When it does not happen:

When it does happen:

Suggested conditions required for the bug to happen:

  1. The browser must be busy with something
  2. The webpage must be very complex or broken

In order for 1) to happen: 1) Open a webpage 2) Wait for it to load + give it a few seconds to stay idle 3) Start clicking everywhere, spamming F5 etc 4) Quickly close the browser using File -> Quit or the X button 5) Ladybird closes, but WebContent becomes a zombie process

Demonstration: (Disclaimer: Mojeek is a relatively lightweight page. It is hard to make Ladybird busy with it, but it does work)

https://github.com/SerenityOS/serenity/assets/48770967/6e03d183-05b8-4e67-bb60-e7a3c891b7e9

In order for 2) to happen: 1) Load something broken, like for example https://duolingo.com or complex like https://adilene.net/ 2) Wait like 10-15 seconds (You don't even need to spam anything, just wait) 3) So far 99,999% of the time closing the browser at this stage will result in WebContent becoming a zombie process.

Exaggerated demonstration:

https://github.com/SerenityOS/serenity/assets/48770967/14ef8eb0-f009-4e6e-8786-23d5dc9b8920

And here is a small comparison: One browser is closed with File -> Quit and leaves a zombie process, the other is closed using CTRL+C in the terminal and that does not leave any zombie process.

https://github.com/SerenityOS/serenity/assets/48770967/6025f6c8-420e-4939-a902-0139d2a31eb8

ADKaster commented 7 months ago

I ran into this while implementing a process viewer/task manager for Ladybird. It seems like we have some really invalid assumptions about what will happen to the other side of unix sockets when we close the UI process.

Phantop commented 7 months ago

Can affirm this happening to me quite often—the vestigial WebContent process always will fully utilize a CPU core which is somewhat annoying on a laptop alas.