<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[202723] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/202723">202723</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-06-30 18:29:47 -0700 (Thu, 30 Jun 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS] WebContent processes do not exit promptly
https://bugs.webkit.org/show_bug.cgi?id=159301
&lt;rdar://problem/26965488&gt;

Reviewed by Anders Carlsson.

WebContent processes do not exit promptly, they hang around for 10 seconds
until the watchdog forcefully calls exit().

This patch addresses the issue by asking XPC to exit when clean. It also
fixes 2 XPC transactions that were leaking so that XPC can become clean.

* DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm:
(DatabaseServiceInitializer):
* NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm:
(NetworkServiceInitializer):
* PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:
(PluginServiceInitializer):
* WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
(WebContentServiceInitializer):
Add extra priorityBoostMessage parameter which is then passed along to
ChildProcess via initialization parameters. ChildProcess is now in
charge of retaining the message for as long as it needs the priority
boost. In particular, ChildProcess now takes care of releasing the
boost message before existing to avoid leaking an XPC transaction.

* Shared/ChildProcess.cpp:
(WebKit::ChildProcess::initialize):
Retain priorityBoostMessage as a data member.

(WebKit::ChildProcess::stopRunLoop):
(WebKit::ChildProcess::platformStopRunLoop):
* Shared/ios/ChildProcessIOS.mm:
(WebKit::ChildProcess::platformStopRunLoop):
On iOS, call XPCServiceExit() to exit instead of RunLoop::main().stop()
which did not work.

* Shared/ChildProcess.h:
* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
(WebKit::XPCServiceInitializer):
Set priorityBoostMessage on ChildProcessInitializationParameters.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
(WebKit::XPCServiceExit):
Add XPCServiceExit() function which destroys the priority boost
message, calls xpc_transaction_end() to balance the
xpc_transaction_begin() in XPCServiceInitializer() and then call
xpc_transaction_exit_clean() to ask XPC to exit when clean.

* Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
(WebKit::XPCServiceEventHandler):
Leaking the &quot;pre-bootstrap&quot; event for priority boosting would cause us to
leak an XPC transaction, which would prevent XPC from becoming clean and
exiting. Instead, we now pass it along to the initialization function.
We then pass it to ChildProcess which manages the lifetime of this message
instead of leaking it.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFwtfspidarwinXPCSPIh">trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2DatabaseProcessEntryPointmacXPCServiceDatabaseServiceEntryPointmm">trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcessEntryPointmacXPCServiceNetworkServiceEntryPointmm">trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2PluginProcessEntryPointmacXPCServicePluginServiceEntryPointmm">trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedChildProcesscpp">trunk/Source/WebKit2/Shared/ChildProcess.cpp</a></li>
<li><a href="#trunkSourceWebKit2SharedChildProcessh">trunk/Source/WebKit2/Shared/ChildProcess.h</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointh">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm</a></li>
<li><a href="#trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainmm">trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm</a></li>
<li><a href="#trunkSourceWebKit2SharediosChildProcessIOSmm">trunk/Source/WebKit2/Shared/ios/ChildProcessIOS.mm</a></li>
<li><a href="#trunkSourceWebKit2WebProcessEntryPointmacXPCServiceWebContentServiceEntryPointmm">trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFwtfspidarwinXPCSPIh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WTF/wtf/spi/darwin/XPCSPI.h        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -123,6 +123,8 @@
</span><span class="cx"> EXTERN_C void xpc_main(xpc_connection_handler_t);
</span><span class="cx"> EXTERN_C const char* xpc_string_get_string_ptr(xpc_object_t);
</span><span class="cx"> EXTERN_C void xpc_transaction_begin(void);
</span><ins>+EXTERN_C void xpc_transaction_end(void);
+EXTERN_C void xpc_transaction_exit_clean(void);
</ins><span class="cx"> EXTERN_C void xpc_track_activity(void);
</span><span class="cx"> 
</span><span class="cx"> EXTERN_C xpc_object_t xpc_connection_copy_entitlement_value(xpc_connection_t, const char* entitlement);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/ChangeLog        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -1,3 +1,62 @@
</span><ins>+2016-06-30  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        [iOS] WebContent processes do not exit promptly
+        https://bugs.webkit.org/show_bug.cgi?id=159301
+        &lt;rdar://problem/26965488&gt;
+
+        Reviewed by Anders Carlsson.
+
+        WebContent processes do not exit promptly, they hang around for 10 seconds
+        until the watchdog forcefully calls exit().
+
+        This patch addresses the issue by asking XPC to exit when clean. It also
+        fixes 2 XPC transactions that were leaking so that XPC can become clean.
+
+        * DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm:
+        (DatabaseServiceInitializer):
+        * NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm:
+        (NetworkServiceInitializer):
+        * PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm:
+        (PluginServiceInitializer):
+        * WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm:
+        (WebContentServiceInitializer):
+        Add extra priorityBoostMessage parameter which is then passed along to
+        ChildProcess via initialization parameters. ChildProcess is now in
+        charge of retaining the message for as long as it needs the priority
+        boost. In particular, ChildProcess now takes care of releasing the
+        boost message before existing to avoid leaking an XPC transaction.
+
+        * Shared/ChildProcess.cpp:
+        (WebKit::ChildProcess::initialize):
+        Retain priorityBoostMessage as a data member.
+
+        (WebKit::ChildProcess::stopRunLoop):
+        (WebKit::ChildProcess::platformStopRunLoop):
+        * Shared/ios/ChildProcessIOS.mm:
+        (WebKit::ChildProcess::platformStopRunLoop):
+        On iOS, call XPCServiceExit() to exit instead of RunLoop::main().stop()
+        which did not work.
+
+        * Shared/ChildProcess.h:
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h:
+        (WebKit::XPCServiceInitializer):
+        Set priorityBoostMessage on ChildProcessInitializationParameters.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm:
+        (WebKit::XPCServiceExit):
+        Add XPCServiceExit() function which destroys the priority boost
+        message, calls xpc_transaction_end() to balance the
+        xpc_transaction_begin() in XPCServiceInitializer() and then call
+        xpc_transaction_exit_clean() to ask XPC to exit when clean.
+
+        * Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:
+        (WebKit::XPCServiceEventHandler):
+        Leaking the &quot;pre-bootstrap&quot; event for priority boosting would cause us to
+        leak an XPC transaction, which would prevent XPC from becoming clean and
+        exiting. Instead, we now pass it along to the initialization function.
+        We then pass it to ChildProcess which manages the lifetime of this message
+        instead of leaking it.
+
</ins><span class="cx"> 2016-06-30  Brian Burg  &lt;bburg@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r202329): WebInspectorProxy's WKPagePolicyClient callbacks are not being called
</span></span></pre></div>
<a id="trunkSourceWebKit2DatabaseProcessEntryPointmacXPCServiceDatabaseServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/DatabaseProcess/EntryPoint/mac/XPCService/DatabaseServiceEntryPoint.mm        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -36,9 +36,9 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebKit;
</span><span class="cx"> 
</span><del>-extern &quot;C&quot; WK_EXPORT void DatabaseServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage);
</del><ins>+extern &quot;C&quot; WK_EXPORT void DatabaseServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
</ins><span class="cx"> 
</span><del>-void DatabaseServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
</del><ins>+void DatabaseServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
</ins><span class="cx"> {
</span><span class="cx"> #if HAVE(OS_ACTIVITY)
</span><span class="cx"> #pragma clang diagnostic push
</span><span class="lines">@@ -47,7 +47,7 @@
</span><span class="cx"> #pragma clang diagnostic pop
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    XPCServiceInitializer&lt;DatabaseProcess, XPCServiceInitializerDelegate&gt;(adoptOSObject(connection), initializerMessage);
</del><ins>+    XPCServiceInitializer&lt;DatabaseProcess, XPCServiceInitializerDelegate&gt;(adoptOSObject(connection), initializerMessage, priorityBoostMessage);
</ins><span class="cx"> 
</span><span class="cx"> #if HAVE(OS_ACTIVITY)
</span><span class="cx"> #pragma clang diagnostic push
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcessEntryPointmacXPCServiceNetworkServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/NetworkProcess/EntryPoint/mac/XPCService/NetworkServiceEntryPoint.mm        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -48,9 +48,9 @@
</span><span class="cx"> 
</span><span class="cx"> using namespace WebKit;
</span><span class="cx"> 
</span><del>-extern &quot;C&quot; WK_EXPORT void NetworkServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage);
</del><ins>+extern &quot;C&quot; WK_EXPORT void NetworkServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
</ins><span class="cx"> 
</span><del>-void NetworkServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
</del><ins>+void NetworkServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
</ins><span class="cx"> {
</span><span class="cx">     // Remove the SecItemShim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
</span><span class="cx">     // the this process don't try to insert the shim and crash.
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx"> #pragma clang diagnostic pop
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    XPCServiceInitializer&lt;NetworkProcess, NetworkServiceInitializerDelegate&gt;(adoptOSObject(connection), initializerMessage);
</del><ins>+    XPCServiceInitializer&lt;NetworkProcess, NetworkServiceInitializerDelegate&gt;(adoptOSObject(connection), initializerMessage, priorityBoostMessage);
</ins><span class="cx"> 
</span><span class="cx"> #if HAVE(OS_ACTIVITY)
</span><span class="cx"> #pragma clang diagnostic push
</span></span></pre></div>
<a id="trunkSourceWebKit2PluginProcessEntryPointmacXPCServicePluginServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/PluginProcess/EntryPoint/mac/XPCService/PluginServiceEntryPoint.mm        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -69,9 +69,9 @@
</span><span class="cx"> 
</span><span class="cx"> #endif // ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx"> 
</span><del>-extern &quot;C&quot; WK_EXPORT void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage);
</del><ins>+extern &quot;C&quot; WK_EXPORT void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
</ins><span class="cx"> 
</span><del>-void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
</del><ins>+void PluginServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
</ins><span class="cx"> {
</span><span class="cx"> #if ENABLE(NETSCAPE_PLUGIN_API)
</span><span class="cx">     // FIXME: Add support for teardown from PluginProcessMain.mm
</span><span class="lines">@@ -87,7 +87,7 @@
</span><span class="cx"> #pragma clang diagnostic pop
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    XPCServiceInitializer&lt;PluginProcess, PluginServiceInitializerDelegate&gt;(adoptOSObject(connection), initializerMessage);
</del><ins>+    XPCServiceInitializer&lt;PluginProcess, PluginServiceInitializerDelegate&gt;(adoptOSObject(connection), initializerMessage, priorityBoostMessage);
</ins><span class="cx"> 
</span><span class="cx"> #if HAVE(OS_ACTIVITY)
</span><span class="cx"> #pragma clang diagnostic push
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedChildProcesscpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/ChildProcess.cpp (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/ChildProcess.cpp        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/Shared/ChildProcess.cpp        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -64,6 +64,10 @@
</span><span class="cx"> {
</span><span class="cx">     platformInitialize();
</span><span class="cx"> 
</span><ins>+#if PLATFORM(COCOA)
+    m_priorityBoostMessage = parameters.priorityBoostMessage;
+#endif
+
</ins><span class="cx">     initializeProcess(parameters);
</span><span class="cx">     initializeProcessName(parameters);
</span><span class="cx"> 
</span><span class="lines">@@ -158,8 +162,15 @@
</span><span class="cx"> 
</span><span class="cx"> void ChildProcess::stopRunLoop()
</span><span class="cx"> {
</span><ins>+    platformStopRunLoop();
+}
+
+#if !PLATFORM(IOS)
+void ChildProcess::platformStopRunLoop()
+{
</ins><span class="cx">     RunLoop::main().stop();
</span><span class="cx"> }
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> void ChildProcess::terminate()
</span><span class="cx"> {
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedChildProcessh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/ChildProcess.h (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/ChildProcess.h        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/Shared/ChildProcess.h        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -45,6 +45,9 @@
</span><span class="cx">     String clientIdentifier;
</span><span class="cx">     IPC::Connection::Identifier connectionIdentifier;
</span><span class="cx">     HashMap&lt;String, String&gt; extraInitializationData;
</span><ins>+#if PLATFORM(COCOA)
+    OSObjectPtr&lt;xpc_object_t&gt; priorityBoostMessage;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> class ChildProcess : protected IPC::Connection::Client, public IPC::MessageSender {
</span><span class="lines">@@ -110,6 +113,7 @@
</span><span class="cx">     void terminationTimerFired();
</span><span class="cx"> 
</span><span class="cx">     void platformInitialize();
</span><ins>+    void platformStopRunLoop();
</ins><span class="cx"> 
</span><span class="cx">     // The timeout, in seconds, before this process will be terminated if termination
</span><span class="cx">     // has been enabled. If the timeout is 0 seconds, the process will be terminated immediately.
</span><span class="lines">@@ -125,6 +129,10 @@
</span><span class="cx">     IPC::MessageReceiverMap m_messageReceiverMap;
</span><span class="cx"> 
</span><span class="cx">     UserActivity m_processSuppressionDisabled;
</span><ins>+
+#if PLATFORM(COCOA)
+    OSObjectPtr&lt;xpc_object_t&gt; m_priorityBoostMessage;
+#endif
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.h        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -67,7 +67,7 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> template&lt;typename XPCServiceType, typename XPCServiceInitializerDelegateType&gt;
</span><del>-void XPCServiceInitializer(OSObjectPtr&lt;xpc_connection_t&gt; connection, xpc_object_t initializerMessage)
</del><ins>+void XPCServiceInitializer(OSObjectPtr&lt;xpc_connection_t&gt; connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
</ins><span class="cx"> {
</span><span class="cx">     XPCServiceInitializerDelegateType delegate(WTFMove(connection), initializerMessage);
</span><span class="cx"> 
</span><span class="lines">@@ -81,6 +81,9 @@
</span><span class="cx">         exit(EXIT_FAILURE);
</span><span class="cx"> 
</span><span class="cx">     ChildProcessInitializationParameters parameters;
</span><ins>+    if (priorityBoostMessage)
+        parameters.priorityBoostMessage = adoptOSObject(xpc_retain(priorityBoostMessage));
+
</ins><span class="cx">     if (!delegate.getConnectionIdentifier(parameters.connectionIdentifier))
</span><span class="cx">         exit(EXIT_FAILURE);
</span><span class="cx"> 
</span><span class="lines">@@ -101,6 +104,8 @@
</span><span class="cx">     XPCServiceType::singleton().initialize(parameters);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void XPCServiceExit(OSObjectPtr&lt;xpc_object_t&gt;&amp;&amp; priorityBoostMessage);
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif // XPCServiceEntryPoint_h
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceEntryPoint.mm        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -120,4 +120,13 @@
</span><span class="cx">     return processIsSandboxed(xpc_connection_get_pid(m_connection.get()));
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void XPCServiceExit(OSObjectPtr&lt;xpc_object_t&gt;&amp;&amp; priorityBoostMessage)
+{
+    // Make sure to destroy the priority boost message to avoid leaking a transaction.
+    priorityBoostMessage = nullptr;
+    // Balances the xpc_transaction_begin() in XPCServiceInitializer.
+    xpc_transaction_end();
+    xpc_transaction_exit_clean();
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKit2SharedEntryPointUtilitiesmacXPCServiceXPCServiceMainmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -34,6 +34,8 @@
</span><span class="cx"> 
</span><span class="cx"> static void XPCServiceEventHandler(xpc_connection_t peer)
</span><span class="cx"> {
</span><ins>+    static xpc_object_t priorityBoostMessage = nullptr;
+
</ins><span class="cx">     xpc_connection_set_target_queue(peer, dispatch_get_main_queue());
</span><span class="cx">     xpc_connection_set_event_handler(peer, ^(xpc_object_t event) {
</span><span class="cx">         xpc_type_t type = xpc_get_type(event);
</span><span class="lines">@@ -49,7 +51,7 @@
</span><span class="cx">                 CFBundleRef webKitBundle = CFBundleGetBundleWithIdentifier(CFSTR(&quot;com.apple.WebKit&quot;));
</span><span class="cx">                 CFStringRef entryPointFunctionName = (CFStringRef)CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), CFSTR(&quot;WebKitEntryPoint&quot;));
</span><span class="cx"> 
</span><del>-                typedef void (*InitializerFunction)(xpc_connection_t, xpc_object_t);
</del><ins>+                typedef void (*InitializerFunction)(xpc_connection_t, xpc_object_t, xpc_object_t);
</ins><span class="cx">                 InitializerFunction initializerFunctionPtr = reinterpret_cast&lt;InitializerFunction&gt;(CFBundleGetFunctionPointerForName(webKitBundle, entryPointFunctionName));
</span><span class="cx">                 if (!initializerFunctionPtr) {
</span><span class="cx">                     NSLog(@&quot;Unable to find entry point in WebKit.framework with name: %@&quot;, (NSString *)entryPointFunctionName);
</span><span class="lines">@@ -68,12 +70,16 @@
</span><span class="cx">                 if (fd != -1)
</span><span class="cx">                     dup2(fd, STDERR_FILENO);
</span><span class="cx"> 
</span><del>-                initializerFunctionPtr(peer, event);
</del><ins>+                initializerFunctionPtr(peer, event, priorityBoostMessage);
+                if (priorityBoostMessage)
+                    xpc_release(priorityBoostMessage);
</ins><span class="cx">             }
</span><span class="cx"> 
</span><span class="cx">             // Leak a boost onto the NetworkProcess.
</span><del>-            if (!strcmp(xpc_dictionary_get_string(event, &quot;message-name&quot;), &quot;pre-bootstrap&quot;))
-                xpc_retain(event);
</del><ins>+            if (!strcmp(xpc_dictionary_get_string(event, &quot;message-name&quot;), &quot;pre-bootstrap&quot;)) {
+                assert(!priorityBoostMessage);
+                priorityBoostMessage = xpc_retain(event);
+            }
</ins><span class="cx">         }
</span><span class="cx">     });
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2SharediosChildProcessIOSmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/Shared/ios/ChildProcessIOS.mm (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/Shared/ios/ChildProcessIOS.mm        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/Shared/ios/ChildProcessIOS.mm        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -31,6 +31,7 @@
</span><span class="cx"> 
</span><span class="cx"> #import &quot;SandboxInitializationParameters.h&quot;
</span><span class="cx"> #import &quot;WebKitSystemInterface.h&quot;
</span><ins>+#import &quot;XPCServiceEntryPoint.h&quot;
</ins><span class="cx"> #import &lt;WebCore/FileSystem.h&gt;
</span><span class="cx"> #import &lt;WebCore/FloatingPointEnvironment.h&gt;
</span><span class="cx"> #import &lt;WebCore/SystemVersion.h&gt;
</span><span class="lines">@@ -114,6 +115,11 @@
</span><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void ChildProcess::platformStopRunLoop()
+{
+    XPCServiceExit(WTFMove(m_priorityBoostMessage));
+}
+
</ins><span class="cx"> } // namespace WebKit
</span><span class="cx"> 
</span><span class="cx"> #endif
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessEntryPointmacXPCServiceWebContentServiceEntryPointmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm (202722 => 202723)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm        2016-07-01 00:13:49 UTC (rev 202722)
+++ trunk/Source/WebKit2/WebProcess/EntryPoint/mac/XPCService/WebContentServiceEntryPoint.mm        2016-07-01 01:29:47 UTC (rev 202723)
</span><span class="lines">@@ -43,9 +43,9 @@
</span><span class="cx"> using namespace WebCore;
</span><span class="cx"> using namespace WebKit;
</span><span class="cx"> 
</span><del>-extern &quot;C&quot; WK_EXPORT void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage);
</del><ins>+extern &quot;C&quot; WK_EXPORT void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage);
</ins><span class="cx"> 
</span><del>-void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage)
</del><ins>+void WebContentServiceInitializer(xpc_connection_t connection, xpc_object_t initializerMessage, xpc_object_t priorityBoostMessage)
</ins><span class="cx"> {
</span><span class="cx">     // Remove the WebProcessShim from the DYLD_INSERT_LIBRARIES environment variable so any processes spawned by
</span><span class="cx">     // the this process don't try to insert the shim and crash.
</span><span class="lines">@@ -63,7 +63,7 @@
</span><span class="cx">     InitWebCoreThreadSystemInterface();
</span><span class="cx"> #endif // PLATFORM(IOS)
</span><span class="cx"> 
</span><del>-    XPCServiceInitializer&lt;WebProcess, XPCServiceInitializerDelegate&gt;(adoptOSObject(connection), initializerMessage);
</del><ins>+    XPCServiceInitializer&lt;WebProcess, XPCServiceInitializerDelegate&gt;(adoptOSObject(connection), initializerMessage, priorityBoostMessage);
</ins><span class="cx"> 
</span><span class="cx"> #if HAVE(OS_ACTIVITY)
</span><span class="cx"> #pragma clang diagnostic push
</span></span></pre>
</div>
</div>

</body>
</html>