<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>184445</bug_id>
          
          <creation_ts>2018-04-10 04:08:58 -0700</creation_ts>
          <short_desc>[GTK][WPE] Race condition when destroying webprocesses</short_desc>
          <delta_ts>2018-04-16 11:34:35 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>WebKitGTK</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          <see_also>https://bugs.webkit.org/show_bug.cgi?id=183348</see_also>
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Miguel Gomez">magomez</reporter>
          <assigned_to name="Miguel Gomez">magomez</assigned_to>
          <cc>bugs-noreply</cc>
    
    <cc>cgarcia</cc>
    
    <cc>commit-queue</cc>
    
    <cc>mcatanzaro</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1413249</commentid>
    <comment_count>0</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2018-04-10 04:08:58 -0700</bug_when>
    <thetext>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&apos;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.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1413253</commentid>
    <comment_count>1</comment_count>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2018-04-10 05:15:15 -0700</bug_when>
    <thetext>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().</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1413255</commentid>
    <comment_count>2</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2018-04-10 05:37:49 -0700</bug_when>
    <thetext>(In reply to Miguel Gomez from comment #1)
&gt; One option to fix this could be making the WebPage::Close() message a sync
&gt; one, and make the ui process wait for the web process to properly close
&gt; before shutting down, but this would delay closing the browser and that is a
&gt; problem for the Apple ports.
&gt; 
&gt; So, if we cannot wait for the web process to end, we should ensure that it
&gt; will close its WebPages on exit. The easiest way is to use the code that
&gt; does that on debug inside WebProcess::didClose().

Yes, I would move that part out of the debug ifdef, at least for GTK and WPE.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1413256</commentid>
    <comment_count>3</comment_count>
      <attachid>337601</attachid>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2018-04-10 06:23:32 -0700</bug_when>
    <thetext>Created attachment 337601
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1413261</commentid>
    <comment_count>4</comment_count>
      <attachid>337603</attachid>
    <who name="Miguel Gomez">magomez</who>
    <bug_when>2018-04-10 06:53:15 -0700</bug_when>
    <thetext>Created attachment 337603
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1413269</commentid>
    <comment_count>5</comment_count>
      <attachid>337603</attachid>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2018-04-10 08:11:04 -0700</bug_when>
    <thetext>Comment on attachment 337603
Patch

Ok, let&apos;s try with this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1413285</commentid>
    <comment_count>6</comment_count>
      <attachid>337603</attachid>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-04-10 09:26:47 -0700</bug_when>
    <thetext>Comment on attachment 337603
Patch

Clearing flags on attachment: 337603

Committed r230481: &lt;https://trac.webkit.org/changeset/230481&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1413286</commentid>
    <comment_count>7</comment_count>
    <who name="WebKit Commit Bot">commit-queue</who>
    <bug_when>2018-04-10 09:26:48 -0700</bug_when>
    <thetext>All reviewed patches have been landed.  Closing bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1413320</commentid>
    <comment_count>8</comment_count>
    <who name="Michael Catanzaro">mcatanzaro</who>
    <bug_when>2018-04-10 10:44:08 -0700</bug_when>
    <thetext>IMO this is wrong, this code should not be platform-specific. If it&apos;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)
&gt; One option to fix this could be making the WebPage::Close() message a sync
&gt; one, and make the ui process wait for the web process to properly close
&gt; before shutting down, but this would delay closing the browser and that is a
&gt; 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&apos;s not try that, either.</thetext>
  </long_desc>
      
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>337601</attachid>
            <date>2018-04-10 06:23:32 -0700</date>
            <delta_ts>2018-04-10 06:53:11 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-184445-20180410152331.patch</filename>
            <type>text/plain</type>
            <size>1571</size>
            <attacher name="Miguel Gomez">magomez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMwNDc5CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IDFiYjgxMGMyOGRkMWQyYzA0
ZjJmZjBlNTA1MjhhZmIyYzA4YzgxMWIuLjdjMzY5NjA0ZWFjOTU0YzI0ZTkwOTdmNDU3ZTAwMWRh
NTYxZDNlNGQgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCisrKyBiL1NvdXJj
ZS9XZWJLaXQvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTYgQEAKKzIwMTgtMDQtMTAgIE1pZ3VlbCBH
b21leiAgPG1hZ29tZXpAaWdhbGlhLmNvbT4KKworICAgICAgICBbR1RLXVtXUEVdIFJhY2UgY29u
ZGl0aW9uIHdoZW4gZGVzdHJveWluZyB3ZWJwcm9jZXNzZXMKKyAgICAgICAgaHR0cHM6Ly9idWdz
LndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE4NDQ0NQorCisgICAgICAgIFJldmlld2VkIGJ5
IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIEVuc3VyZSB0aGF0IHRoZSBXZWJQcm9jZXNzIGlz
IHByb3Blcmx5IGNsb3NpbmcgaXRzIHBhZ2VzIHdoZW4gaXQncyBleGl0aW5nIGJlY2F1c2UKKyAg
ICAgICAgdGhlIFVJUHJvY2VzcyBoYXMgaW52YWxpZGF0ZWQgdGhlIElQQyBjb25uZWN0aW9uLgor
CisgICAgICAgICogV2ViUHJvY2Vzcy9XZWJQcm9jZXNzLmNwcDoKKyAgICAgICAgKFdl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G9uKCkuZ2FyYmFnZUNvbGxlY3RTb29uKCk7CiAg
ICAgRm9udENhY2hlOjpzaW5nbGV0b24oKS5pbnZhbGlkYXRlKCk7CiAgICAgTWVtb3J5Q2FjaGU6
OnNpbmdsZXRvbigpLnNldERpc2FibGVkKHRydWUpOwo=
</data>

          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>337603</attachid>
            <date>2018-04-10 06:53:15 -0700</date>
            <delta_ts>2018-04-10 09:26:47 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-184445-20180410155313.patch</filename>
            <type>text/plain</type>
            <size>1577</size>
            <attacher name="Miguel Gomez">magomez</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMjMwNDc5CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViS2l0L0No
YW5nZUxvZyBiL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCmluZGV4IDFiYjgxMGMyOGRkMWQyYzA0
ZjJmZjBlNTA1MjhhZmIyYzA4YzgxMWIuLjdjMzY5NjA0ZWFjOTU0YzI0ZTkwOTdmNDU3ZTAwMWRh
NTYxZDNlNGQgMTAwNjQ0Ci0tLSBhL1NvdXJjZS9XZWJLaXQvQ2hhbmdlTG9nCisrKyBiL1NvdXJj
ZS9XZWJLaXQvQ2hhbmdlTG9nCkBAIC0xLDMgKzEsMTYgQEAKKzIwMTgtMDQtMTAgIE1pZ3VlbCBH
b21leiAgPG1hZ29tZXpAaWdhbGlhLmNvbT4KKworICAgICAgICBbR1RLXVtXUEVdIFJhY2UgY29u
ZGl0aW9uIHdoZW4gZGVzdHJveWluZyB3ZWJwcm9jZXNzZXMKKyAgICAgICAgaHR0cHM6Ly9idWdz
LndlYmtpdC5vcmcvc2hvd19idWcuY2dpP2lkPTE4NDQ0NQorCisgICAgICAgIFJldmlld2VkIGJ5
IE5PQk9EWSAoT09QUyEpLgorCisgICAgICAgIEVuc3VyZSB0aGF0IHRo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