RESOLVED FIXED 184445
[GTK][WPE] Race condition when destroying webprocesses
https://bugs.webkit.org/show_bug.cgi?id=184445
Summary [GTK][WPE] Race condition when destroying webprocesses
Miguel Gomez
Reported 2018-04-10 04:08:58 PDT
When a WebPageProxy gets destroyed, this is that ideally happens: * WebPageProxy::close() is called: * Sends a WebPage::Close() message to the webprocess, so it can properly close its page before shutting down the process * Calls WebProcessProxy::removeWebPage() which, in the end, closes the IPC connection to the webprocess * At the same time, when the webprocess executes WebPage::close() in response to the WebPage::Close() message * releases the page resources * at the end calls WebProcess::removeWebPage(), which causes the web process termination But there's the possibility that the webprocess never processes the WebPage::Close() message. This happens when it detects that the IPC connection has been closed before processing the message. In that case, the webprocess exits without properly closing its webpages, causing problems on situations where a proper deinitialization is required (for example deinitializing a hardware decoder used by the media player). We need to ensure that the WebPage instances owned by the WebProcess are always properly closed before exiting.
Attachments
Patch (1.53 KB, patch)
2018-04-10 06:23 PDT, Miguel Gomez
no flags
Patch (1.54 KB, patch)
2018-04-10 06:53 PDT, Miguel Gomez
no flags
Miguel Gomez
Comment 1 2018-04-10 05:15:15 PDT
One option to fix this could be making the WebPage::Close() message a sync one, and make the ui process wait for the web process to properly close before shutting down, but this would delay closing the browser and that is a problem for the Apple ports. So, if we cannot wait for the web process to end, we should ensure that it will close its WebPages on exit. The easiest way is to use the code that does that on debug inside WebProcess::didClose().
Carlos Garcia Campos
Comment 2 2018-04-10 05:37:49 PDT
(In reply to Miguel Gomez from comment #1) > One option to fix this could be making the WebPage::Close() message a sync > one, and make the ui process wait for the web process to properly close > before shutting down, but this would delay closing the browser and that is a > problem for the Apple ports. > > So, if we cannot wait for the web process to end, we should ensure that it > will close its WebPages on exit. The easiest way is to use the code that > does that on debug inside WebProcess::didClose(). Yes, I would move that part out of the debug ifdef, at least for GTK and WPE.
Miguel Gomez
Comment 3 2018-04-10 06:23:32 PDT
Miguel Gomez
Comment 4 2018-04-10 06:53:15 PDT
Carlos Garcia Campos
Comment 5 2018-04-10 08:11:04 PDT
Comment on attachment 337603 [details] Patch Ok, let's try with this.
WebKit Commit Bot
Comment 6 2018-04-10 09:26:47 PDT
Comment on attachment 337603 [details] Patch Clearing flags on attachment: 337603 Committed r230481: <https://trac.webkit.org/changeset/230481>
WebKit Commit Bot
Comment 7 2018-04-10 09:26:48 PDT
All reviewed patches have been landed. Closing bug.
Michael Catanzaro
Comment 8 2018-04-10 10:44:08 PDT
IMO this is wrong, this code should not be platform-specific. If it's not good enough for Apple, why should it be good enough for us? The web process is *expected* to crash, and WebKit is designed around that expectation. It must not be expected to release any system resources, or your application is going to be in big trouble when it does crash. Sounds like you need to find some other solution to handle these hardware media decoders, if they are not robust to process crashes. (In reply to Miguel Gomez from comment #1) > One option to fix this could be making the WebPage::Close() message a sync > one, and make the ui process wait for the web process to properly close > before shutting down, but this would delay closing the browser and that is a > problem for the Apple ports. That would be a problem for us too, because we know that in practice the web process often hangs on exit. So let's not try that, either.
Note You need to log in before you can comment on or make changes to this bug.