Title: [115952] trunk
Revision
115952
Author
sle...@apple.com
Date
2012-05-03 02:51:56 -0700 (Thu, 03 May 2012)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=85450 unbounded growth of JSDOMWindowShells loading pages in the same window
<rdar://problem/11320059> REGRESSION (r115083): PLT3 shows linear memory growth and gets slower with each run

Reviewed by Brady Eidson.

The API added for DOMWindowExtension, didCreateGlobalObjectForFrame, would create a global object
for every world, even those that did not need the callback.  This had the side effect of creating a
JSDOMWindowShell that the associated world didn't necessarily know to clean up.  Instead of creating
unnecessary objects change the API to globalObjectIsAvailableForFrame and do not pass the global object
in the API.  The object can be accessed later by those worlds which require it.

Source/WebKit2:

* WebProcess/InjectedBundle/API/c/WKBundlePage.h:
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
(WebKit::InjectedBundlePageLoaderClient::globalObjectIsAvailableForFrame): rename API and remove globalObject parameter
* WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
(InjectedBundlePageLoaderClient): ditto
* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchGlobalObjectAvailable): ditto

Tools:

* TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp:
(TestWebKitAPI):
(TestWebKitAPI::didReceiveMessageFromInjectedBundle):
* TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp:
(TestWebKitAPI):
(DOMWindowExtensionBasic):
(TestWebKitAPI::DOMWindowExtensionBasic::didCreatePage):
(TestWebKitAPI::DOMWindowExtensionBasic::globalObjectIsAvailableForFrame):
(TestWebKitAPI::globalObjectIsAvailableForFrameCallback):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (115951 => 115952)


