Title: [275563] trunk/Source
Revision
275563
Author
[email protected]
Date
2021-04-06 15:37:57 -0700 (Tue, 06 Apr 2021)

Log Message

Add additional page load diagnostic logging
https://bugs.webkit.org/show_bug.cgi?id=224194
<rdar://problem/76227175>

Reviewed by Alex Christensen.

This patch adds new logging to help us diagnose and investigate page load failures.

Source/WebCore:

* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::init): Add logging for some unusual conditions:
    (1) A loader cannot be created because the document loader is nullptr.
    (2) A load is cancelled because it violates security policy.
    (3) A load was cancelled during 'willSendRequest' processing.
    (4) A load was cancelled because the request was null.
(WebCore::ResourceLoader::loadDataURL): Log when a data load was cancelled.
(WebCore::ResourceLoader::willSendRequestInternal): Log when a cross-origin redirect is triggered, and when a redirect is
to a dataURL and will be handled locally.
(WebCore::ResourceLoader::didFinishLoadingOnePart): Log when a load is cancelled after it finished.
* loader/SubresourceLoader.cpp:
(WebCore::SubresourceLoader::willSendRequestInternal):  Log when an ongoing load has unexpectedly reached terminal state. Remove a
spammy log message that indicates when a redirect response is null (which just means its a normal load).
(WebCore::SubresourceLoader::didFinishLoading): Log when a finished load unexpectedly did not reach terminal state.
(WebCore::SubresourceLoader::notifyDone): Log when a load could not finish because the document loader was nullptr.

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::didClose): Log when the connection from a WebProcess requesting a load
is closed.
(WebKit::NetworkConnectionToWebProcess::removeLoadIdentifier): Log when the WebProcess requests a load
identifier be removed (and cancelled).
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::restartNetworkLoad): Log when an in-process load is cancelled so that the load
can be restarted.
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::didClose): Log when the network process crashes.
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::didClose): Add logging when the WebProcess crashes.
* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad): Remove an erroneous log message that made it appear that no URL handler
had been called. The log message was generated when a normal network load handler was executed, leading to
confusing troubleshooting logs.
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::registerURLSchemeHandler): Log when a web page registers a custom URL handler, and for which scheme.
* WebProcess/WebPage/WebURLSchemeTaskProxy.cpp:
(WebKit::pageIDFromWebFrame): Added helper.
(WebKit::frameIDFromWebFrame): Ditto.
(WebKit::WebURLSchemeTaskProxy::startLoading): Add logging to track progress of custom URL handlers.
(WebKit::WebURLSchemeTaskProxy::stopLoading): Ditto.
(WebKit::WebURLSchemeTaskProxy::didPerformRedirection): Ditto.
(WebKit::WebURLSchemeTaskProxy::didReceiveResponse): Ditto.
(WebKit::WebURLSchemeTaskProxy::didReceiveData): Ditto.
(WebKit::WebURLSchemeTaskProxy::didComplete): Ditto.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::networkProcessConnectionClosed): Add logging that the network process crashed.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (275562 => 275563)


--- trunk/Source/WebCore/ChangeLog	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebCore/ChangeLog	2021-04-06 22:37:57 UTC (rev 275563)
@@ -1,3 +1,29 @@
+2021-04-06  Brent Fulgham  <[email protected]>
+
+        Add additional page load diagnostic logging
+        https://bugs.webkit.org/show_bug.cgi?id=224194
+        <rdar://problem/76227175>
+
+        Reviewed by Alex Christensen.
+
+        This patch adds new logging to help us diagnose and investigate page load failures.
+
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::init): Add logging for some unusual conditions:
+            (1) A loader cannot be created because the document loader is nullptr.
+            (2) A load is cancelled because it violates security policy.
+            (3) A load was cancelled during 'willSendRequest' processing.
+            (4) A load was cancelled because the request was null.
+        (WebCore::ResourceLoader::loadDataURL): Log when a data load was cancelled.
+        (WebCore::ResourceLoader::willSendRequestInternal): Log when a cross-origin redirect is triggered, and when a redirect is
+        to a dataURL and will be handled locally.
+        (WebCore::ResourceLoader::didFinishLoadingOnePart): Log when a load is cancelled after it finished.
+        * loader/SubresourceLoader.cpp:
+        (WebCore::SubresourceLoader::willSendRequestInternal):  Log when an ongoing load has unexpectedly reached terminal state. Remove a
+        spammy log message that indicates when a redirect response is null (which just means its a normal load).
+        (WebCore::SubresourceLoader::didFinishLoading): Log when a finished load unexpectedly did not reach terminal state.
+        (WebCore::SubresourceLoader::notifyDone): Log when a load could not finish because the document loader was nullptr.
+
 2021-04-06  Patrick Angle  <[email protected]>
 
         Web Inspector: Grid overlay label style cleanup

Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (275562 => 275563)


