Changeset 115952 in webkit


Ignore:
Timestamp:
May 3, 2012 2:51:56 AM (12 years ago)
Author:
Stephanie Lewis
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):

Location:
trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r115948 r115952  
     12012-05-03  Stephanie Lewis  <slewis@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=85450 unbounded growth of JSDOMWindowShells loading pages in the same window
     4        <rdar://problem/11320059> REGRESSION (r115083): PLT3 shows linear memory growth and gets slower with each run
     5
     6        Reviewed by Brady Eidson.
     7
     8        The API added for DOMWindowExtension, didCreateGlobalObjectForFrame, would create a global object
     9        for every world, even those that did not need the callback.  This had the side effect of creating a
     10        JSDOMWindowShell that the associated world didn't necessarily know to clean up.  Instead of creating
     11        unnecessary objects change the API to globalObjectIsAvailableForFrame and do not pass the global object
     12        in the API.  The object can be accessed later by those worlds which require it.
     13
     14        * WebProcess/InjectedBundle/API/c/WKBundlePage.h:
     15        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp:
     16        (WebKit::InjectedBundlePageLoaderClient::globalObjectIsAvailableForFrame): rename API and remove globalObject parameter
     17        * WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h:
     18        (InjectedBundlePageLoaderClient): ditto
     19        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
     20        (WebKit::WebFrameLoaderClient::dispatchGlobalObjectAvailable): ditto
     21
    1222012-05-02  Alexander Færøy  <ahf@0x90.dk>
    223
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/API/c/WKBundlePage.h

    r115083 r115952  
    104104typedef void (*WKBundlePageDidHandleOnloadEventsForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef frame, const void *clientInfo);
    105105typedef bool (*WKBundlePageShouldGoToBackForwardListItemCallback)(WKBundlePageRef page, WKBundleBackForwardListItemRef item, WKTypeRef* userData, const void *clientInfo);
    106 typedef void (*WKBundlePageDidCreateGlobalObjectForFrameCallback)(WKBundlePageRef page, JSObjectRef globalObject, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
     106typedef void (*WKBundlePageGlobalObjectIsAvailableForFrameCallback)(WKBundlePageRef page, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
    107107typedef void (*WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
    108108typedef void (*WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback)(WKBundlePageRef page, WKBundleDOMWindowExtensionRef, const void* clientInfo);
     
    138138    WKBundlePageDidDetectXSSForFrameCallback                                didDetectXSSForFrame;
    139139    WKBundlePageShouldGoToBackForwardListItemCallback                       shouldGoToBackForwardListItem;
    140     WKBundlePageDidCreateGlobalObjectForFrameCallback                       didCreateGlobalObjectForFrame;
     140    WKBundlePageGlobalObjectIsAvailableForFrameCallback                     globalObjectIsAvailableForFrame;
    141141    WKBundlePageWillDisconnectDOMWindowExtensionFromGlobalObjectCallback    willDisconnectDOMWindowExtensionFromGlobalObject;
    142142    WKBundlePageDidReconnectDOMWindowExtensionToGlobalObjectCallback        didReconnectDOMWindowExtensionToGlobalObject;
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.cpp

    r115083 r115952  
    250250}
    251251
    252 void InjectedBundlePageLoaderClient::didCreateGlobalObjectForFrame(WebPage* page, JSObjectRef globalObject, WebFrame* frame, WebCore::DOMWrapperWorld* world)
    253 {
    254     if (!m_client.didCreateGlobalObjectForFrame)
     252void InjectedBundlePageLoaderClient::globalObjectIsAvailableForFrame(WebPage* page, WebFrame* frame, WebCore::DOMWrapperWorld* world)
     253{
     254    if (!m_client.globalObjectIsAvailableForFrame)
    255255        return;
    256256   
    257257    RefPtr<InjectedBundleScriptWorld> injectedWorld = InjectedBundleScriptWorld::getOrCreate(world);
    258     m_client.didCreateGlobalObjectForFrame(toAPI(page), globalObject, toAPI(frame), toAPI(injectedWorld.get()), m_client.clientInfo);
     258    m_client.globalObjectIsAvailableForFrame(toAPI(page), toAPI(frame), toAPI(injectedWorld.get()), m_client.clientInfo);
    259259}
    260260
  • trunk/Source/WebKit2/WebProcess/InjectedBundle/InjectedBundlePageLoaderClient.h

    r115083 r115952  
    7575    void didHandleOnloadEventsForFrame(WebPage*, WebFrame*);
    7676
    77     void didCreateGlobalObjectForFrame(WebPage*, JSObjectRef globalObject, WebFrame*, WebCore::DOMWrapperWorld*);
     77    void globalObjectIsAvailableForFrame(WebPage*, WebFrame*, WebCore::DOMWrapperWorld*);
    7878    void willDisconnectDOMWindowExtensionFromGlobalObject(WebPage*, WebCore::DOMWindowExtension*);
    7979    void didReconnectDOMWindowExtensionToGlobalObject(WebPage*, WebCore::DOMWindowExtension*);
  • trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp

    r115926 r115952  
    14171417        return;
    14181418   
    1419     JSObjectRef globalObject = toRef(m_frame->coreFrame()->script()->globalObject(world));
    1420    
    1421     webPage->injectedBundleLoaderClient().didCreateGlobalObjectForFrame(webPage, globalObject, m_frame, world);
    1422    
     1419    webPage->injectedBundleLoaderClient().globalObjectIsAvailableForFrame(webPage, m_frame, world);
    14231420}
    14241421
  • trunk/Tools/ChangeLog

    r115949 r115952  
     12012-05-03  Stephanie Lewis  <slewis@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=85450 unbounded growth of JSDOMWindowShells loading pages in the same window
     4        <rdar://problem/11320059> REGRESSION (r115083): PLT3 shows linear memory growth and gets slower with each run
     5
     6        Reviewed by Brady Eidson.
     7
     8        The API added for DOMWindowExtension, didCreateGlobalObjectForFrame, would create a global object
     9        for every world, even those that did not need the callback.  This had the side effect of creating a
     10        JSDOMWindowShell that the associated world didn't necessarily know to clean up.  Instead of creating
     11        unnecessary objects change the API to globalObjectIsAvailableForFrame and do not pass the global object
     12        in the API.  The object can be accessed later by those worlds which require it.
     13
     14        * TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp:
     15        (TestWebKitAPI):
     16        (TestWebKitAPI::didReceiveMessageFromInjectedBundle):
     17        * TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp:
     18        (TestWebKitAPI):
     19        (DOMWindowExtensionBasic):
     20        (TestWebKitAPI::DOMWindowExtensionBasic::didCreatePage):
     21        (TestWebKitAPI::DOMWindowExtensionBasic::globalObjectIsAvailableForFrame):
     22        (TestWebKitAPI::globalObjectIsAvailableForFrameCallback):
     23
    1242012-05-03  Nikolas Zimmermann  <nzimmermann@rim.com>
    225
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic.cpp

    r115083 r115952  
    3737
    3838static const char* expectedMessages[] = {
    39 "DidCreateGlobalObjectForFrame called",
    40 "DidCreateGlobalObjectForFrame called",
    41 "DidCreateGlobalObjectForFrame called",
    42 "DidCreateGlobalObjectForFrame called",
     39"GlobalObjectIsAvailableForFrame called",
     40"GlobalObjectIsAvailableForFrame called",
     41"GlobalObjectIsAvailableForFrame called",
     42"GlobalObjectIsAvailableForFrame called",
    4343"Subframe finished loading",
    4444"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",
     
    4949"WillDisconnectDOMWindowExtensionFromGlobalObject called",
    5050"WillDisconnectDOMWindowExtensionFromGlobalObject called",
    51 "DidCreateGlobalObjectForFrame called",
    52 "DidCreateGlobalObjectForFrame called",
     51"GlobalObjectIsAvailableForFrame called",
     52"GlobalObjectIsAvailableForFrame called",
    5353"Main frame finished loading",
    5454"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",
     
    8181    messages.append(bodyString);
    8282   
    83     if (WKStringIsEqualToUTF8CString(messageName, "DidCreateGlobalObjectForFrame"))
     83    if (WKStringIsEqualToUTF8CString(messageName, "GlobalObjectIsAvailableForFrame"))
    8484        liveDOMExtensionCount++;
    8585    else if (WKStringIsEqualToUTF8CString(messageName, "WillDestroyGlobalObjectForDOMWindowExtension")) {
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2/DOMWindowExtensionBasic_Bundle.cpp

    r115083 r115952  
    4040
    4141static void didFinishLoadForFrameCallback(WKBundlePageRef, WKBundleFrameRef, WKTypeRef*, const void* clientInfo);
    42 static void didCreateGlobalObjectForFrameCallback(WKBundlePageRef, JSObjectRef, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
     42static void globalObjectIsAvailableForFrameCallback(WKBundlePageRef, WKBundleFrameRef, WKBundleScriptWorldRef, const void* clientInfo);
    4343static void willDisconnectDOMWindowExtensionFromGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef, const void* clientInfo);
    4444static void didReconnectDOMWindowExtensionToGlobalObjectCallback(WKBundlePageRef, WKBundleDOMWindowExtensionRef, const void* clientInfo);
     
    6969    virtual void didCreatePage(WKBundleRef, WKBundlePageRef);
    7070   
    71     void didCreateGlobalObjectForFrame(WKBundleFrameRef, WKBundleScriptWorldRef);
     71    void globalObjectIsAvailableForFrame(WKBundleFrameRef, WKBundleScriptWorldRef);
    7272    void willDisconnectDOMWindowExtensionFromGlobalObject(WKBundleDOMWindowExtensionRef);
    7373    void didReconnectDOMWindowExtensionToGlobalObject(WKBundleDOMWindowExtensionRef);
     
    161161    pageLoaderClient.clientInfo = this;
    162162    pageLoaderClient.didFinishLoadForFrame = didFinishLoadForFrameCallback;
    163     pageLoaderClient.didCreateGlobalObjectForFrame = didCreateGlobalObjectForFrameCallback;
     163    pageLoaderClient.globalObjectIsAvailableForFrame = globalObjectIsAvailableForFrameCallback;
    164164    pageLoaderClient.willDisconnectDOMWindowExtensionFromGlobalObject = willDisconnectDOMWindowExtensionFromGlobalObjectCallback;
    165165    pageLoaderClient.didReconnectDOMWindowExtensionToGlobalObject = didReconnectDOMWindowExtensionToGlobalObjectCallback;
     
    181181}
    182182
    183 void DOMWindowExtensionBasic::didCreateGlobalObjectForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
     183void DOMWindowExtensionBasic::globalObjectIsAvailableForFrame(WKBundleFrameRef frame, WKBundleScriptWorldRef world)
    184184{
    185185    WKBundleDOMWindowExtensionRef extension = WKBundleDOMWindowExtensionCreate(frame, world);
     
    197197
    198198    updateExtensionStateRecord(extension, Connected);
    199     sendBundleMessage("DidCreateGlobalObjectForFrame called");
     199    sendBundleMessage("GlobalObjectIsAvailableForFrame called");
    200200}
    201201
     
    232232}
    233233
    234 static void didCreateGlobalObjectForFrameCallback(WKBundlePageRef, JSObjectRef, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void* clientInfo)
    235 {
    236     ((DOMWindowExtensionBasic*)clientInfo)->didCreateGlobalObjectForFrame(frame, world);
     234static void globalObjectIsAvailableForFrameCallback(WKBundlePageRef, WKBundleFrameRef frame, WKBundleScriptWorldRef world, const void* clientInfo)
     235{
     236    ((DOMWindowExtensionBasic*)clientInfo)->globalObjectIsAvailableForFrame(frame, world);
    237237}
    238238
Note: See TracChangeset for help on using the changeset viewer.