Diff
Modified: trunk/Source/WebCore/ChangeLog (149970 => 149971)
--- trunk/Source/WebCore/ChangeLog 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebCore/ChangeLog 2013-05-12 23:16:30 UTC (rev 149971)
@@ -1,3 +1,48 @@
+2013-05-12 Andreas Kling <[email protected]>
+
+ Unload event listeners should prevent Safari from insta-killing the web process on last tab close.
+ <http://webkit.org/b/115988>
+ <rdar://problem/13870943>
+
+ Reviewed by Anders Carlsson.
+
+ Add two methods to Chrome (and ChromeClient):
+
+ - enableSuddenTermination()
+ - disableSuddenTermination()
+
+ ..and call these from DOMWindow instead of the free global functions.
+
+ For WebKit1, it just calls the NSProcessInfo methods to keep behavior the same.
+ For WebKit2, the new methods plumb through the information to the UI process.
+
+ Also updated the DOMWindow logic to think in terms of per-DOMWindow sudden termination counters
+ instead of a process-global one, since that gets confusing in a WK2 world.
+ When a DOMWindow transitions between having/not having unload/beforeunload event listeners,
+ we send a notification to the Chrome.
+
+ * WebCore.exp.in:
+ * WebCore.xcodeproj/project.pbxproj:
+ * page/Chrome.h:
+ (WebCore::Chrome::enableSuddenTermination):
+ (WebCore::Chrome::disableSuddenTermination):
+ * page/ChromeClient.h:
+ (WebCore::ChromeClient::enableSuddenTermination):
+ (WebCore::ChromeClient::disableSuddenTermination):
+ * page/DOMWindow.cpp:
+ (WebCore::addUnloadEventListener):
+ (WebCore::removeUnloadEventListener):
+ (WebCore::removeAllUnloadEventListeners):
+ (WebCore::addBeforeUnloadEventListener):
+ (WebCore::removeBeforeUnloadEventListener):
+ (WebCore::removeAllBeforeUnloadEventListeners):
+ (WebCore::DOMWindow::dispatchAllPendingBeforeUnloadEvents):
+ (WebCore::DOMWindow::dispatchAllPendingUnloadEvents):
+ (WebCore::DOMWindow::enableSuddenTermination):
+ (WebCore::DOMWindow::disableSuddenTermination):
+ * page/DOMWindow.h:
+ (DOMWindow):
+
2013-05-12 Anders Carlsson <[email protected]>
Remove Complex.h from WTF
Modified: trunk/Source/WebCore/WebCore.exp.in (149970 => 149971)
--- trunk/Source/WebCore/WebCore.exp.in 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebCore/WebCore.exp.in 2013-05-12 23:16:30 UTC (rev 149971)
@@ -751,6 +751,7 @@
__ZN7WebCore23createFragmentFromNodesEPNS_8DocumentERKN3WTF6VectorIPNS_4NodeELm0ENS2_15CrashOnOverflowEEE
__ZN7WebCore23dataForURLComponentTypeEP5NSURLl
__ZN7WebCore23decodeHostNameWithRangeEP8NSString8_NSRange
+__ZN7WebCore23enableSuddenTerminationEv
__ZN7WebCore23encodeHostNameWithRangeEP8NSString8_NSRange
__ZN7WebCore23getHostnamesWithCookiesERKNS_21NetworkStorageSessionERN3WTF7HashSetINS3_6StringENS3_10StringHashENS3_10HashTraitsIS5_EEEE
__ZN7WebCore24BinaryPropertyListWriter17writePropertyListEv
@@ -774,6 +775,7 @@
__ZN7WebCore24createFragmentFromMarkupEPNS_8DocumentERKN3WTF6StringES5_NS_19ParserContentPolicyE
__ZN7WebCore24decodeURLEscapeSequencesERKN3WTF6StringE
__ZN7WebCore24deleteCookiesForHostnameERKNS_21NetworkStorageSessionERKN3WTF6StringE
+__ZN7WebCore24disableSuddenTerminationEv
__ZN7WebCore24fileSystemRepresentationERKN3WTF6StringE
__ZN7WebCore24notifyHistoryItemChangedE
__ZN7WebCore24pathByAppendingComponentERKN3WTF6StringES3_
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (149970 => 149971)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2013-05-12 23:16:30 UTC (rev 149971)
@@ -2882,7 +2882,7 @@
939B02EE0EA2DBC400C54570 /* WidthIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 939B02EC0EA2DBC400C54570 /* WidthIterator.cpp */; };
939B02EF0EA2DBC400C54570 /* WidthIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = 939B02ED0EA2DBC400C54570 /* WidthIterator.h */; };
93A38B4B0D0E5808006872C2 /* EditorCommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 93A38B4A0D0E5808006872C2 /* EditorCommand.cpp */; };
- 93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B2D8150F9920D2006AE6B2 /* SuddenTermination.h */; };
+ 93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B2D8150F9920D2006AE6B2 /* SuddenTermination.h */; settings = {ATTRIBUTES = (Private, ); }; };
93B2D8180F9920EE006AE6B2 /* SuddenTermination.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B2D8170F9920EE006AE6B2 /* SuddenTermination.mm */; };
93B6A0E60B0BCA5C00F5027A /* ContextMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = 93B6A0E50B0BCA5C00F5027A /* ContextMenu.h */; settings = {ATTRIBUTES = (Private, ); }; };
93B6A0EA0B0BCA8400F5027A /* ContextMenuMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 93B6A0E90B0BCA8400F5027A /* ContextMenuMac.mm */; };
@@ -21656,6 +21656,7 @@
BC64640A11D7F304006455B0 /* DOMStringMap.h in Headers */,
0FF5025B102BA9010066F39A /* DOMStyleMedia.h in Headers */,
0FF50263102BA92C0066F39A /* DOMStyleMediaInternal.h in Headers */,
+ 93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */,
850657000AAB4763002D15C0 /* DOMStyleSheet.h in Headers */,
85B498FF0ADB348100925CBB /* DOMStyleSheetInternal.h in Headers */,
850657020AAB4763002D15C0 /* DOMStyleSheetList.h in Headers */,
@@ -23518,7 +23519,6 @@
656D37480ADBA5DE00A4554D /* SubresourceLoader.h in Headers */,
659A7D130B6DB4D9001155B3 /* SubstituteData.h in Headers */,
1A8F6B020DB53006001DB794 /* SubstituteResource.h in Headers */,
- 93B2D8160F9920D2006AE6B2 /* SuddenTermination.h in Headers */,
97C078501165D5BE003A32EF /* SuffixTree.h in Headers */,
97627B9814FB5424002CDCA1 /* Supplementable.h in Headers */,
087558C613B4A57D00F49307 /* SurrogatePairAwareTextIterator.h in Headers */,
Modified: trunk/Source/WebCore/page/Chrome.cpp (149970 => 149971)
--- trunk/Source/WebCore/page/Chrome.cpp 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebCore/page/Chrome.cpp 2013-05-12 23:16:30 UTC (rev 149971)
@@ -461,6 +461,16 @@
m_client->print(frame);
}
+void Chrome::enableSuddenTermination()
+{
+ m_client->enableSuddenTermination();
+}
+
+void Chrome::disableSuddenTermination()
+{
+ m_client->disableSuddenTermination();
+}
+
#if ENABLE(DIRECTORY_UPLOAD)
void Chrome::enumerateChosenDirectory(FileChooser* fileChooser)
{
Modified: trunk/Source/WebCore/page/Chrome.h (149970 => 149971)
--- trunk/Source/WebCore/page/Chrome.h 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebCore/page/Chrome.h 2013-05-12 23:16:30 UTC (rev 149971)
@@ -147,6 +147,9 @@
void print(Frame*);
+ void enableSuddenTermination();
+ void disableSuddenTermination();
+
#if ENABLE(INPUT_TYPE_COLOR)
PassOwnPtr<ColorChooser> createColorChooser(ColorChooserClient*, const Color& initialColor);
#endif
Modified: trunk/Source/WebCore/page/ChromeClient.h (149970 => 149971)
--- trunk/Source/WebCore/page/ChromeClient.h 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebCore/page/ChromeClient.h 2013-05-12 23:16:30 UTC (rev 149971)
@@ -317,6 +317,9 @@
virtual void willPopUpMenu(NSMenu *) { }
#endif
+ virtual void enableSuddenTermination() { }
+ virtual void disableSuddenTermination() { }
+
#if PLATFORM(WIN)
virtual void setLastSetCursorToCurrentCursor() = 0;
#endif
Modified: trunk/Source/WebCore/page/DOMWindow.cpp (149970 => 149971)
--- trunk/Source/WebCore/page/DOMWindow.cpp 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebCore/page/DOMWindow.cpp 2013-05-12 23:16:30 UTC (rev 149971)
@@ -175,20 +175,16 @@
static void addUnloadEventListener(DOMWindow* domWindow)
{
DOMWindowSet& set = windowsWithUnloadEventListeners();
- if (set.isEmpty())
- disableSuddenTermination();
- set.add(domWindow);
+ if (set.add(domWindow).isNewEntry)
+ domWindow->disableSuddenTermination();
}
static void removeUnloadEventListener(DOMWindow* domWindow)
{
DOMWindowSet& set = windowsWithUnloadEventListeners();
DOMWindowSet::iterator it = set.find(domWindow);
- if (it == set.end())
- return;
- set.remove(it);
- if (set.isEmpty())
- enableSuddenTermination();
+ if (set.remove(it))
+ domWindow->enableSuddenTermination();
}
static void removeAllUnloadEventListeners(DOMWindow* domWindow)
@@ -198,27 +194,22 @@
if (it == set.end())
return;
set.removeAll(it);
- if (set.isEmpty())
- enableSuddenTermination();
+ domWindow->enableSuddenTermination();
}
static void addBeforeUnloadEventListener(DOMWindow* domWindow)
{
DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
- if (set.isEmpty())
- disableSuddenTermination();
- set.add(domWindow);
+ if (set.add(domWindow).isNewEntry)
+ domWindow->disableSuddenTermination();
}
static void removeBeforeUnloadEventListener(DOMWindow* domWindow)
{
DOMWindowSet& set = windowsWithBeforeUnloadEventListeners();
DOMWindowSet::iterator it = set.find(domWindow);
- if (it == set.end())
- return;
- set.remove(it);
- if (set.isEmpty())
- enableSuddenTermination();
+ if (set.remove(it))
+ domWindow->enableSuddenTermination();
}
static void removeAllBeforeUnloadEventListeners(DOMWindow* domWindow)
@@ -228,8 +219,7 @@
if (it == set.end())
return;
set.removeAll(it);
- if (set.isEmpty())
- enableSuddenTermination();
+ domWindow->enableSuddenTermination();
}
static bool allowsBeforeUnloadListeners(DOMWindow* window)
@@ -272,12 +262,11 @@
if (!frame->loader()->shouldClose())
return false;
+
+ window->enableSuddenTermination();
}
- enableSuddenTermination();
-
alreadyDispatched = true;
-
return true;
}
@@ -310,10 +299,10 @@
window->dispatchEvent(PageTransitionEvent::create(eventNames().pagehideEvent, false), window->document());
window->dispatchEvent(Event::create(eventNames().unloadEvent, false, false), window->document());
+
+ window->enableSuddenTermination();
}
- enableSuddenTermination();
-
alreadyDispatched = true;
}
@@ -2017,4 +2006,16 @@
dialogFrame->page()->chrome()->runModal();
}
+void DOMWindow::enableSuddenTermination()
+{
+ if (Page* page = this->page())
+ page->chrome()->enableSuddenTermination();
+}
+
+void DOMWindow::disableSuddenTermination()
+{
+ if (Page* page = this->page())
+ page->chrome()->disableSuddenTermination();
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/page/DOMWindow.h (149970 => 149971)
--- trunk/Source/WebCore/page/DOMWindow.h 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebCore/page/DOMWindow.h 2013-05-12 23:16:30 UTC (rev 149971)
@@ -412,6 +412,9 @@
void willDetachDocumentFromFrame();
void willDestroyCachedFrame();
+ void enableSuddenTermination();
+ void disableSuddenTermination();
+
private:
explicit DOMWindow(Document*);
Modified: trunk/Source/WebKit/mac/ChangeLog (149970 => 149971)
--- trunk/Source/WebKit/mac/ChangeLog 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit/mac/ChangeLog 2013-05-12 23:16:30 UTC (rev 149971)
@@ -1,3 +1,16 @@
+2013-05-12 Andreas Kling <[email protected]>
+
+ Unload event listeners should prevent Safari from insta-killing the web process on last tab close.
+ <http://webkit.org/b/115988>
+ <rdar://problem/13870943>
+
+ Reviewed by Anders Carlsson.
+
+ * WebCoreSupport/WebChromeClient.h:
+ * WebCoreSupport/WebChromeClient.mm:
+ (WebChromeClient::enableSuddenTermination):
+ (WebChromeClient::disableSuddenTermination):
+
2013-05-10 Brian J. Burg <[email protected]>
Web Inspector: Implement WK2 version of WebInspectorFrontendClient::save
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h (149970 => 149971)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.h 2013-05-12 23:16:30 UTC (rev 149971)
@@ -136,6 +136,9 @@
virtual void makeFirstResponder(NSResponder *) OVERRIDE;
virtual void willPopUpMenu(NSMenu *) OVERRIDE;
+
+ virtual void enableSuddenTermination() OVERRIDE;
+ virtual void disableSuddenTermination() OVERRIDE;
virtual bool shouldReplaceWithGeneratedFileForUpload(const WTF::String& path, WTF::String &generatedFilename) OVERRIDE;
virtual WTF::String generateReplacementFile(const WTF::String& path) OVERRIDE;
Modified: trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm (149970 => 149971)
--- trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit/mac/WebCoreSupport/WebChromeClient.mm 2013-05-12 23:16:30 UTC (rev 149971)
@@ -814,6 +814,16 @@
END_BLOCK_OBJC_EXCEPTIONS;
}
+void WebChromeClient::enableSuddenTermination()
+{
+ [[NSProcessInfo processInfo] enableSuddenTermination];
+}
+
+void WebChromeClient::disableSuddenTermination()
+{
+ [[NSProcessInfo processInfo] disableSuddenTermination];
+}
+
bool WebChromeClient::shouldReplaceWithGeneratedFileForUpload(const String& path, String& generatedFilename)
{
NSString* filename;
Modified: trunk/Source/WebKit2/ChangeLog (149970 => 149971)
--- trunk/Source/WebKit2/ChangeLog 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit2/ChangeLog 2013-05-12 23:16:30 UTC (rev 149971)
@@ -1,3 +1,33 @@
+2013-05-12 Andreas Kling <[email protected]>
+
+ Unload event listeners should prevent Safari from insta-killing the web process on last tab close.
+ <http://webkit.org/b/115988>
+ <rdar://problem/13870943>
+
+ Reviewed by Anders Carlsson.
+
+ Let WebCore control the UI process's suppression of the sudden termination mechanism.
+ This is implemented by having WebChromeClient push Enable/DisableSuddenTermination messages
+ over to the UI process where the appropriate NSProcessInfo calls are made.
+
+ We also use this information when deciding whether to insta-kill a web process when its last
+ page is closed. This mechanism is re-usable in WebCore to protect against sudden termination
+ by the UI process.
+
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::WebProcessProxy):
+ (WebKit::WebProcessProxy::removeWebPage):
+ (WebKit::WebProcessProxy::enableSuddenTermination):
+ (WebKit::WebProcessProxy::disableSuddenTermination):
+ * UIProcess/WebProcessProxy.h:
+ (WebProcessProxy):
+ * UIProcess/WebProcessProxy.messages.in:
+ * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+ (WebKit::WebChromeClient::enableSuddenTermination):
+ (WebKit::WebChromeClient::disableSuddenTermination):
+ * WebProcess/WebCoreSupport/WebChromeClient.h:
+ (WebChromeClient):
+
2013-05-12 Alexey Proskuryakov <[email protected]>
<rdar://problem/13402976> Sandbox violations in com.nvidia.OpenGL on Lion.
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (149970 => 149971)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp 2013-05-12 23:16:30 UTC (rev 149971)
@@ -41,6 +41,7 @@
#include "WebProcessMessages.h"
#include "WebProcessProxyMessages.h"
#include <WebCore/KURL.h>
+#include <WebCore/SuddenTermination.h>
#include <stdio.h>
#include <wtf/MainThread.h>
#include <wtf/text/CString.h>
@@ -90,6 +91,7 @@
: m_responsivenessTimer(this)
, m_context(context)
, m_mayHaveUniversalFileReadSandboxExtension(false)
+ , m_suddenTerminationCounter(0)
#if ENABLE(CUSTOM_PROTOCOLS)
, m_customProtocolManagerProxy(this)
#endif
@@ -202,7 +204,7 @@
#if ENABLE(NETWORK_PROCESS)
// Terminate the web process immediately if we have enough information to confidently do so.
// This only works if we're using a network process. Otherwise we have to wait for the web process to clean up.
- if (canTerminateChildProcess() && m_context->usesNetworkProcess())
+ if (!m_suddenTerminationCounter && canTerminateChildProcess() && m_context->usesNetworkProcess())
requestTermination();
#endif
}
@@ -652,4 +654,23 @@
disconnect();
}
+
+void WebProcessProxy::enableSuddenTermination()
+{
+ if (!isValid())
+ return;
+
+ WebCore::enableSuddenTermination();
+ m_suddenTerminationCounter--;
+}
+
+void WebProcessProxy::disableSuddenTermination()
+{
+ if (!isValid())
+ return;
+
+ WebCore::disableSuddenTermination();
+ m_suddenTerminationCounter++;
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (149970 => 149971)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h 2013-05-12 23:16:30 UTC (rev 149971)
@@ -115,6 +115,9 @@
void updateProcessSuppressionState();
#endif
+ void enableSuddenTermination();
+ void disableSuddenTermination();
+
void requestTermination();
private:
@@ -188,6 +191,8 @@
bool m_mayHaveUniversalFileReadSandboxExtension; // True if a read extension for "/" was ever granted - we don't track whether WebProcess still has it.
HashSet<String> m_localPathsWithAssumedReadAccess;
+ unsigned m_suddenTerminationCounter;
+
WebPageProxyMap m_pageMap;
WebFrameProxyMap m_frameMap;
WebBackForwardListItemMap m_backForwardListItemMap;
Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in (149970 => 149971)
--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.messages.in 2013-05-12 23:16:30 UTC (rev 149971)
@@ -33,6 +33,9 @@
ShouldTerminate() -> (bool shouldTerminate)
+ EnableSuddenTermination()
+ DisableSuddenTermination()
+
# Plugin messages.
#if ENABLE(NETSCAPE_PLUGIN_API)
GetPlugins(bool refresh) -> (Vector<WebCore::PluginInfo> plugins)
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp (149970 => 149971)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.cpp 2013-05-12 23:16:30 UTC (rev 149971)
@@ -45,6 +45,7 @@
#include "WebPopupMenu.h"
#include "WebPreferencesStore.h"
#include "WebProcess.h"
+#include "WebProcessProxyMessages.h"
#include "WebSearchPopupMenu.h"
#include "WebSecurityOrigin.h"
#include <WebCore/AXObjectCache.h>
@@ -844,4 +845,14 @@
return m_page->injectedBundleUIClient().plugInExtraScript();
}
+void WebChromeClient::enableSuddenTermination()
+{
+ m_page->send(Messages::WebProcessProxy::EnableSuddenTermination());
+}
+
+void WebChromeClient::disableSuddenTermination()
+{
+ m_page->send(Messages::WebProcessProxy::DisableSuddenTermination());
+}
+
} // namespace WebKit
Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h (149970 => 149971)
--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h 2013-05-12 21:27:43 UTC (rev 149970)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebChromeClient.h 2013-05-12 23:16:30 UTC (rev 149971)
@@ -206,6 +206,9 @@
#if PLATFORM(MAC)
virtual void makeFirstResponder() OVERRIDE;
#endif
+
+ virtual void enableSuddenTermination() OVERRIDE;
+ virtual void disableSuddenTermination() OVERRIDE;
virtual void dispatchViewportPropertiesDidChange(const WebCore::ViewportArguments&) const OVERRIDE;