Changeset 240555 in webkit


Ignore:
Timestamp:
Jan 27, 2019 12:44:05 PM (5 years ago)
Author:
jiewen_tan@apple.com
Message:

Use a load optimizer for some sites
https://bugs.webkit.org/show_bug.cgi?id=193881
<rdar://problem/46325455>

Reviewed by Brent Fulgham.

Source/WebCore:

Expose FormData::flatten to be used by the load optimizer.

  • WebCore.xcodeproj/project.pbxproj:
  • platform/network/FormData.h:

Source/WebKit:

We will try to speed up some sites with a dedicated load optimizer. The load optimizer lives
within the WebsiteDataStore as one client instance should have only one and it should live
as long as the client lives. How does the load optimizer work? It intercepts every load in
the navigation state. If a request meets some requirements, it will then fetch the request
from its own cache. Once the fetch succeeds, the original load will be ignored and the
optimizer will display the cached content.

Covered by API tests.

  • SourcesCocoa.txt:
  • UIProcess/Cocoa/LoadOptimizer.h: Added.
  • UIProcess/Cocoa/LoadOptimizer.mm: Added.
  • UIProcess/Cocoa/MediaCaptureUtilities.h:
  • UIProcess/Cocoa/NavigationState.mm:

(WebKit::tryInterceptNavigation):
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
(WebKit::tryAppLink): Deleted.

  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::WebsiteDataStore):

  • UIProcess/WebsiteData/WebsiteDataStore.h:

(WebKit::WebsiteDataStore::loadOptimizer):

  • WebKit.xcodeproj/project.pbxproj:

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKitCocoa/TestLoadOptimizer.mm: Added.
Location:
trunk
Files:
11 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r240553 r240555  
     12019-01-27  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Use a load optimizer for some sites
     4        https://bugs.webkit.org/show_bug.cgi?id=193881
     5        <rdar://problem/46325455>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        Expose FormData::flatten to be used by the load optimizer.
     10
     11        * WebCore.xcodeproj/project.pbxproj:
     12        * platform/network/FormData.h:
     13
    1142019-01-26  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/Source/WebCore/platform/network/FormData.h

    r239535 r240555  
    222222    WEBCORE_EXPORT void appendBlob(const URL& blobURL);
    223223
    224     Vector<char> flatten() const; // omits files
     224    WEBCORE_EXPORT Vector<char> flatten() const; // omits files
    225225    String flattenToString() const; // omits files
    226226
  • trunk/Source/WebKit/ChangeLog

    r240554 r240555  
     12019-01-27  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Use a load optimizer for some sites
     4        https://bugs.webkit.org/show_bug.cgi?id=193881
     5        <rdar://problem/46325455>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        We will try to speed up some sites with a dedicated load optimizer. The load optimizer lives
     10        within the WebsiteDataStore as one client instance should have only one and it should live
     11        as long as the client lives. How does the load optimizer work? It intercepts every load in
     12        the navigation state. If a request meets some requirements, it will then fetch the request
     13        from its own cache. Once the fetch succeeds, the original load will be ignored and the
     14        optimizer will display the cached content.
     15
     16        Covered by API tests.
     17
     18        * SourcesCocoa.txt:
     19        * UIProcess/Cocoa/LoadOptimizer.h: Added.
     20        * UIProcess/Cocoa/LoadOptimizer.mm: Added.
     21        * UIProcess/Cocoa/MediaCaptureUtilities.h:
     22        * UIProcess/Cocoa/NavigationState.mm:
     23        (WebKit::tryInterceptNavigation):
     24        (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
     25        (WebKit::tryAppLink): Deleted.
     26        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     27        (WebKit::WebsiteDataStore::WebsiteDataStore):
     28        * UIProcess/WebsiteData/WebsiteDataStore.h:
     29        (WebKit::WebsiteDataStore::loadOptimizer):
     30        * WebKit.xcodeproj/project.pbxproj:
     31
    1322019-01-25  Brian Burg  <bburg@apple.com>
    233
  • trunk/Source/WebKit/SourcesCocoa.txt

    r240311 r240555  
    324324UIProcess/Cocoa/IconLoadingDelegate.mm
    325325UIProcess/Cocoa/LegacyCustomProtocolManagerClient.mm
     326UIProcess/Cocoa/LoadOptimizer.mm
    326327UIProcess/Cocoa/MediaCaptureUtilities.mm
    327328UIProcess/Cocoa/NavigationState.mm
  • trunk/Source/WebKit/UIProcess/Cocoa/LoadOptimizer.h

    r240554 r240555  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2626#pragma once
    2727
    28 #if WK_API_ENABLED
    29 
    30 #import "WKWebViewPrivate.h"
    31 #import <WebCore/MediaProducer.h>
    32 
    33 namespace WebKit {
    34 
    35 _WKMediaCaptureState toWKMediaCaptureState(WebCore::MediaProducer::MediaStateFlags);
    36 
    37 } // namespace WebKit
    38 
     28#if HAVE(LOAD_OPTIMIZER)
     29#include <WebKitAdditions/LoadOptimizerAdditions.h>
    3930#endif
  • trunk/Source/WebKit/UIProcess/Cocoa/LoadOptimizer.mm

    r240554 r240555  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#import "config.h"
     27#import "LoadOptimizer.h"
    2728
    28 #if WK_API_ENABLED
    29 
    30 #import "WKWebViewPrivate.h"
    31 #import <WebCore/MediaProducer.h>
    32 
    33 namespace WebKit {
    34 
    35 _WKMediaCaptureState toWKMediaCaptureState(WebCore::MediaProducer::MediaStateFlags);
    36 
    37 } // namespace WebKit
    38 
     29#if HAVE(LOAD_OPTIMIZER)
     30#import <WebKitAdditions/LoadOptimizerAdditions.mm>
    3931#endif
  • trunk/Source/WebKit/UIProcess/Cocoa/MediaCaptureUtilities.h

    r240100 r240555  
    2626#pragma once
    2727
     28#import "WKFoundation.h"
     29
    2830#if WK_API_ENABLED
    2931
  • trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm

    r240477 r240555  
    3838#import "AuthenticationDecisionListener.h"
    3939#import "CompletionHandlerCallChecker.h"
     40#import "LoadOptimizer.h"
    4041#import "Logging.h"
    4142#import "NavigationActionData.h"
     
    465466#endif
    466467
    467 static void tryAppLink(Ref<API::NavigationAction>&& navigationAction, WTF::Function<void(bool)>&& completionHandler)
     468static void tryInterceptNavigation(Ref<API::NavigationAction>&& navigationAction, WebPageProxy& page, WTF::Function<void(bool)>&& completionHandler)
    468469{
    469470#if HAVE(APP_LINKS)
    470     if (!navigationAction->shouldOpenAppLinks()) {
    471         completionHandler(false);
    472         return;
    473     }
    474 
    475     auto* localCompletionHandler = new WTF::Function<void (bool)>(WTFMove(completionHandler));
    476     [LSAppLink openWithURL:navigationAction->request().url() completionHandler:[localCompletionHandler](BOOL success, NSError *) {
    477         dispatch_async(dispatch_get_main_queue(), [localCompletionHandler, success] {
    478             (*localCompletionHandler)(success);
    479             delete localCompletionHandler;
    480         });
    481     }];
    482 #else
     471    if (navigationAction->shouldOpenAppLinks()) {
     472        auto* localCompletionHandler = new WTF::Function<void (bool)>(WTFMove(completionHandler));
     473        [LSAppLink openWithURL:navigationAction->request().url() completionHandler:[localCompletionHandler](BOOL success, NSError *) {
     474            dispatch_async(dispatch_get_main_queue(), [localCompletionHandler, success] {
     475                (*localCompletionHandler)(success);
     476                delete localCompletionHandler;
     477            });
     478        }];
     479        return;
     480    }
     481#endif
     482
     483#if HAVE(LOAD_OPTIMIZER)
     484    if (LoadOptimizer::canOptimizeLoad(navigationAction->request().url())) {
     485        page.websiteDataStore().loadOptimizer().optimizeLoad(navigationAction->request(), page, WTFMove(completionHandler));
     486        return;
     487    }
     488#endif
     489
    483490    completionHandler(false);
    484 #endif
    485491}
    486492
     
    492498        && !m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandlerWebsitePolicies
    493499        && !m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionUserInfoDecisionHandlerWebsitePolicies) {
    494         auto completionHandler = [webPage = makeRef(webPageProxy), listener = WTFMove(listener), navigationAction = navigationAction.copyRef()] (bool followedLinkToApp) {
    495             if (followedLinkToApp) {
     500        auto completionHandler = [webPage = makeRef(webPageProxy), listener = WTFMove(listener), navigationAction = navigationAction.copyRef()] (bool interceptedNavigation) {
     501            if (interceptedNavigation) {
    496502                listener->ignore();
    497503                return;
     
    520526            listener->ignore();
    521527        };
    522         tryAppLink(WTFMove(navigationAction), WTFMove(completionHandler));
     528        tryInterceptNavigation(WTFMove(navigationAction), webPageProxy, WTFMove(completionHandler));
    523529        return;
    524530    }
     
    555561        case WKNavigationActionPolicyAllow:
    556562        case _WKNavigationActionPolicyAllowInNewProcess:
    557             tryAppLink(WTFMove(navigationAction), [actionPolicy, localListener = WTFMove(localListener), websitePolicies = WTFMove(apiWebsitePolicies)](bool followedLinkToApp) mutable {
    558                 if (followedLinkToApp) {
     563            tryInterceptNavigation(WTFMove(navigationAction), webPageProxy, [actionPolicy, localListener = WTFMove(localListener), websitePolicies = WTFMove(apiWebsitePolicies)](bool interceptedNavigation) mutable {
     564                if (interceptedNavigation) {
    559565                    localListener->ignore();
    560566                    return;
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r240498 r240555  
    5858#include <wtf/RunLoop.h>
    5959
     60#if HAVE(LOAD_OPTIMIZER)
     61#include "LoadOptimizer.h"
     62#endif
     63
    6064#if ENABLE(NETSCAPE_PLUGIN_API)
    6165#include "PluginProcessManager.h"
     
    102106#endif
    103107    , m_client(makeUniqueRef<WebsiteDataStoreClient>())
     108#if HAVE(LOAD_OPTIMIZER)
     109    , m_loadOptimizer(makeUniqueRef<LoadOptimizer>())
     110#endif
    104111{
    105112    WTF::setProcessPrivileges(allPrivileges());
     
    120127#endif
    121128    , m_client(makeUniqueRef<WebsiteDataStoreClient>())
     129#if HAVE(LOAD_OPTIMIZER)
     130    , m_loadOptimizer(makeUniqueRef<LoadOptimizer>())
     131#endif
    122132{
    123133    maybeRegisterWithSessionIDMap();
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r240360 r240555  
    6060
    6161class AuthenticatorManager;
     62class LoadOptimizer;
    6263class SecKeyProxyStore;
    6364class StorageManager;
     
    238239    void setClient(UniqueRef<WebsiteDataStoreClient>&& client) { m_client = WTFMove(client); }
    239240
     241#if HAVE(LOAD_OPTIMIZER)
     242    LoadOptimizer& loadOptimizer() { return m_loadOptimizer.get(); }
     243#endif
     244
    240245private:
    241246    explicit WebsiteDataStore(PAL::SessionID);
     
    315320
    316321    UniqueRef<WebsiteDataStoreClient> m_client;
     322
     323#if HAVE(LOAD_OPTIMIZER)
     324    UniqueRef<LoadOptimizer> m_loadOptimizer;
     325#endif
    317326};
    318327
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r240554 r240555  
    10241024                5772F206217DBD6A0056BF2C /* HidService.h in Headers */ = {isa = PBXBuildFile; fileRef = 5772F204217DBD6A0056BF2C /* HidService.h */; };
    10251025                578DC2982155A0020074E815 /* LocalAuthenticationSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = 578DC2972155A0010074E815 /* LocalAuthenticationSoftLink.h */; };
     1026                57900B4021F8F9B8008317DE /* LoadOptimizer.h in Headers */ = {isa = PBXBuildFile; fileRef = 57900B3E21F8F9B8008317DE /* LoadOptimizer.h */; };
    10261027                57AC8F50217FEED90055438C /* HidConnection.h in Headers */ = {isa = PBXBuildFile; fileRef = 57AC8F4E217FEED90055438C /* HidConnection.h */; };
    10271028                57B4B46020B504AC00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B4B45E20B504AB00D4AD79 /* ClientCertificateAuthenticationXPCConstants.h */; };
     
    33733374                5772F205217DBD6A0056BF2C /* HidService.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = HidService.mm; sourceTree = "<group>"; };
    33743375                578DC2972155A0010074E815 /* LocalAuthenticationSoftLink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LocalAuthenticationSoftLink.h; sourceTree = "<group>"; };
     3376                57900B3E21F8F9B8008317DE /* LoadOptimizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoadOptimizer.h; sourceTree = "<group>"; };
     3377                57900B3F21F8F9B8008317DE /* LoadOptimizer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadOptimizer.mm; sourceTree = "<group>"; };
    33753378                57AC8F4E217FEED90055438C /* HidConnection.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = HidConnection.h; sourceTree = "<group>"; };
    33763379                57AC8F4F217FEED90055438C /* HidConnection.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = HidConnection.mm; sourceTree = "<group>"; };
     
    53155318                                411286EF21C8A90C003A8550 /* MediaCaptureUtilities.h */,
    53165319                                411286F021C8A90D003A8550 /* MediaCaptureUtilities.mm */,
     5320                                57900B3E21F8F9B8008317DE /* LoadOptimizer.h */,
     5321                                57900B3F21F8F9B8008317DE /* LoadOptimizer.mm */,
    53175322                                1ABC3DF41899E437004F0626 /* NavigationState.h */,
    53185323                                1ABC3DF31899E437004F0626 /* NavigationState.mm */,
     
    99169921                                BC8699B5116AADAA002A925B /* WKView.h in Headers */,
    99179922                                BC8699B7116AADAA002A925B /* WKViewInternal.h in Headers */,
     9923                                57900B4021F8F9B8008317DE /* LoadOptimizer.h in Headers */,
    99189924                                2D28A4971AF965A100F190C9 /* WKViewLayoutStrategy.h in Headers */,
    99199925                                BFA6179F12F0B99D0033E0CA /* WKViewPrivate.h in Headers */,
  • trunk/Tools/ChangeLog

    r240552 r240555  
     12019-01-27  Jiewen Tan  <jiewen_tan@apple.com>
     2
     3        Use a load optimizer for some sites
     4        https://bugs.webkit.org/show_bug.cgi?id=193881
     5        <rdar://problem/46325455>
     6
     7        Reviewed by Brent Fulgham.
     8
     9        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     10        * TestWebKitAPI/Tests/WebKitCocoa/TestLoadOptimizer.mm: Added.
     11
    1122019-01-27  Chris Fleizach  <cfleizach@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r240450 r240555  
    282282                57599E2B1F071AA000A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityWrite.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57599E231F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibilityWrite.html */; };
    283283                5769C50B1D9B0002000847FB /* SerializedCryptoKeyWrap.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */; };
     284                5774AA6821FBBF7800AF2A1B /* TestLoadOptimizer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5774AA6721FBBF7800AF2A1B /* TestLoadOptimizer.mm */; };
    284285                578CBD67204FB2C80083B9F2 /* LocalAuthentication.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 578CBD66204FB2C70083B9F2 /* LocalAuthentication.framework */; };
    285286                57901FB11CAF142D00ED64F9 /* LoadInvalidURLRequest.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 57901FB01CAF141C00ED64F9 /* LoadInvalidURLRequest.html */; };
     
    16541655                57599E261F07192C00A3FB8C /* IndexedDBStructuredCloneBackwardCompatibility.sqlite3-shm */ = {isa = PBXFileReference; lastKnownFileType = file; path = "IndexedDBStructuredCloneBackwardCompatibility.sqlite3-shm"; sourceTree = "<group>"; };
    16551656                5769C50A1D9B0001000847FB /* SerializedCryptoKeyWrap.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SerializedCryptoKeyWrap.mm; sourceTree = "<group>"; };
     1657                5774AA6721FBBF7800AF2A1B /* TestLoadOptimizer.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TestLoadOptimizer.mm; sourceTree = "<group>"; };
    16561658                578CBD66204FB2C70083B9F2 /* LocalAuthentication.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = LocalAuthentication.framework; path = System/Library/Frameworks/LocalAuthentication.framework; sourceTree = SDKROOT; };
    16571659                57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LoadInvalidURLRequest.mm; sourceTree = "<group>"; };
     
    25102512                                4612C2B8210A6ABF00B788A6 /* LoadFileThenReload.mm */,
    25112513                                57901FAC1CAF12C200ED64F9 /* LoadInvalidURLRequest.mm */,
     2514                                5774AA6721FBBF7800AF2A1B /* TestLoadOptimizer.mm */,
    25122515                                51E6A8921D2F1BEC00C004B6 /* LocalStorageClear.mm */,
    25132516                                CA38459520AE012E00990D3B /* LocalStorageDatabaseTracker.mm */,
     
    42534256                                7CCE7F2D1A411B1000447C4C /* UserContentTest.mm in Sources */,
    42544257                                7C882E0A1C80C764006BF731 /* UserContentWorld.mm in Sources */,
     4258                                5774AA6821FBBF7800AF2A1B /* TestLoadOptimizer.mm in Sources */,
    42554259                                7CCB99211D3B41F6003922F6 /* UserInitiatedActionInNavigationAction.mm in Sources */,
    42564260                                7CCE7F171A411AE600447C4C /* UserMedia.cpp in Sources */,
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/TestLoadOptimizer.mm

    r240554 r240555  
    11/*
    2  * Copyright (C) 2018 Apple Inc. All rights reserved.
     2 * Copyright (C) 2019 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #pragma once
     26#import "config.h"
    2727
    28 #if WK_API_ENABLED
    29 
    30 #import "WKWebViewPrivate.h"
    31 #import <WebCore/MediaProducer.h>
    32 
    33 namespace WebKit {
    34 
    35 _WKMediaCaptureState toWKMediaCaptureState(WebCore::MediaProducer::MediaStateFlags);
    36 
    37 } // namespace WebKit
    38 
     28#if HAVE(LOAD_OPTIMIZER)
     29#import <WebKitAdditions/TestLoadOptimizerAdditions.mm>
    3930#endif
Note: See TracChangeset for help on using the changeset viewer.