--- trunk/Source/WebKit2/ChangeLog	2012-05-03 09:49:29 UTC (rev 115951)
+++ trunk/Source/WebKit2/ChangeLog	2012-05-03 09:51:56 UTC (rev 115952)
@@ -1,3 +1,24 @@
+2012-05-03  Stephanie Lewis  <sle...@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=85450 unbounded growth of JSDOMWindowShells loading pages in the same window
+        <rdar://problem/11320059> REGRESSION (r115083): PLT3 shows linear memory growth and gets slower with each run
+
+        Reviewed by Brady Eidson.
+
+        The API added for DOMWindowExtension, didCreateGlobalObjectForFrame, would create a global object
+        for every world, even those that did not need the callback.  This had the side effect of creating a
+        JSDOMWindowShell that the associated world didn't necessarily know to clean up.  Instead of creating
+        unnecessary objects change the API to globalObjectIsAvailableForFrame and do not pass the global object
+        in the API.  The object can be accessed later by those worlds which require it.
+
+        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
+        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
+        (WebKit::InjectedBundlePageLoaderClient::globalObjectIsAvailableForFrame): rename API and remove globalObject parameter
+        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
+        (InjectedBundlePageLoaderClient): ditto
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchGlobalObjectAvailable): ditto
+
 2012-05-02  Alexander Færøy  <a...@0x90.dk>
 
         Rename deviceDPI to devicePixelRatio

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h (115951 => 115952)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2012-05-03 09:49:29 UTC (rev 115951)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h	2012-05-03 09:51:56 UTC (rev 115952)
@@ -103,7 +103,7 @@
 typedef void (*WKBundlePageWillPerformClientRedirectForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, WKURLRef url, double delay, double date, const void *clientInfo);
 typedef void (*WKBundlePageDidHandleOnloadEventsForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
 typedef bool (*WKBundlePageShouldGoToBackForwardListItemCallback)(WKBundlePageRef page, WKBundleBackForwardListItemRef item, WKTypeRef* userData, const void *clientInfo);
-typedef void (*WKBundlePageDidCreateGlobalObjectForFrameCallback)(WKBundlePageRef page, JSObjectRef globalObject, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
+typedef void (*WKBundlePageGlobalObjectIsAvailableForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
 typedef void (*WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
 typedef void (*WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
 typedef void (*WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
@@ -137,7 +137,7 @@
     WKBundlePageDidNewFirstVisuallyNonEmptyLayoutCallback                   didNewFirstVisuallyNonEmptyLayout;
     WKBundlePageDidDetectXSSForFrameCallback                                didDetectXSSForFrame;
     WKBundlePageShouldGoToBackForwardListItemCallback                       shouldGoToBackForwardListItem;
-    WKBundlePageDidCreateGlobalObjectForFrameCallback                       didCreateGlobalObjectForFrame;
+    WKBundlePageGlobalObjectIsAvailableForFrameCallback                     globalObjectIsAvailableForFrame;
     WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback    willDisconnectDOMWindowExtensionFromGlobalObject;
     WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback        didReconnectDOMWindowExtensionToGlobalObject;
     WKBundlePageWillDestroyGlobalObjectForDOMWindowExtensionCallback        willDestroyGlobalObjectForDOMWindowExtension;

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp (115951 => 115952)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp	2012-05-03 09:49:29 UTC (rev 115951)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp	2012-05-03 09:51:56 UTC (rev 115952)
@@ -249,13 +249,13 @@
     m_client.didHandleOnloadEventsForFrame(toAPI(page), toAPI(frame), m_client.clientInfo);
 }
 
-void InjectedBundlePageLoaderClient::didCreateGlobalObjectForFrame(WebPage* page, JSObjectRef globalObject, WebFrame* frame, WebCore::DOMWrapperWorld* world)
+void InjectedBundlePageLoaderClient::globalObjectIsAvailableForFrame(WebPage* page, WebFrame* frame, WebCore::DOMWrapperWorld* world)
 {
-    if (!m_client.didCreateGlobalObjectForFrame)
+    if (!m_client.globalObjectIsAvailableForFrame)
         return;
     
     RefPtr<InjectedBundleScriptWorld> injectedWorld = InjectedBundleScriptWorld::getOrCreate(world);
-    m_client.didCreateGlobalObjectForFrame(toAPI(page), globalObject, toAPI(frame), toAPI(injectedWorld.get()), m_client.clientInfo);
+    m_client.globalObjectIsAvailableForFrame(toAPI(page), toAPI(frame), toAPI(injectedWorld.get()), m_client.clientInfo);
 }
 
 void InjectedBundlePageLoaderClient::willDisconnectDOMWindowExtensionFromGlobalObject(WebPage* page, WebCore::DOMWindowExtension* coreExtension)

Modified: trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h (115951 => 115952)


--- trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h	2012-05-03 09:49:29 UTC (rev 115951)
+++ trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h	2012-05-03 09:51:56 UTC (rev 115952)
@@ -74,7 +74,7 @@
     void willPerformClientRedirectForFrame(WebPage*, WebFrame*, const String& url, double delay, double date);
     void didHandleOnloadEventsForFrame(WebPage*, WebFrame*);
 
-    void didCreateGlobalObjectForFrame(WebPage*, JSObjectRef globalObject, WebFrame*, WebCore::DOMWrapperWorld*);
+    void globalObjectIsAvailableForFrame(WebPage*, WebFrame*, WebCore::DOMWrapperWorld*);
     void willDisconnectDOMWindowExtensionFromGlobalObject(WebPage*, WebCore::DOMWindowExtension*);
     void didReconnectDOMWindowExtensionToGlobalObject(WebPage*, WebCore::DOMWindowExtension*);
     void willDestroyGlobalObjectForDOMWindowExtension(WebPage*, WebCore::DOMWindowExtension*);

Modified: trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (115951 => 115952)


--- trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2012-05-03 09:49:29 UTC (rev 115951)
+++ trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2012-05-03 09:51:56 UTC (rev 115952)
@@ -1416,10 +1416,7 @@
     if (!webPage)
         return;
     
-    JSObjectRef globalObject = toRef(m_frame->coreFrame()->script()->globalObject(world));
-    
-    webPage->injectedBundleLoaderClient().didCreateGlobalObjectForFrame(webPage, globalObject, m_frame, world);
-    
+    webPage->injectedBundleLoaderClient().globalObjectIsAvailableForFrame(webPage, m_frame, world);
 }
 
 void WebFrameLoaderClient::dispatchWillDisconnectDOMWindowExtensionFromGlobalObject(WebCore::DOMWindowExtension* extension)

Modified: trunk/Tools/ChangeLog (115951 => 115952)


--- trunk/Tools/ChangeLog	2012-05-03 09:49:29 UTC (rev 115951)
+++ trunk/Tools/ChangeLog	2012-05-03 09:51:56 UTC (rev 115952)
@@ -1,3 +1,26 @@
+2012-05-03  Stephanie Lewis  <sle...@apple.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=85450 unbounded growth of JSDOMWindowShells loading pages in the same window
+        <rdar://problem/11320059> REGRESSION (r115083): PLT3 shows linear memory growth and gets slower with each run
+
+        Reviewed by Brady Eidson.
+
+        The API added for DOMWindowExtension, didCreateGlobalObjectForFrame, would create a global object
+        for every world, even those that did not need the callback.  This had the side effect of creating a
+        JSDOMWindowShell that the associated world didn't necessarily know to clean up.  Instead of creating
+        unnecessary objects change the API to globalObjectIsAvailableForFrame and do not pass the global object
+        in the API.  The object can be accessed later by those worlds which require it.
+
+        * TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp:
+        (TestWebKitAPI):
+        (TestWebKitAPI::didReceiveMessageFromInjectedBundle):
+        * TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp:
+        (TestWebKitAPI):
+        (DOMWindowExtensionBasic):
+        (TestWebKitAPI::DOMWindowExtensionBasic::didCreatePage):
+        (TestWebKitAPI::DOMWindowExtensionBasic::globalObjectIsAvailableForFrame):
+        (TestWebKitAPI::globalObjectIsAvailableForFrameCallback):
+
 2012-05-03  Nikolas Zimmermann  <nzimmerm...@rim.com>
 
         Not reviewed. Fix mac build, it was missing setPageVisibility/resetPageVisibility stub implementations.

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp (115951 => 115952)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp	2012-05-03 09:49:29 UTC (rev 115951)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp	2012-05-03 09:51:56 UTC (rev 115952)
@@ -36,10 +36,10 @@
 static int liveDOMExtensionCount;
 
 static const char* expectedMessages[] = {
-"DidCreateGlobalObjectForFrame called",
-"DidCreateGlobalObjectForFrame called",
-"DidCreateGlobalObjectForFrame called",
-"DidCreateGlobalObjectForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
 "Subframe finished loading",
 "Extension states:\nFirst page, main frame, standard world - Connected\nFirst page, main frame, non-standard world - Connected\nFirst page, subframe, standard world - Connected\nFirst page, subframe, non-standard world - Connected\nSecond page, main frame, standard world - Uncreated\nSecond page, main frame, non-standard world - Uncreated",
 "Main frame finished loading",
@@ -48,8 +48,8 @@
 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
-"DidCreateGlobalObjectForFrame called",
-"DidCreateGlobalObjectForFrame called",
+"GlobalObjectIsAvailableForFrame called",
+"GlobalObjectIsAvailableForFrame called",
 "Main frame finished loading",
 "Extension states:\nFirst page, main frame, standard world - Disconnected\nFirst page, main frame, non-standard world - Disconnected\nFirst page, subframe, standard world - Disconnected\nFirst page, subframe, non-standard world - Disconnected\nSecond page, main frame, standard world - Connected\nSecond page, main frame, non-standard world - Connected",
 "WillDisconnectDOMWindowExtensionFromGlobalObject called",
@@ -80,7 +80,7 @@
     WKStringRef bodyString = (WKStringRef)messageBody;
     messages.append(bodyString);
     
-    if (WKStringIsEqualToUTF8CString(messageName, "DidCreateGlobalObjectForFrame"))
+    if (WKStringIsEqualToUTF8CString(messageName, "GlobalObjectIsAvailableForFrame"))
         liveDOMExtensionCount++;
     else if (WKStringIsEqualToUTF8CString(messageName, "WillDestroyGlobalObjectForDOMWindowExtension")) {
         liveDOMExtensionCount--;

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp (115951 => 115952)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp	2012-05-03 09:49:29 UTC (rev 115951)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp	2012-05-03 09:51:56 UTC (rev 115952)
@@ -39,7 +39,7 @@
 namespace TestWebKitAPI {
 
 static void didFinishLoadForFrameCallback(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void* clientInfo);
-static void didCreateGlobalObjectForFrameCallback(WKBundlePageRef, JSObjectRef, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
+static void globalObjectIsAvailableForFrameCallback(WKBundlePageRef, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
 static void willDisconnectDOMWindowExtensionFromGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef, const void* clientInfo);
 static void didReconnectDOMWindowExtensionToGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef, const void* clientInfo);
 static void willDestroyGlobalObjectForDOMWindowExtensionCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef, const void* clientInfo);
@@ -68,7 +68,7 @@
     virtual void initialize(WKBundleRef, WKTypeRef userData);
     virtual void didCreatePage(WKBundleRef, WKBundlePageRef);
     
-    void didCreateGlobalObjectForFrame(WKBundleFrameRef, WKBundleScriptWorldRef);
+    void globalObjectIsAvailableForFrame(WKBundleFrameRef, WKBundleScriptWorldRef);
     void willDisconnectDOMWindowExtensionFromGlobalObject(WKBundleDOMWindowExtensionRef);
     void didReconnectDOMWindowExtensionToGlobalObject(WKBundleDOMWindowExtensionRef);
     void willDestroyGlobalObjectForDOMWindowExtension(WKBundleDOMWindowExtensionRef);
@@ -160,7 +160,7 @@
     pageLoaderClient.version = 1;
     pageLoaderClient.clientInfo = this;
     pageLoaderClient.didFinishLoadForFrame = didFinishLoadForFrameCallback;
-    pageLoaderClient.didCreateGlobalObjectForFrame = didCreateGlobalObjectForFrameCallback;
+    pageLoaderClient.globalObjectIsAvailableForFrame = globalObjectIsAvailableForFrameCallback;
     pageLoaderClient.willDisconnectDOMWindowExtensionFromGlobalObject = willDisconnectDOMWindowExtensionFromGlobalObjectCallback;
     pageLoaderClient.didReconnectDOMWindowExtensionToGlobalObject = didReconnectDOMWindowExtensionToGlobalObjectCallback;
     pageLoaderClient.willDestroyGlobalObjectForDOMWindowExtension = willDestroyGlobalObjectForDOMWindowExtensionCallback;
@@ -180,7 +180,7 @@
     WKBundlePostMessage(m_bundle, wkMessage.get(), wkMessage.get());
 }
 
-void DOMWindowExtensionBasic::didCreateGlobalObjectForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
+void DOMWindowExtensionBasic::globalObjectIsAvailableForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
 {
     WKBundleDOMWindowExtensionRef extension = WKBundleDOMWindowExtensionCreate(frame, world);
 
@@ -196,7 +196,7 @@
     m_extensionToRecordMap.set(extension, index);
 
     updateExtensionStateRecord(extension, Connected);
-    sendBundleMessage("DidCreateGlobalObjectForFrame called");
+    sendBundleMessage("GlobalObjectIsAvailableForFrame called");
 }
 
 void DOMWindowExtensionBasic::willDisconnectDOMWindowExtensionFromGlobalObject(WKBundleDOMWindowExtensionRef extension)
@@ -231,9 +231,9 @@
     ((DOMWindowExtensionBasic*)clientInfo)->frameLoadFinished(frame);
 }
 
-static void didCreateGlobalObjectForFrameCallback(WKBundlePageRef, JSObjectRef, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void* clientInfo)
+static void globalObjectIsAvailableForFrameCallback(WKBundlePageRef, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void* clientInfo)
 {
-    ((DOMWindowExtensionBasic*)clientInfo)->didCreateGlobalObjectForFrame(frame, world);
+    ((DOMWindowExtensionBasic*)clientInfo)->globalObjectIsAvailableForFrame(frame, world);
 }
 
 static void willDisconnectDOMWindowExtensionFromGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef extension, const void* clientInfo)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to