--- trunk/Source/WebCore/loader/ResourceLoader.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
  *           (C) 2007 Graham Dennis ([email protected])
  *
  * Redistribution and use in source and binary forms, with or without
@@ -124,6 +124,10 @@
 void ResourceLoader::init(ResourceRequest&& clientRequest, CompletionHandler<void(bool)>&& completionHandler)
 {
     if (!m_documentLoader || !m_documentLoader->frame()) {
+        if (!m_documentLoader)
+            RELEASE_LOG_IF_ALLOWED("init: Cancelling because there is no document loader.");
+        else
+            RELEASE_LOG_IF_ALLOWED("init: Cancelling because the document loader has no frame.");
         cancel();
         return completionHandler(false);
     }
@@ -138,6 +142,7 @@
     m_defersLoading = m_options.defersLoadingPolicy == DefersLoadingPolicy::AllowDefersLoading && m_frame->page()->defersLoading();
 
     if (m_options.securityCheck == SecurityCheckPolicy::DoSecurityCheck && !m_frame->document()->securityOrigin().canDisplay(clientRequest.url())) {
+        RELEASE_LOG_IF_ALLOWED("init: Cancelling load because it violates security policy.");
         FrameLoader::reportLocalLoadFailed(m_frame.get(), clientRequest.url().string());
         releaseResources();
         return completionHandler(false);
@@ -158,11 +163,14 @@
 
 #if PLATFORM(IOS_FAMILY)
         // If this ResourceLoader was stopped as a result of willSendRequest, bail out.
-        if (m_reachedTerminalState)
+        if (m_reachedTerminalState) {
+            RELEASE_LOG_IF_ALLOWED("init: Cancelling load because it was stopped as a result of willSendRequest.");
             return completionHandler(false);
+        }
 #endif
 
         if (request.isNull()) {
+            RELEASE_LOG_IF_ALLOWED("init: Cancelling load because the request is null.");
             cancel();
             return completionHandler(false);
         }
@@ -269,8 +277,10 @@
             protectedThis->didFail(ResourceError(errorDomainWebKitInternal, 0, url, "Data URL decoding failed"));
             return;
         }
-        if (this->wasCancelled())
+        if (this->wasCancelled()) {
+            RELEASE_LOG_IF_ALLOWED("loadDataURL: Load was cancelled");
             return;
+        }
 
         auto dataSize = decodeResult->data.size();
         ResourceResponse dataResponse = ResourceResponse::dataURLResponse(url, decodeResult.value());
@@ -402,6 +412,7 @@
 
     bool isRedirect = !redirectResponse.isNull();
     if (isRedirect) {
+        RELEASE_LOG_IF_ALLOWED("willSendRequestInternal: Processing cross-origin redirect");
         platformStrategies()->loaderStrategy()->crossOriginRedirectReceived(this, request.url());
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
         frameLoader()->client().didLoadFromRegistrableDomain(RegistrableDomain(request.url()));
@@ -416,6 +427,7 @@
 
         if (redirectURL.protocolIsData()) {
             // Handle data URL decoding locally.
+            RELEASE_LOG_IF_ALLOWED("willSendRequestInternal: Redirected to a data URL. Processing locally");
             finishNetworkLoad();
             loadDataURL();
         }
@@ -565,8 +577,10 @@
 {
     // If load has been cancelled after finishing (which could happen with a
     // _javascript_ that changes the window location), do nothing.
-    if (wasCancelled())
+    if (wasCancelled()) {
+        RELEASE_LOG_IF_ALLOWED("didFinishLoadingOnePart: Load was cancelled after finishing.");
         return;
+    }
     ASSERT(!m_reachedTerminalState);
 
     if (m_notifiedLoadComplete)
@@ -847,5 +861,6 @@
 
 } // namespace WebCore
 
+#undef RELEASE_LOG_IF_ALLOWED
 #undef PAGE_ID
 #undef FRAME_ID

Modified: trunk/Source/WebCore/loader/SubresourceLoader.cpp (275562 => 275563)


--- trunk/Source/WebCore/loader/SubresourceLoader.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebCore/loader/SubresourceLoader.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2006-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -211,8 +211,10 @@
         }
 
         ResourceLoader::willSendRequestInternal(WTFMove(newRequest), redirectResponse, [this, protectedThis = WTFMove(protectedThis), completionHandler = WTFMove(completionHandler), redirectResponse] (ResourceRequest&& request) mutable {
-            if (reachedTerminalState())
+            if (reachedTerminalState()) {
+                RELEASE_LOG_IF_ALLOWED("willSendRequestInternal: reached terminal state; calling completion handler");
                 return completionHandler(WTFMove(request));
+            }
 
             if (request.isNull()) {
                 RELEASE_LOG_IF_ALLOWED("willSendRequestInternal: resource load canceled because request is NULL (2)");
@@ -303,7 +305,6 @@
         return;
     }
 
-    RELEASE_LOG_IF_ALLOWED("willSendRequestInternal: redirect response is NULL");
     continueWillSendRequest(WTFMove(completionHandler), WTFMove(newRequest));
 }
 
@@ -749,6 +750,7 @@
         RELEASE_LOG_IF_ALLOWED("didFinishLoading: reached terminal state");
         return;
     }
+    RELEASE_LOG_IF_ALLOWED("didFinishLoading: Did not reach terminal state");
     releaseResources();
 }
 
