<!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>[208580] trunk</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/208580">208580</a></dd>
<dt>Author</dt> <dd>achristensen@apple.com</dd>
<dt>Date</dt> <dd>2016-11-10 22:16:08 -0800 (Thu, 10 Nov 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>Fix assertion after <a href="http://trac.webkit.org/projects/webkit/changeset/208534">r208534</a>.
https://bugs.webkit.org/show_bug.cgi?id=160497

Source/WebKit/mac:

* WebView/WebView.mm:
(-[WebView _commonInitializationWithFrameName:groupName:]):
(WebInstallMemoryPressureHandler):
WebInstallMemoryPressureHandler can be called before [WebView initWithFrame:frameName:groupName:]
When this happens, we should use the same std::once_flag to make sure we install the MemoryPressureHandler::singleton
only once, otherwise we get an assertion !m_installed in MemoryPressureHandler::setLowMemoryHandler.

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/mac/MemoryPressureHandler.mm: Added.
(TestWebKitAPI::TEST):
Add a regression test.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitmacChangeLog">trunk/Source/WebKit/mac/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitmacWebViewWebViewmm">trunk/Source/WebKit/mac/WebView/WebView.mm</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj">trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsTestWebKitAPITestsmacMemoryPressureHandlermm">trunk/Tools/TestWebKitAPI/Tests/mac/MemoryPressureHandler.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitmacChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/ChangeLog (208579 => 208580)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/ChangeLog        2016-11-11 06:08:18 UTC (rev 208579)
+++ trunk/Source/WebKit/mac/ChangeLog        2016-11-11 06:16:08 UTC (rev 208580)
</span><span class="lines">@@ -1,5 +1,17 @@
</span><span class="cx"> 2016-11-10  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><ins>+        Fix assertion after r208534.
+        https://bugs.webkit.org/show_bug.cgi?id=160497
+
+        * WebView/WebView.mm:
+        (-[WebView _commonInitializationWithFrameName:groupName:]):
+        (WebInstallMemoryPressureHandler):
+        WebInstallMemoryPressureHandler can be called before [WebView initWithFrame:frameName:groupName:]
+        When this happens, we should use the same std::once_flag to make sure we install the MemoryPressureHandler::singleton
+        only once, otherwise we get an assertion !m_installed in MemoryPressureHandler::setLowMemoryHandler.
+
+2016-11-10  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
</ins><span class="cx">         Move SecurityOrigin::databaseIdentifier() to SecurityOriginData
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=164573
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitmacWebViewWebViewmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (208579 => 208580)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/mac/WebView/WebView.mm        2016-11-11 06:08:18 UTC (rev 208579)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm        2016-11-11 06:16:08 UTC (rev 208580)
</span><span class="lines">@@ -1430,19 +1430,8 @@
</span><span class="cx">     _private-&gt;page-&gt;settings().setFontFallbackPrefersPictographs(true);
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    if (![[NSUserDefaults standardUserDefaults] boolForKey:@&quot;WebKitSuppressMemoryPressureHandler&quot;]) {
-        WebCore::registerMemoryReleaseNotifyCallbacks();
</del><ins>+    WebInstallMemoryPressureHandler();
</ins><span class="cx"> 
</span><del>-        static std::once_flag onceFlag;
-        std::call_once(onceFlag, [] {
-            auto&amp; memoryPressureHandler = MemoryPressureHandler::singleton();
-            memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous synchronous) {
-                WebCore::releaseMemory(critical, synchronous);
-            });
-            memoryPressureHandler.install();
-        });
-    }
-
</del><span class="cx">     if (!WebKitLinkedOnOrAfter(WEBKIT_FIRST_VERSION_WITH_LOCAL_RESOURCE_SECURITY_RESTRICTION)) {
</span><span class="cx">         // Originally, we allowed all local loads.
</span><span class="cx">         SecurityPolicy::setLocalLoadPolicy(SecurityPolicy::AllowLocalLoadsForAll);
</span><span class="lines">@@ -9800,6 +9789,16 @@
</span><span class="cx"> 
</span><span class="cx"> void WebInstallMemoryPressureHandler(void)
</span><span class="cx"> {
</span><del>-    if (![[NSUserDefaults standardUserDefaults] boolForKey:@&quot;WebKitSuppressMemoryPressureHandler&quot;])
-        MemoryPressureHandler::singleton().install();
</del><ins>+    if (![[NSUserDefaults standardUserDefaults] boolForKey:@&quot;WebKitSuppressMemoryPressureHandler&quot;]) {
+        WebCore::registerMemoryReleaseNotifyCallbacks();
+
+        static std::once_flag onceFlag;
+        std::call_once(onceFlag, [] {
+            auto&amp; memoryPressureHandler = MemoryPressureHandler::singleton();
+            memoryPressureHandler.setLowMemoryHandler([] (Critical critical, Synchronous synchronous) {
+                WebCore::releaseMemory(critical, synchronous);
+            });
+            memoryPressureHandler.install();
+        });
+    }
</ins><span class="cx"> }
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (208579 => 208580)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2016-11-11 06:08:18 UTC (rev 208579)
+++ trunk/Tools/ChangeLog        2016-11-11 06:16:08 UTC (rev 208580)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2016-11-10  Alex Christensen  &lt;achristensen@webkit.org&gt;
+
+        Fix assertion after r208534.
+        https://bugs.webkit.org/show_bug.cgi?id=160497
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/mac/MemoryPressureHandler.mm: Added.
+        (TestWebKitAPI::TEST):
+        Add a regression test.
+
</ins><span class="cx"> 2016-11-10  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         REGRESSION (r208522): LayoutTest fast/loader/reload-zero-byte-plugin.html is a flaky failure
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestWebKitAPIxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (208579 => 208580)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-11-11 06:08:18 UTC (rev 208579)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj        2016-11-11 06:16:08 UTC (rev 208580)
</span><span class="lines">@@ -152,6 +152,7 @@
</span><span class="cx">                 5769C50B1D9B0002000847FB /* SerializedCryptoKeyWrap.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */; };
</span><span class="cx">                 57901FB11CAF142D00ED64F9 /* LoadInvalidURLRequest.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57901FB01CAF141C00ED64F9 /* LoadInvalidURLRequest.html */; };
</span><span class="cx">                 57F56A5C1C7F8CC100F31D7E /* IsNavigationActionTrusted.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */; };
</span><ins>+                5C0BF88D1DD5964D00B00328 /* MemoryPressureHandler.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */; };
</ins><span class="cx">                 5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */; };
</span><span class="cx">                 5C2936961D5C00ED00DEAB1E /* CookieMessage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */; };
</span><span class="cx">                 5C6E65441D5CEFD400F7862E /* URLParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5C6E65411D5CEF8500F7862E /* URLParser.cpp */; };
</span><span class="lines">@@ -949,6 +950,7 @@
</span><span class="cx">                 5798E2AF1CAF5C2800C5CBA0 /* ProvisionalURLNotChange.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ProvisionalURLNotChange.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 57F10D921C7E7B3800ECDF30 /* IsNavigationActionTrusted.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = IsNavigationActionTrusted.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 57F56A5B1C7F8A4000F31D7E /* IsNavigationActionTrusted.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = IsNavigationActionTrusted.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MemoryPressureHandler.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieAcceptPolicy.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = CookieMessage.html; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 5C5E633D1D0B67940085A025 /* UniqueRef.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UniqueRef.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -1938,6 +1940,7 @@
</span><span class="cx">                 C07E6CAD13FD67650038B22B /* mac */ = {
</span><span class="cx">                         isa = PBXGroup;
</span><span class="cx">                         children = (
</span><ins>+                                5C0BF88C1DD5957400B00328 /* MemoryPressureHandler.mm */,
</ins><span class="cx">                                 C07E6CB013FD737C0038B22B /* Resources */,
</span><span class="cx">                                 379028B514FABD92007E6B43 /* AcceptsFirstMouse.mm */,
</span><span class="cx">                                 B55F119F1516834F00915916 /* AttributedString.mm */,
</span><span class="lines">@@ -2541,6 +2544,7 @@
</span><span class="cx">                                 7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */,
</span><span class="cx">                                 A14FC5901B8AE36F00D107EB /* TestProtocol.mm in Sources */,
</span><span class="cx">                                 7CCE7EAE1A411A3400447C4C /* TestsController.cpp in Sources */,
</span><ins>+                                5C0BF88D1DD5964D00B00328 /* MemoryPressureHandler.mm in Sources */,
</ins><span class="cx">                                 CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */,
</span><span class="cx">                                 7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */,
</span><span class="cx">                                 7CCE7ED31A411A7E00447C4C /* TypingStyleCrash.mm in Sources */,
</span></span></pre></div>
<a id="trunkToolsTestWebKitAPITestsmacMemoryPressureHandlermm"></a>
<div class="addfile"><h4>Added: trunk/Tools/TestWebKitAPI/Tests/mac/MemoryPressureHandler.mm (0 => 208580)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/TestWebKitAPI/Tests/mac/MemoryPressureHandler.mm                                (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/mac/MemoryPressureHandler.mm        2016-11-11 06:16:08 UTC (rev 208580)
</span><span class="lines">@@ -0,0 +1,38 @@
</span><ins>+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &lt;WebKit/WebViewPrivate.h&gt;
+
+namespace TestWebKitAPI {
+
+TEST(WebKit1, MemoryPressureHandler)
+{
+    WebInstallMemoryPressureHandler();
+    [[[WebView alloc] initWithFrame:NSZeroRect frameName:nil groupName:nil] autorelease];
+    // This test passes if it does not assert.
+}
+
+} // namespace TestWebKitAPI
</ins></span></pre>
</div>
</div>

</body>
</html>