Title: [289260] branches/safari-613-branch/Source
Revision
289260
Author
[email protected]
Date
2022-02-07 18:52:17 -0800 (Mon, 07 Feb 2022)

Log Message

Cherry-pick r287914. rdar://problem/85451366

    Protect DocumentLoader when a reference to its members is used.
    https://bugs.webkit.org/show_bug.cgi?id=233464

    Patch by Frédéric Wang <[email protected]> on 2022-01-12
    Reviewed by Brady Eidson.

    Source/WebCore:

    No new tests, due to our infra (bug 127676).

    * loader/FrameLoader.cpp:
    (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Ensure that DocumentLoader loader
    remains alive while DocumentLoader::m_mainDocumentError is used.

    Source/WebKit:

    * UIProcess/WebPageProxy.cpp:
    (WebKit::WebPageProxy::didFinishLoadForFrame): If the navigationID is obsolete, skip update
    of the page load state to avoid failure of debug ASSERT.
    * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
    (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad): Ensure that DocumentLoader loader
    remains alive while DocumentLoader::m_request is used.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287914 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (289259 => 289260)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-02-08 02:52:14 UTC (rev 289259)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-02-08 02:52:17 UTC (rev 289260)
@@ -1,5 +1,47 @@
 2022-02-07  Russell Epstein  <[email protected]>
 
+        Cherry-pick r287914. rdar://problem/85451366
+
+    Protect DocumentLoader when a reference to its members is used.
+    https://bugs.webkit.org/show_bug.cgi?id=233464
+    
+    Patch by Frédéric Wang <[email protected]> on 2022-01-12
+    Reviewed by Brady Eidson.
+    
+    Source/WebCore:
+    
+    No new tests, due to our infra (bug 127676).
+    
+    * loader/FrameLoader.cpp:
+    (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Ensure that DocumentLoader loader
+    remains alive while DocumentLoader::m_mainDocumentError is used.
+    
+    Source/WebKit:
+    
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::didFinishLoadForFrame): If the navigationID is obsolete, skip update
+    of the page load state to avoid failure of debug ASSERT.
+    * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+    (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad): Ensure that DocumentLoader loader
+    remains alive while DocumentLoader::m_request is used.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287914 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-12  Frédéric Wang  <[email protected]>
+
+            Protect DocumentLoader when a reference to its members is used.
+            https://bugs.webkit.org/show_bug.cgi?id=233464
+
+            Reviewed by Brady Eidson.
+
+            No new tests, due to our infra (bug 127676).
+
+            * loader/FrameLoader.cpp:
+            (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Ensure that DocumentLoader loader
+            remains alive while DocumentLoader::m_mainDocumentError is used.
+
+2022-02-07  Russell Epstein  <[email protected]>
+
         Cherry-pick r287899. rdar://problem/83925935
 
     DataURLResourceMediaLoader decodes the URL repeatedly during a video playback

Modified: branches/safari-613-branch/Source/WebCore/loader/FrameLoader.cpp (289259 => 289260)


--- branches/safari-613-branch/Source/WebCore/loader/FrameLoader.cpp	2022-02-08 02:52:14 UTC (rev 289259)
+++ branches/safari-613-branch/Source/WebCore/loader/FrameLoader.cpp	2022-02-08 02:52:17 UTC (rev 289260)
@@ -2585,7 +2585,8 @@
         if (RefPtr domWindow = m_frame.document() ? m_frame.document()->domWindow() : nullptr)
             domWindow->performance().scheduleNavigationObservationTaskIfNeeded();
 
-        const ResourceError& error = m_documentLoader->mainDocumentError();
+        Ref protector = *m_documentLoader;
+        const ResourceError& error = protector->mainDocumentError();
 
         AXObjectCache::AXLoadingEvent loadingEvent;
         if (!error.isNull()) {

Modified: branches/safari-613-branch/Source/WebKit/ChangeLog (289259 => 289260)


--- branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:52:14 UTC (rev 289259)
+++ branches/safari-613-branch/Source/WebKit/ChangeLog	2022-02-08 02:52:17 UTC (rev 289260)
@@ -1,3 +1,46 @@
+2022-02-07  Russell Epstein  <[email protected]>
+
+        Cherry-pick r287914. rdar://problem/85451366
+
+    Protect DocumentLoader when a reference to its members is used.
+    https://bugs.webkit.org/show_bug.cgi?id=233464
+    
+    Patch by Frédéric Wang <[email protected]> on 2022-01-12
+    Reviewed by Brady Eidson.
+    
+    Source/WebCore:
+    
+    No new tests, due to our infra (bug 127676).
+    
+    * loader/FrameLoader.cpp:
+    (WebCore::FrameLoader::checkLoadCompleteForThisFrame): Ensure that DocumentLoader loader
+    remains alive while DocumentLoader::m_mainDocumentError is used.
+    
+    Source/WebKit:
+    
+    * UIProcess/WebPageProxy.cpp:
+    (WebKit::WebPageProxy::didFinishLoadForFrame): If the navigationID is obsolete, skip update
+    of the page load state to avoid failure of debug ASSERT.
+    * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+    (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad): Ensure that DocumentLoader loader
+    remains alive while DocumentLoader::m_request is used.
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@287914 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-12  Frédéric Wang  <[email protected]>
+
+            Protect DocumentLoader when a reference to its members is used.
+            https://bugs.webkit.org/show_bug.cgi?id=233464
+
+            Reviewed by Brady Eidson.
+
+            * UIProcess/WebPageProxy.cpp:
+            (WebKit::WebPageProxy::didFinishLoadForFrame): If the navigationID is obsolete, skip update
+            of the page load state to avoid failure of debug ASSERT.
+            * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+            (WebKit::WebFrameLoaderClient::dispatchDidFinishLoad): Ensure that DocumentLoader loader
+            remains alive while DocumentLoader::m_request is used.
+
 2022-02-02  Russell Epstein  <[email protected]>
 
         Apply patch. rdar://problem/86150540

Modified: branches/safari-613-branch/Source/WebKit/UIProcess/WebPageProxy.cpp (289259 => 289260)


--- branches/safari-613-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-02-08 02:52:14 UTC (rev 289259)
+++ branches/safari-613-branch/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-02-08 02:52:17 UTC (rev 289260)
@@ -5020,23 +5020,26 @@
 
     // FIXME: We should message check that navigationID is not zero here, but it's currently zero for some navigations through the back/forward cache.
     RefPtr<API::Navigation> navigation;
-    if (frame->isMainFrame() && navigationID)
+    if (frame->isMainFrame() && navigationID && navigationState().hasNavigation(navigationID))
         navigation = navigationState().navigation(navigationID);
 
-    auto transaction = m_pageLoadState.transaction();
-
     bool isMainFrame = frame->isMainFrame();
-    if (isMainFrame)
-        m_pageLoadState.didFinishLoad(transaction);
+    if (!isMainFrame || !navigationID || navigation) {
+        auto transaction = m_pageLoadState.transaction();
 
-    if (m_controlledByAutomation) {
-        if (auto* automationSession = process().processPool().automationSession())
-            automationSession->navigationOccurredForFrame(*frame);
+        if (isMainFrame)
+            m_pageLoadState.didFinishLoad(transaction);
+
+        if (m_controlledByAutomation) {
+            if (auto* automationSession = process().processPool().automationSession())
+                automationSession->navigationOccurredForFrame(*frame);
+        }
+
+        frame->didFinishLoad();
+
+        m_pageLoadState.commitChanges();
     }
 
-    frame->didFinishLoad();
-
-    m_pageLoadState.commitChanges();
     if (m_loaderClient)
         m_loaderClient->didFinishLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
     else {

Modified: branches/safari-613-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp (289259 => 289260)


--- branches/safari-613-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2022-02-08 02:52:14 UTC (rev 289259)
+++ branches/safari-613-branch/Source/WebKit/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp	2022-02-08 02:52:17 UTC (rev 289260)
@@ -671,14 +671,14 @@
 
     RefPtr<API::Object> userData;
 
-    auto& documentLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader());
-    auto navigationID = documentLoader.navigationID();
+    Ref documentLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().documentLoader());
+    auto navigationID = documentLoader->navigationID();
 
     // Notify the bundle client.
     webPage->injectedBundleLoaderClient().didFinishLoadForFrame(*webPage, m_frame, userData);
 
     // Notify the UIProcess.
-    webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), m_frame->info(), documentLoader.request(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
+    webPage->send(Messages::WebPageProxy::DidFinishLoadForFrame(m_frame->frameID(), m_frame->info(), documentLoader->request(), navigationID, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 
     // If we have a load listener, notify it.
     if (WebFrame::LoadListener* loadListener = m_frame->loadListener())
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to