@@ -847,10 +849,15 @@
 #endif
     if (m_documentLoader)
         m_documentLoader->cachedResourceLoader().loadDone(type, shouldPerformPostLoadActions);
+    else
+        RELEASE_LOG_ERROR_IF_ALLOWED("notifyDone: document loader is null. Could not call loadDone()");
+
     if (reachedTerminalState())
         return;
     if (m_documentLoader)
         m_documentLoader->removeSubresourceLoader(type, this);
+    else
+        RELEASE_LOG_ERROR_IF_ALLOWED("notifyDone: document loader is null. Could not call removeSubresourceLoader()");
 }
 
 void SubresourceLoader::releaseResources()

Modified: trunk/Source/WebKit/ChangeLog (275562 => 275563)


--- trunk/Source/WebKit/ChangeLog	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/ChangeLog	2021-04-06 22:37:57 UTC (rev 275563)
@@ -1,3 +1,43 @@
+2021-04-06  Brent Fulgham  <[email protected]>
+
+        Add additional page load diagnostic logging
+        https://bugs.webkit.org/show_bug.cgi?id=224194
+        <rdar://problem/76227175>
+
+        Reviewed by Alex Christensen.
+
+        This patch adds new logging to help us diagnose and investigate page load failures.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::didClose): Log when the connection from a WebProcess requesting a load
+        is closed.
+        (WebKit::NetworkConnectionToWebProcess::removeLoadIdentifier): Log when the WebProcess requests a load
+        identifier be removed (and cancelled).
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::restartNetworkLoad): Log when an in-process load is cancelled so that the load
+        can be restarted.
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::didClose): Log when the network process crashes.
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::didClose): Add logging when the WebProcess crashes.
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::scheduleLoad): Remove an erroneous log message that made it appear that no URL handler
+        had been called. The log message was generated when a normal network load handler was executed, leading to
+        confusing troubleshooting logs.
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::registerURLSchemeHandler): Log when a web page registers a custom URL handler, and for which scheme.
+        * WebProcess/WebPage/WebURLSchemeTaskProxy.cpp:
+        (WebKit::pageIDFromWebFrame): Added helper.
+        (WebKit::frameIDFromWebFrame): Ditto.
+        (WebKit::WebURLSchemeTaskProxy::startLoading): Add logging to track progress of custom URL handlers.
+        (WebKit::WebURLSchemeTaskProxy::stopLoading): Ditto.
+        (WebKit::WebURLSchemeTaskProxy::didPerformRedirection): Ditto.
+        (WebKit::WebURLSchemeTaskProxy::didReceiveResponse): Ditto.
+        (WebKit::WebURLSchemeTaskProxy::didReceiveData): Ditto.
+        (WebKit::WebURLSchemeTaskProxy::didComplete): Ditto.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::networkProcessConnectionClosed): Add logging that the network process crashed.
+
 2021-04-06  Devin Rousso  <[email protected]>
 
         [iOS] contextmenu hints can be clipped by the WKWebView

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (275562 => 275563)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -360,6 +360,12 @@
     // Protect ourself as we might be otherwise be deleted during this function.
     Ref<NetworkConnectionToWebProcess> protector(*this);
 
