Changeset 223827 in webkit


Ignore:
Timestamp:
Oct 22, 2017 7:20:19 PM (6 years ago)
Author:
Wenson Hsieh
Message:

[iOS] WebProcess::initializeWebProcess spends ~150ms spinning up AVSystemController on some devices
https://bugs.webkit.org/show_bug.cgi?id=178640
<rdar://problem/35113105>

Reviewed by Youenn Fablet.

In r213933, we added a mechanism to allow the web process to drive media capture, by setting an attribute on the
shared AVSystemController. This requires us to fault in the Celestial framework, which is a slight performance
hit on some hardware. Instead of doing this at the start of every web process launch, we can just do this work
lazily, the first time the web process requests permissions for user media access.

  • WebProcess/WebCoreSupport/WebUserMediaClient.cpp:

(WebKit::WebUserMediaClient::requestUserMediaAccess):

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::prepareToSendUserMediaPermissionRequest):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/ios/WebPageIOS.mm:

(WebKit::WebPage::prepareToSendUserMediaPermissionRequest):

  • WebProcess/cocoa/WebProcessCocoa.mm:

(WebKit::WebProcess::platformInitializeWebProcess):

Location:
trunk/Source/WebKit
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r223822 r223827  
     12017-10-22  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        [iOS] WebProcess::initializeWebProcess spends ~150ms spinning up AVSystemController on some devices
     4        https://bugs.webkit.org/show_bug.cgi?id=178640
     5        <rdar://problem/35113105>
     6
     7        Reviewed by Youenn Fablet.
     8
     9        In r213933, we added a mechanism to allow the web process to drive media capture, by setting an attribute on the
     10        shared AVSystemController. This requires us to fault in the Celestial framework, which is a slight performance
     11        hit on some hardware. Instead of doing this at the start of every web process launch, we can just do this work
     12        lazily, the first time the web process requests permissions for user media access.
     13
     14        * WebProcess/WebCoreSupport/WebUserMediaClient.cpp:
     15        (WebKit::WebUserMediaClient::requestUserMediaAccess):
     16        * WebProcess/WebPage/WebPage.cpp:
     17        (WebKit::WebPage::prepareToSendUserMediaPermissionRequest):
     18        * WebProcess/WebPage/WebPage.h:
     19        * WebProcess/WebPage/ios/WebPageIOS.mm:
     20        (WebKit::WebPage::prepareToSendUserMediaPermissionRequest):
     21        * WebProcess/cocoa/WebProcessCocoa.mm:
     22        (WebKit::WebProcess::platformInitializeWebProcess):
     23
    1242017-10-21  Michael Catanzaro  <mcatanzaro@igalia.com>
    225
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebUserMediaClient.cpp

    r218601 r223827  
    4444void WebUserMediaClient::requestUserMediaAccess(UserMediaRequest& request)
    4545{
     46    m_page.prepareToSendUserMediaPermissionRequest();
    4647    m_page.userMediaPermissionRequestManager().startUserMediaRequest(request);
    4748}
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r223779 r223827  
    38993899
    39003900#if ENABLE(MEDIA_STREAM)
     3901
     3902#if !PLATFORM(IOS)
     3903void WebPage::prepareToSendUserMediaPermissionRequest()
     3904{
     3905}
     3906#endif
     3907
    39013908void WebPage::userMediaAccessWasGranted(uint64_t userMediaID, String&& audioDeviceUID, String&& videoDeviceUID, String&& mediaDeviceIdentifierHashSalt)
    39023909{
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r223726 r223827  
    512512#if ENABLE(MEDIA_STREAM)
    513513    UserMediaPermissionRequestManager& userMediaPermissionRequestManager() { return *m_userMediaPermissionRequestManager; }
     514    void prepareToSendUserMediaPermissionRequest();
    514515#endif
    515516
  • trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm

    r223726 r223827  
    100100#import <WebCore/RenderThemeIOS.h>
    101101#import <WebCore/RenderView.h>
     102#import <WebCore/RuntimeApplicationChecks.h>
    102103#import <WebCore/Settings.h>
    103104#import <WebCore/SharedBuffer.h>
     
    111112#import <wtf/MemoryPressureHandler.h>
    112113#import <wtf/SetForScope.h>
     114#import <wtf/SoftLinking.h>
    113115#import <wtf/text/TextStream.h>
     116
     117#if ENABLE(MEDIA_STREAM)
     118#import "CelestialSPI.h"
     119SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(Celestial)
     120SOFT_LINK_CLASS_OPTIONAL(Celestial, AVSystemController)
     121SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_PIDToInheritApplicationStateFrom, NSString *)
     122#endif
    114123
    115124using namespace WebCore;
     
    34123421#endif
    34133422
     3423#if ENABLE(MEDIA_STREAM)
     3424void WebPage::prepareToSendUserMediaPermissionRequest()
     3425{
     3426    static std::once_flag once;
     3427    std::call_once(once, [] {
     3428        if (!canLoadAVSystemController_PIDToInheritApplicationStateFrom())
     3429            return;
     3430
     3431        NSError *error = nil;
     3432        [[getAVSystemControllerClass() sharedAVSystemController] setAttribute:@(WebCore::presentingApplicationPID()) forKey:getAVSystemController_PIDToInheritApplicationStateFrom() error:&error];
     3433        if (error)
     3434            WTFLogAlways("Failed to set up PID proxying: %s", error.localizedDescription.UTF8String);
     3435    });
     3436}
     3437#endif
     3438
    34143439} // namespace WebKit
    34153440
  • trunk/Source/WebKit/WebProcess/cocoa/WebProcessCocoa.mm

    r222896 r223827  
    7171
    7272#if PLATFORM(IOS)
    73 #import "CelestialSPI.h"
    7473#import <pal/spi/ios/GraphicsServicesSPI.h>
    75 #import <wtf/SoftLinking.h>
    7674#endif
    7775
    7876#if USE(OS_STATE)
    7977#import <os/state_private.h>
    80 #endif
    81 
    82 #if PLATFORM(IOS)
    83 SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(Celestial)
    84 
    85 SOFT_LINK_CLASS_OPTIONAL(Celestial, AVSystemController)
    86 
    87 SOFT_LINK_CONSTANT_MAY_FAIL(Celestial, AVSystemController_PIDToInheritApplicationStateFrom, NSString *)
    88 
    89 #define AVSystemController_PIDToInheritApplicationStateFrom getAVSystemController_PIDToInheritApplicationStateFrom()
    9078#endif
    9179
     
    175163    // Priority decay on iOS 9 is impacting page load time so we fix the priority of the WebProcess' main thread (rdar://problem/22003112).
    176164    pthread_set_fixedpriority_self();
    177 #endif
    178 
    179 #if PLATFORM(IOS)
    180     if (canLoadAVSystemController_PIDToInheritApplicationStateFrom()) {
    181         pid_t pid = WebCore::presentingApplicationPID();
    182         NSError *error = nil;
    183         [[getAVSystemControllerClass() sharedAVSystemController] setAttribute:@(pid) forKey:AVSystemController_PIDToInheritApplicationStateFrom error:&error];
    184         if (error)
    185             WTFLogAlways("Failed to set up PID proxying: %s", [[error localizedDescription] UTF8String]);
    186     }
    187165#endif
    188166}
Note: See TracChangeset for help on using the changeset viewer.