Title: [213182] trunk/Source
Revision
213182
Author
timothy_hor...@apple.com
Date
2017-02-28 15:18:12 -0800 (Tue, 28 Feb 2017)

Log Message

[iOS] Getting QLPreviewProtocol slows down first navigation in Web process
https://bugs.webkit.org/show_bug.cgi?id=168940
<rdar://problem/29468999>

Reviewed by Simon Fraser.

No new tests, just a performance improvement.

* loader/DocumentLoader.cpp:
(WebCore::isRemoteWebArchive):
* loader/PolicyChecker.cpp:
(WebCore::PolicyChecker::checkNavigationPolicy):
* loader/ResourceLoadNotifier.cpp:
(WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
Make use of isQuickLookPreviewURL.

* loader/ios/QuickLook.h:
* loader/ios/QuickLook.mm:
(WebCore::isQuickLookPreviewURL):
Add isQuickLookPreviewURL, which first early-returns if the protocol
of the URL is a well-known protocol, and then falls back to loading QuickLook.

In a microbenchmark this is a 30-40% improvement in total time spent
loading an empty HTML document (wall-clock time between loadHTMLString
and didFinishNavigation).

* WebProcess/Network/WebLoaderStrategy.cpp:
(WebKit::WebLoaderStrategy::scheduleLoad):
Make use of isQuickLookPreviewURL.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (213181 => 213182)


--- trunk/Source/WebCore/ChangeLog	2017-02-28 23:08:28 UTC (rev 213181)
+++ trunk/Source/WebCore/ChangeLog	2017-02-28 23:18:12 UTC (rev 213182)
@@ -1,3 +1,31 @@
+2017-02-28  Tim Horton  <timothy_hor...@apple.com>
+
+        [iOS] Getting QLPreviewProtocol slows down first navigation in Web process
+        https://bugs.webkit.org/show_bug.cgi?id=168940
+        <rdar://problem/29468999>
+
+        Reviewed by Simon Fraser.
+
+        No new tests, just a performance improvement.
+
+        * loader/DocumentLoader.cpp:
+        (WebCore::isRemoteWebArchive):
+        * loader/PolicyChecker.cpp:
+        (WebCore::PolicyChecker::checkNavigationPolicy):
+        * loader/ResourceLoadNotifier.cpp:
+        (WebCore::ResourceLoadNotifier::dispatchWillSendRequest):
+        Make use of isQuickLookPreviewURL.
+
+        * loader/ios/QuickLook.h:
+        * loader/ios/QuickLook.mm:
+        (WebCore::isQuickLookPreviewURL):
+        Add isQuickLookPreviewURL, which first early-returns if the protocol
+        of the URL is a well-known protocol, and then falls back to loading QuickLook.
+
+        In a microbenchmark this is a 30-40% improvement in total time spent
+        loading an empty HTML document (wall-clock time between loadHTMLString
+        and didFinishNavigation).
+
 2017-02-28  Simon Fraser  <simon.fra...@apple.com>
 
         Add Geolocation and DeviceOrientation to features.json 

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (213181 => 213182)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-02-28 23:08:28 UTC (rev 213181)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2017-02-28 23:18:12 UTC (rev 213182)
@@ -727,7 +727,7 @@
         return false;
 
 #if USE(QUICK_LOOK)
-    if (response.url().protocolIs(QLPreviewProtocol()))
+    if (isQuickLookPreviewURL(response.url()))
         return false;
 #endif
 

Modified: trunk/Source/WebCore/loader/PolicyChecker.cpp (213181 => 213182)


--- trunk/Source/WebCore/loader/PolicyChecker.cpp	2017-02-28 23:08:28 UTC (rev 213181)
+++ trunk/Source/WebCore/loader/PolicyChecker.cpp	2017-02-28 23:18:12 UTC (rev 213182)
@@ -125,7 +125,7 @@
 
 #if USE(QUICK_LOOK)
     // Always allow QuickLook-generated URLs based on the protocol scheme.
-    if (!request.isNull() && request.url().protocolIs(QLPreviewProtocol())) {
+    if (!request.isNull() && isQuickLookPreviewURL(request.url())) {
         continueAfterNavigationPolicy(PolicyUse);
         return;
     }

Modified: trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp (213181 => 213182)


--- trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp	2017-02-28 23:08:28 UTC (rev 213181)
+++ trunk/Source/WebCore/loader/ResourceLoadNotifier.cpp	2017-02-28 23:18:12 UTC (rev 213182)
@@ -119,7 +119,7 @@
 {
 #if USE(QUICK_LOOK)
     // Always allow QuickLook-generated URLs based on the protocol scheme.
-    if (!request.isNull() && request.url().protocolIs(QLPreviewProtocol()))
+    if (!request.isNull() && isQuickLookPreviewURL(request.url()))
         return;
 #endif
 

Modified: trunk/Source/WebCore/loader/ios/QuickLook.h (213181 => 213182)


--- trunk/Source/WebCore/loader/ios/QuickLook.h	2017-02-28 23:08:28 UTC (rev 213181)
+++ trunk/Source/WebCore/loader/ios/QuickLook.h	2017-02-28 23:18:12 UTC (rev 213182)
@@ -44,11 +44,13 @@
 class ResourceRequest;
 class ResourceResponse;
 class SharedBuffer;
+class URL;
 
 WEBCORE_EXPORT NSSet *QLPreviewGetSupportedMIMETypesSet();
 WEBCORE_EXPORT void removeQLPreviewConverterForURL(NSURL *);
 WEBCORE_EXPORT RetainPtr<NSURLRequest> registerQLPreviewConverterIfNeeded(NSURL *, NSString *mimeType, NSData *);
 WEBCORE_EXPORT const char* QLPreviewProtocol();
+WEBCORE_EXPORT bool isQuickLookPreviewURL(const URL&);
 WEBCORE_EXPORT NSString *createTemporaryFileForQuickLook(NSString *fileName);
 
 class QuickLookHandle {

Modified: trunk/Source/WebCore/loader/ios/QuickLook.mm (213181 => 213182)


--- trunk/Source/WebCore/loader/ios/QuickLook.mm	2017-02-28 23:08:28 UTC (rev 213181)
+++ trunk/Source/WebCore/loader/ios/QuickLook.mm	2017-02-28 23:18:12 UTC (rev 213182)
@@ -39,6 +39,7 @@
 #import "ResourceError.h"
 #import "ResourceLoader.h"
 #import "ResourceRequest.h"
+#import "SchemeRegistry.h"
 #import "SharedBuffer.h"
 #import <WebCore/NetworkLoadMetrics.h>
 #import <wtf/NeverDestroyed.h>
@@ -123,6 +124,14 @@
     return previewProtocol.get().data();
 }
 
+bool WebCore::isQuickLookPreviewURL(const URL& url)
+{
+    // Use some known protocols as a short-cut to avoid loading the QuickLook framework.
+    if (url.protocolIsInHTTPFamily() || url.isBlankURL() || url.protocolIsBlob() || url.protocolIsData() || SchemeRegistry::shouldTreatURLSchemeAsLocal(url.protocol().toString()))
+        return NO;
+    return url.protocolIs(QLPreviewProtocol());
+}
+
 static RefPtr<QuickLookHandleClient>& testingClient()
 {
     static NeverDestroyed<RefPtr<QuickLookHandleClient>> testingClient;

Modified: trunk/Source/WebKit2/ChangeLog (213181 => 213182)


--- trunk/Source/WebKit2/ChangeLog	2017-02-28 23:08:28 UTC (rev 213181)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-28 23:18:12 UTC (rev 213182)
@@ -1,3 +1,15 @@
+2017-02-28  Tim Horton  <timothy_hor...@apple.com>
+
+        [iOS] Getting QLPreviewProtocol slows down first navigation in Web process
+        https://bugs.webkit.org/show_bug.cgi?id=168940
+        <rdar://problem/29468999>
+
+        Reviewed by Simon Fraser.
+
+        * WebProcess/Network/WebLoaderStrategy.cpp:
+        (WebKit::WebLoaderStrategy::scheduleLoad):
+        Make use of isQuickLookPreviewURL.
+
 2017-02-28  Brady Eidson  <beid...@apple.com>
 
         Fix API test regression(s):

Modified: trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp (213181 => 213182)


--- trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp	2017-02-28 23:08:28 UTC (rev 213181)
+++ trunk/Source/WebKit2/WebProcess/Network/WebLoaderStrategy.cpp	2017-02-28 23:18:12 UTC (rev 213182)
@@ -175,7 +175,7 @@
     }
 
 #if USE(QUICK_LOOK)
-    if (resourceLoader.request().url().protocolIs(QLPreviewProtocol())) {
+    if (isQuickLookPreviewURL(resourceLoader.request().url())) {
         LOG(NetworkScheduling, "(WebProcess) WebLoaderStrategy::scheduleLoad, url '%s' will be handled as a QuickLook resource.", resourceLoader.url().string().utf8().data());
         RELEASE_LOG_IF_ALLOWED(resourceLoader, "scheduleLoad: URL will be handled as a QuickLook resource (frame = %p, resourceID = %" PRIu64 ")", resourceLoader.frame(), identifier);
         startLocalLoad(resourceLoader);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to