+#if OS(DARWIN)
+    RELEASE_LOG_IF_ALLOWED(Loading, "didClose: WebProcess (%d) closed its connection. Aborting related loaders.", connection.remoteProcessID());
+#else
+    RELEASE_LOG_IF_ALLOWED(Loading, "didClose: WebProcess closed its connection. Aborting related loaders.");
+#endif
+
     while (!m_networkResourceLoaders.isEmpty())
         m_networkResourceLoaders.begin()->value->abort();
 
@@ -557,6 +563,7 @@
 
     // Abort the load now, as the WebProcess won't be able to respond to messages any more which might lead
     // to leaked loader resources (connections, threads, etc).
+    RELEASE_LOG_IF_ALLOWED(Loading, "removeLoadIdentifier: Removing identifier %" PRIu64 " and aborting corresponding loader", identifier);
     loader->abort();
     ASSERT(!m_networkResourceLoaders.contains(identifier));
 }
@@ -1237,5 +1244,6 @@
 
 } // namespace WebKit
 
+#undef RELEASE_LOG_IF_ALLOWED
 #undef NETWORK_PROCESS_MESSAGE_CHECK_COMPLETION
 #undef NETWORK_PROCESS_MESSAGE_CHECK

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (275562 => 275563)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012-2019 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -65,6 +65,7 @@
 #include <WebCore/PreviewConverter.h>
 #endif
 
+#undef RELEASE_LOG_IF_ALLOWED
 #define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), Network, "%p - [pageProxyID=%" PRIu64 ", webPageID=%" PRIu64 ", frameID=%" PRIu64 ", resourceID=%" PRIu64 ", isMainResource=%d, destination=%u, isSynchronous=%d] NetworkResourceLoader::" fmt, this, m_parameters.webPageProxyID.toUInt64(), m_parameters.webPageID.toUInt64(), m_parameters.webFrameID.toUInt64(), m_parameters.identifier, isMainResource(), static_cast<unsigned>(m_parameters.options.destination), isSynchronous(), ##__VA_ARGS__)
 #define RELEASE_LOG_ERROR_IF_ALLOWED(fmt, ...) RELEASE_LOG_ERROR_IF(isAlwaysOnLoggingAllowed(), Network, "%p - [pageProxyID=%" PRIu64 ", webPageID=%" PRIu64 ", frameID=%" PRIu64 ", resourceID=%" PRIu64 ", isMainResource=%d, destination=%u, isSynchronous=%d] NetworkResourceLoader::" fmt, this, m_parameters.webPageProxyID.toUInt64(), m_parameters.webPageID.toUInt64(), m_parameters.webFrameID.toUInt64(), m_parameters.identifier, isMainResource(), static_cast<unsigned>(m_parameters.options.destination), isSynchronous(), ##__VA_ARGS__)
 
@@ -939,8 +940,10 @@
 {
     RELEASE_LOG_IF_ALLOWED("restartNetworkLoad: (hasNetworkLoad=%d)", !!m_networkLoad);
 
-    if (m_networkLoad)
+    if (m_networkLoad) {
+        RELEASE_LOG_IF_ALLOWED("restartNetworkLoad: Cancelling existing network load so we can restart the load.");
         m_networkLoad->cancel();
+    }
 
     startNetworkLoad(WTFMove(newRequest), FirstLoad::No);
 }

Modified: trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp (275562 => 275563)


--- trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -336,8 +336,14 @@
     return didReceiveSyncNetworkProcessProxyMessage(connection, decoder, replyEncoder);
 }
 
