ServiceWorker: Fix crash during shutdown in single-process mode
In single-process mode, ServiceWorkerProcessManager::Shutdown() may end up being called
after the RenderProcessHost was deleted, as part of deleting the default browser context.
(which itself has to be destroyed after the RenderProcessHost since it's accessed during destruction)
RenderProcessHost::FromID() returns a nullptr in this case, which causes a segfault.
The crash is 100% reproducible after visiting youtube.com
, which seems to register a service worker.
This is happening at least with QtWebEngine in single-process mode, I haven't tested with Chromium's
own shell or other implementations with single-process support.
It might be specific to QtWebEngine's default browser context management too, in which case
any tips on how to fix the lifecycle issue on the QtWebEngine side is appreciated.
For reference, here's a link to the QtWebEngine change causing the default browser context to
be deleted after the RenderProcessHostImpl is deleted: