Open Bug 1724337 Opened 3 years ago Updated 2 years ago

[meta] Improve browser shutdown handling in ProcessWatcher

Categories

(Core :: IPC, enhancement)

enhancement

Tracking

()

People

(Reporter: jld, Unassigned)

References

(Depends on 1 open bug)

Details

(Keywords: meta)

ProcessWatcher, the interface for handling child processes that should be terminating, has separate implementations for Windows and Unix, but the basic idea is:

  • if the force parameter is false, we'll wait indefinitely and block parent process shutdown; this is used for builds that need processes to exit normally for memory leak detection
  • if the force parameter is true, the process is forcefully terminated after a short (2s) timeout; this is used on release builds (and in ContentParent::KillHard in all cases)

But there are a some problems, and discussion on Matrix turned up some more:

  1. In the force == true case, if the parent exits while the timeout is pending, we don't try to kill the process or otherwise ensure that it isn't hanging.
  2. The hook used for “on shutdown”, MessageLoop::WillDestroyCurrentMessageLoop on the IPC I/O thread, generally doesn't happen on release builds: we terminate the parent process before that stage of shutdown. It's been suggested to use the xpcom-shutdown-threads observable instead, but that's async, which leads to:
  3. Blocking shutdown should use the nsIAsyncShutdown framework instead of actually blocking a thread.
  4. The timeouts use PendingTask via PostDelayedTask, which is deprecated; nsITimer should be used instead. (We also have DelayedRunnable which is built on nsITimer and appears to be the backend for PostDelayedTask if used on an XPCOM thread; this needs more investigation.)
  5. Related to the previous item, trying to post delayed tasks after XPCOM has shut down timer processing is unhelpful (and could possibly cause hangs in some cases?); moving the “on shutdown” point earlier by fixing item #2 would ensure that can't happen.

Item #1 is more of a defect than an enhancement, and I think it could be fixed without pulling in all of items #2/#3 by using a sufficiently early observer notification to kill any pending forced processes and leaving the shutdown blocking as it currently is. But ideally that whole cluster of issues should be fixed. Item #4 is somewhat separate and could possibly be left to whoever tries to get rid of the PendingTask machinery.

Maybe this would make more sense as a meta-bug, but mainly I wanted to get these things written down somewhere persistent.

Yes, I think we need this as meta bug. We see a series of intermittents where we apparently hang in WillDestroyCurrentMessageLoop. There are some sparse analysis here and there and I'd like to bring them all together here.

Keywords: meta
See Also: → 1719481, 1730374, 1742677, 1742271
Summary: Improve browser shutdown handling in ProcessWatcher → [meta] Improve browser shutdown handling in ProcessWatcher
Depends on: 1743362
Depends on: 1740529
See Also: → 1684441
See Also: → 961035
Blocks: 1791335
You need to log in before you can comment on or make changes to this bug.