-void NetworkProcessProxy::didClose(IPC::Connection&)
+void NetworkProcessProxy::didClose(IPC::Connection& connection)
 {
+#if OS(DARWIN)
+    RELEASE_LOG_ERROR(Process, "%p - NetworkProcessProxy::didClose (Network Process %d crash)", this, connection.remoteProcessID());
+#else
+    RELEASE_LOG_ERROR(Process, "%p - NetworkProcessProxy::didClose (Network Process crash)", this);
+#endif
+
     // This will cause us to be deleted.
     networkProcessDidTerminate(TerminationReason::Crash);
 }

Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (275562 => 275563)


--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -845,9 +845,14 @@
     return false;
 }
 
-void WebProcessProxy::didClose(IPC::Connection&)
+void WebProcessProxy::didClose(IPC::Connection& connection)
 {
+#if OS(DARWIN)
+    RELEASE_LOG_IF(isReleaseLoggingAllowed(), Process, "%p - WebProcessProxy didClose (web process %d crash)", this, connection.remoteProcessID());
+#else
     RELEASE_LOG_IF(isReleaseLoggingAllowed(), Process, "%p - WebProcessProxy didClose (web process crash)", this);
+#endif
+
     processDidTerminateOrFailedToLaunch(ProcessTerminationReason::Crash);
 }
 

Modified: trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp (275562 => 275563)


--- trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2012, 2015, 2018 Apple Inc. All rights reserved.
+ * Copyright (C) 2012-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -80,6 +80,7 @@
 
 #define RELEASE_LOG_IS_ALLOWED (WebProcess::singleton().sessionID().isAlwaysOnLoggingAllowed())
 
+#undef RELEASE_LOG_IF_ALLOWED
 #define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(RELEASE_LOG_IS_ALLOWED, Network, "%p - WebLoaderStrategy::" fmt, this, ##__VA_ARGS__)
 #define RELEASE_LOG_ERROR_IF_ALLOWED(fmt, ...) RELEASE_LOG_ERROR_IF(RELEASE_LOG_IS_ALLOWED, Network, "%p - WebLoaderStrategy::" fmt, this, ##__VA_ARGS__)
 
@@ -248,8 +249,6 @@
         scheduleLoadFromNetworkProcess(resourceLoader, resourceLoader.request(), trackingParameters, shouldClearReferrerOnHTTPSToHTTPRedirect, maximumBufferingTime(resource));
         return;
     }
-
-    WEBLOADERSTRATEGY_RELEASE_LOG_IF_ALLOWED("scheduleLoad: URL not handled by any handlers");
 }
 
 bool WebLoaderStrategy::tryLoadingUsingURLSchemeHandler(ResourceLoader& resourceLoader, const WebResourceLoader::TrackingParameters& trackingParameters)
@@ -916,3 +915,4 @@
 
 #undef RELEASE_LOG_IF_ALLOWED
 #undef RELEASE_LOG_ERROR_IF_ALLOWED
+#undef RELEASE_LOG_IS_ALLOWED

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (275562 => 275563)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -377,6 +377,7 @@
 static const Seconds initialLayerVolatilityTimerInterval { 20_ms };
 static const Seconds maximumLayerVolatilityTimerInterval { 2_s };
 
+#undef RELEASE_LOG_IF_ALLOWED
 #define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), channel, "%p - [webPageID=%" PRIu64 "] WebPage::" fmt, this, m_identifier.toUInt64(), ##__VA_ARGS__)
 #define RELEASE_LOG_ERROR_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_ERROR_IF(isAlwaysOnLoggingAllowed(), channel, "%p - [webPageID=%" PRIu64 "] WebPage::" fmt, this, m_identifier.toUInt64(), ##__VA_ARGS__)
 
@@ -6747,6 +6748,7 @@
 
 void WebPage::registerURLSchemeHandler(uint64_t handlerIdentifier, const String& scheme)
 {
+    RELEASE_LOG_IF_ALLOWED(Process, "registerURLSchemeHandler: Registered handler %" PRIu64 " for the '%s' scheme", handlerIdentifier, scheme.utf8().data());
     WebCore::LegacySchemeRegistry::registerURLSchemeAsHandledBySchemeHandler(scheme);
     WebCore::LegacySchemeRegistry::registerURLSchemeAsCORSEnabled(scheme);
     auto schemeResult = m_schemeToURLSchemeHandlerProxyMap.add(scheme, WebURLSchemeHandlerProxy::create(*this, handlerIdentifier));

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebURLSchemeTaskProxy.cpp (275562 => 275563)


--- trunk/Source/WebKit/WebProcess/WebPage/WebURLSchemeTaskProxy.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebURLSchemeTaskProxy.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2017 Apple Inc. All rights reserved.
+ * Copyright (C) 2017-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,9 +38,36 @@
 #include <WebCore/ResourceLoader.h>
 #include <wtf/CompletionHandler.h>
 
+#define RELEASE_LOG_IS_ALLOWED (WebProcess::singleton().sessionID().isAlwaysOnLoggingAllowed())
+
+#undef RELEASE_LOG_IF_ALLOWED
+#define RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(RELEASE_LOG_IS_ALLOWED, Loading, "%p - WebURLSchemeTaskProxy::" fmt, this, ##__VA_ARGS__)
+
+#define WEBURLSCHEMETASKPROXY_RELEASE_LOG_STANDARD_TEMPLATE "[schemeHandler=%" PRIu64 ", webPageID=%" PRIu64 ", frameID=%" PRIu64 ", taskID=%lu] WebURLSchemeTaskProxy::"
+#define WEBURLSCHEMETASKPROXY_RELEASE_LOG_STANDARD_PARAMETERS m_urlSchemeHandler.identifier(), pageIDFromWebFrame(m_frame), frameIDFromWebFrame(m_frame), m_identifier
+
+#define WEBURLSCHEMETASKPROXY_RELEASE_LOG_IF_ALLOWED(fmt, ...) RELEASE_LOG_IF(RELEASE_LOG_IS_ALLOWED, Network, WEBURLSCHEMETASKPROXY_RELEASE_LOG_STANDARD_TEMPLATE fmt, WEBURLSCHEMETASKPROXY_RELEASE_LOG_STANDARD_PARAMETERS, ##__VA_ARGS__)
+
+
 namespace WebKit {
 using namespace WebCore;
 
+static uint64_t pageIDFromWebFrame(const RefPtr<WebFrame>& frame)
+{
+    if (frame) {
+        if (auto* page = frame->page())
+            return page->identifier().toUInt64();
+    }
+    return 0;
+}
+
+static uint64_t frameIDFromWebFrame(const RefPtr<WebFrame>& frame)
+{
+    if (frame)
+        return frame->frameID().toUInt64();
+    return 0;
+}
+
 WebURLSchemeTaskProxy::WebURLSchemeTaskProxy(WebURLSchemeHandlerProxy& handler, ResourceLoader& loader, WebFrame& frame)
     : m_urlSchemeHandler(handler)
     , m_coreLoader(&loader)
@@ -54,6 +81,7 @@
 {
     ASSERT(m_coreLoader);
     ASSERT(m_frame);
+    WEBURLSCHEMETASKPROXY_RELEASE_LOG_IF_ALLOWED("startLoading");
     m_urlSchemeHandler.page().send(Messages::WebPageProxy::StartURLSchemeTask(URLSchemeTaskParameters { m_urlSchemeHandler.identifier(), m_coreLoader->identifier(), m_request, m_frame->info() }));
 }
 
@@ -60,6 +88,7 @@
 void WebURLSchemeTaskProxy::stopLoading()
 {
     ASSERT(m_coreLoader);
+    WEBURLSCHEMETASKPROXY_RELEASE_LOG_IF_ALLOWED("stopLoading");
     m_urlSchemeHandler.page().send(Messages::WebPageProxy::StopURLSchemeTask(m_urlSchemeHandler.identifier(), m_coreLoader->identifier()));
     m_coreLoader = nullptr;
     m_frame = nullptr;
@@ -76,7 +105,7 @@
     }
 
     if (m_waitingForCompletionHandler) {
-        RELEASE_LOG(Loading, "Received redirect during previous redirect processing, queuing it.");
+        WEBURLSCHEMETASKPROXY_RELEASE_LOG_IF_ALLOWED("didPerformRedirection: Received redirect during previous redirect processing, queuing it.");
         queueTask([this, protectedThis = makeRef(*this), redirectResponse = WTFMove(redirectResponse), request = WTFMove(request), completionHandler = WTFMove(completionHandler)]() mutable {
             didPerformRedirection(WTFMove(redirectResponse), WTFMove(request), WTFMove(completionHandler));
         });
@@ -98,7 +127,7 @@
 void WebURLSchemeTaskProxy::didReceiveResponse(const ResourceResponse& response)
 {
     if (m_waitingForCompletionHandler) {
-        RELEASE_LOG(Loading, "Received response during redirect processing, queuing it.");
+        WEBURLSCHEMETASKPROXY_RELEASE_LOG_IF_ALLOWED("didReceiveResponse: Received response during redirect processing, queuing it.");
         queueTask([this, protectedThis = makeRef(*this), response] {
             didReceiveResponse(response);
         });
@@ -121,7 +150,7 @@
         return;
 
     if (m_waitingForCompletionHandler) {
-        RELEASE_LOG(Loading, "Received data during response processing, queuing it.");
+        WEBURLSCHEMETASKPROXY_RELEASE_LOG_IF_ALLOWED("didReceiveData: Received data during response processing, queuing it.");
         Vector<uint8_t> dataVector;
         dataVector.append(data, size);
         queueTask([this, protectedThis = makeRef(*this), dataVector = WTFMove(dataVector)] {
@@ -137,6 +166,7 @@
 
 void WebURLSchemeTaskProxy::didComplete(const ResourceError& error)
 {
+    WEBURLSCHEMETASKPROXY_RELEASE_LOG_IF_ALLOWED("didComplete");
     if (!hasLoader())
         return;
 
@@ -173,3 +203,9 @@
 }
 
 } // namespace WebKit
+
+#undef RELEASE_LOG_IF_ALLOWED
+#undef RELEASE_LOG_IS_ALLOWED
+#undef WEBURLSCHEMETASKPROXY_RELEASE_LOG_STANDARD_TEMPLATE
+#undef WEBURLSCHEMETASKPROXY_RELEASE_LOG_STANDARD_PARAMETERS
+#undef WEBURLSCHEMETASKPROXY_RELEASE_LOG_IF_ALLOWED

Modified: trunk/Source/WebKit/WebProcess/WebProcess.cpp (275562 => 275563)


--- trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-04-06 22:29:15 UTC (rev 275562)
+++ trunk/Source/WebKit/WebProcess/WebProcess.cpp	2021-04-06 22:37:57 UTC (rev 275563)
@@ -216,6 +216,7 @@
 #include <WebCore/VP9UtilitiesCocoa.h>
 #endif
 
+#undef RELEASE_LOG_IF_ALLOWED
 #define RELEASE_LOG_SESSION_ID (m_sessionID ? m_sessionID->toUInt64() : 0)
 #define RELEASE_LOG_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_IF(isAlwaysOnLoggingAllowed(), channel, "%p - [sessionID=%" PRIu64 "] WebProcess::" fmt, this, RELEASE_LOG_SESSION_ID, ##__VA_ARGS__)
 #define RELEASE_LOG_ERROR_IF_ALLOWED(channel, fmt, ...) RELEASE_LOG_ERROR_IF(isAlwaysOnLoggingAllowed(), channel, "%p - [sessionID=%" PRIu64 "] WebProcess::" fmt, this, RELEASE_LOG_SESSION_ID, ##__VA_ARGS__)
@@ -1110,6 +1111,12 @@
 
 void WebProcess::networkProcessConnectionClosed(NetworkProcessConnection* connection)
 {
+#if OS(DARWIN)
+    RELEASE_LOG_IF_ALLOWED(Loading, "networkProcessConnectionClosed: NetworkProcess (%d) closed its connection (Crashed)", connection ? connection->connection().remoteProcessID() : 0);
+#else
+    RELEASE_LOG_IF_ALLOWED(Loading, "networkProcessConnectionClosed: NetworkProcess closed its connection (Crashed)");
+#endif
+
     ASSERT(m_networkProcessConnection);
     ASSERT_UNUSED(connection, m_networkProcessConnection == connection);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to