Changeset 229643 in webkit


Ignore:
Timestamp:
Mar 15, 2018 3:27:25 PM (6 years ago)
Author:
Keith Rollin
Message:

Telemetry for stalled webpage loads
https://bugs.webkit.org/show_bug.cgi?id=183221
<rdar://problem/36549013>

Reviewed by Chris Dumez.

Add telemetry for page loads, tracking the pages that succeed, fail,
or are canceled. This information will be used to track the overall
health of our page loading as time goes on.

Source/WebCore:

No new tests -- no new/changed user-level functionality.

  • page/DiagnosticLoggingKeys.cpp:

(WebCore::DiagnosticLoggingKeys::telemetryPageLoadKey):
(WebCore::DiagnosticLoggingKeys::timedOutKey):
(WebCore::DiagnosticLoggingKeys::canceledLessThan2SecondsKey):
(WebCore::DiagnosticLoggingKeys::canceledLessThan5SecondsKey):
(WebCore::DiagnosticLoggingKeys::canceledLessThan20SecondsKey):
(WebCore::DiagnosticLoggingKeys::canceledMoreThan20SecondsKey):
(WebCore::DiagnosticLoggingKeys::failedLessThan2SecondsKey):
(WebCore::DiagnosticLoggingKeys::failedLessThan5SecondsKey):
(WebCore::DiagnosticLoggingKeys::failedLessThan20SecondsKey):
(WebCore::DiagnosticLoggingKeys::failedMoreThan20SecondsKey):
(WebCore::DiagnosticLoggingKeys::occurredKey):
(WebCore::DiagnosticLoggingKeys::succeededLessThan2SecondsKey):
(WebCore::DiagnosticLoggingKeys::succeededLessThan5SecondsKey):
(WebCore::DiagnosticLoggingKeys::succeededLessThan20SecondsKey):
(WebCore::DiagnosticLoggingKeys::succeededMoreThan20SecondsKey):

  • page/DiagnosticLoggingKeys.h:
  • platform/network/cf/ResourceError.h:

(WebCore::ResourceError::ResourceError):

  • platform/network/mac/ResourceErrorMac.mm:

(WebCore::ResourceError::ResourceError):
(WebCore::ResourceError::getNSURLErrorDomain const):
(WebCore::ResourceError::getCFErrorDomainCFNetwork const):
(WebCore::ResourceError::mapPlatformError):

Source/WebKit:

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::close):
(WebKit::WebPageProxy::didStartProvisionalLoadForFrame):
(WebKit::WebPageProxy::didFailProvisionalLoadForFrame):
(WebKit::WebPageProxy::didFinishLoadForFrame):
(WebKit::WebPageProxy::didFailLoadForFrame):
(WebKit::WebPageProxy::reportPageLoadResult):

  • UIProcess/WebPageProxy.h:

(WebKit::WebPageProxy::reportPageLoadResult):

Location:
trunk/Source
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r229639 r229643  
     12018-03-15  Keith Rollin  <krollin@apple.com>
     2
     3        Telemetry for stalled webpage loads
     4        https://bugs.webkit.org/show_bug.cgi?id=183221
     5        <rdar://problem/36549013>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Add telemetry for page loads, tracking the pages that succeed, fail,
     10        or are canceled. This information will be used to track the overall
     11        health of our page loading as time goes on.
     12
     13        No new tests -- no new/changed user-level functionality.
     14
     15        * page/DiagnosticLoggingKeys.cpp:
     16        (WebCore::DiagnosticLoggingKeys::telemetryPageLoadKey):
     17        (WebCore::DiagnosticLoggingKeys::timedOutKey):
     18        (WebCore::DiagnosticLoggingKeys::canceledLessThan2SecondsKey):
     19        (WebCore::DiagnosticLoggingKeys::canceledLessThan5SecondsKey):
     20        (WebCore::DiagnosticLoggingKeys::canceledLessThan20SecondsKey):
     21        (WebCore::DiagnosticLoggingKeys::canceledMoreThan20SecondsKey):
     22        (WebCore::DiagnosticLoggingKeys::failedLessThan2SecondsKey):
     23        (WebCore::DiagnosticLoggingKeys::failedLessThan5SecondsKey):
     24        (WebCore::DiagnosticLoggingKeys::failedLessThan20SecondsKey):
     25        (WebCore::DiagnosticLoggingKeys::failedMoreThan20SecondsKey):
     26        (WebCore::DiagnosticLoggingKeys::occurredKey):
     27        (WebCore::DiagnosticLoggingKeys::succeededLessThan2SecondsKey):
     28        (WebCore::DiagnosticLoggingKeys::succeededLessThan5SecondsKey):
     29        (WebCore::DiagnosticLoggingKeys::succeededLessThan20SecondsKey):
     30        (WebCore::DiagnosticLoggingKeys::succeededMoreThan20SecondsKey):
     31        * page/DiagnosticLoggingKeys.h:
     32        * platform/network/cf/ResourceError.h:
     33        (WebCore::ResourceError::ResourceError):
     34        * platform/network/mac/ResourceErrorMac.mm:
     35        (WebCore::ResourceError::ResourceError):
     36        (WebCore::ResourceError::getNSURLErrorDomain const):
     37        (WebCore::ResourceError::getCFErrorDomainCFNetwork const):
     38        (WebCore::ResourceError::mapPlatformError):
     39
    1402018-03-15  Youenn Fablet  <youenn@apple.com>
    241
  • trunk/Source/WebCore/page/DiagnosticLoggingKeys.cpp

    r226677 r229643  
    11/*
    2  * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    564564{
    565565    return ASCIILiteral("synchronousMessageFailed");
     566}
     567
     568String DiagnosticLoggingKeys::telemetryPageLoadKey()
     569{
     570    return ASCIILiteral("telemetryPageLoad");
     571}
     572
     573String DiagnosticLoggingKeys::timedOutKey()
     574{
     575    return ASCIILiteral("timedOut");
     576}
     577
     578String DiagnosticLoggingKeys::canceledLessThan2SecondsKey()
     579{
     580    return ASCIILiteral("canceledLessThan2Seconds");
     581}
     582
     583String DiagnosticLoggingKeys::canceledLessThan5SecondsKey()
     584{
     585    return ASCIILiteral("canceledLessThan5Seconds");
     586}
     587
     588String DiagnosticLoggingKeys::canceledLessThan20SecondsKey()
     589{
     590    return ASCIILiteral("canceledLessThan20Seconds");
     591}
     592
     593String DiagnosticLoggingKeys::canceledMoreThan20SecondsKey()
     594{
     595    return ASCIILiteral("canceledMoreThan20Seconds");
     596}
     597
     598String DiagnosticLoggingKeys::failedLessThan2SecondsKey()
     599{
     600    return ASCIILiteral("failedLessThan2Seconds");
     601}
     602
     603String DiagnosticLoggingKeys::failedLessThan5SecondsKey()
     604{
     605    return ASCIILiteral("failedLessThan5Seconds");
     606}
     607
     608String DiagnosticLoggingKeys::failedLessThan20SecondsKey()
     609{
     610    return ASCIILiteral("failedLessThan20Seconds");
     611}
     612
     613String DiagnosticLoggingKeys::failedMoreThan20SecondsKey()
     614{
     615    return ASCIILiteral("failedMoreThan20Seconds");
     616}
     617
     618String DiagnosticLoggingKeys::occurredKey()
     619{
     620    return ASCIILiteral("occurred");
     621}
     622
     623String DiagnosticLoggingKeys::succeededLessThan2SecondsKey()
     624{
     625    return ASCIILiteral("succeededLessThan2Seconds");
     626}
     627
     628String DiagnosticLoggingKeys::succeededLessThan5SecondsKey()
     629{
     630    return ASCIILiteral("succeededLessThan5Seconds");
     631}
     632
     633String DiagnosticLoggingKeys::succeededLessThan20SecondsKey()
     634{
     635    return ASCIILiteral("succeededLessThan20Seconds");
     636}
     637
     638String DiagnosticLoggingKeys::succeededMoreThan20SecondsKey()
     639{
     640    return ASCIILiteral("succeededMoreThan20Seconds");
    566641}
    567642
  • trunk/Source/WebCore/page/DiagnosticLoggingKeys.h

    r226677 r229643  
    11/*
    2  * Copyright (C) 2012, 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444    static String cachedResourceRevalidationReasonKey();
    4545    static String canCacheKey();
     46    WEBCORE_EXPORT static String canceledLessThan2SecondsKey();
     47    WEBCORE_EXPORT static String canceledLessThan5SecondsKey();
     48    WEBCORE_EXPORT static String canceledLessThan20SecondsKey();
     49    WEBCORE_EXPORT static String canceledMoreThan20SecondsKey();
    4650    static String cannotSuspendActiveDOMObjectsKey();
    4751    WEBCORE_EXPORT static String cpuUsageKey();
     
    6569    WEBCORE_EXPORT static String entryWronglyNotWarmedUpKey();
    6670    static String expiredKey();
     71    WEBCORE_EXPORT static String failedLessThan2SecondsKey();
     72    WEBCORE_EXPORT static String failedLessThan5SecondsKey();
     73    WEBCORE_EXPORT static String failedLessThan20SecondsKey();
     74    WEBCORE_EXPORT static String failedMoreThan20SecondsKey();
    6775    static String fontKey();
    6876    static String hasPluginsKey();
     
    106114    WEBCORE_EXPORT static String notHTTPFamilyKey();
    107115    static String notInMemoryCacheKey();
     116    WEBCORE_EXPORT static String occurredKey();
    108117    WEBCORE_EXPORT static String otherKey();
    109118    static String pageCacheKey();
     
    143152    WEBCORE_EXPORT static String streamingMedia();
    144153    static String styleSheetKey();
     154    WEBCORE_EXPORT static String succeededLessThan2SecondsKey();
     155    WEBCORE_EXPORT static String succeededLessThan5SecondsKey();
     156    WEBCORE_EXPORT static String succeededLessThan20SecondsKey();
     157    WEBCORE_EXPORT static String succeededMoreThan20SecondsKey();
    145158    WEBCORE_EXPORT static String successfulSpeculativeWarmupWithRevalidationKey();
    146159    WEBCORE_EXPORT static String successfulSpeculativeWarmupWithoutRevalidationKey();
    147160    static String svgDocumentKey();
    148161    WEBCORE_EXPORT static String synchronousMessageFailedKey();
     162    WEBCORE_EXPORT static String telemetryPageLoadKey();
     163    WEBCORE_EXPORT static String timedOutKey();
    149164    WEBCORE_EXPORT static String uncacheableStatusCodeKey();
    150165    static String underMemoryPressureKey();
  • trunk/Source/WebCore/platform/network/cf/ResourceError.h

    r227207 r229643  
    5555        , m_dataIsUpToDate(true)
    5656    {
     57#if PLATFORM(COCOA)
     58        ASSERT(domain != getNSURLErrorDomain());
     59        ASSERT(domain != getCFErrorDomainCFNetwork());
     60#endif
    5761    }
    5862
     
    8286    friend class ResourceErrorBase;
    8387
     88#if PLATFORM(COCOA)
     89    WEBCORE_EXPORT const String& getNSURLErrorDomain() const;
     90    WEBCORE_EXPORT const String& getCFErrorDomainCFNetwork() const;
     91    WEBCORE_EXPORT void mapPlatformError();
     92#endif
    8493    void platformLazyInit();
    8594
  • trunk/Source/WebCore/platform/network/mac/ResourceErrorMac.mm

    r224846 r229643  
    3131#import <Foundation/Foundation.h>
    3232#import <wtf/BlockObjCExceptions.h>
     33#import <wtf/NeverDestroyed.h>
     34#import <wtf/text/WTFString.h>
    3335
    3436@interface NSError (WebExtras)
     
    113115    , m_platformError(nsError)
    114116{
    115     if (nsError)
    116         setType(([m_platformError.get() code] == NSURLErrorTimedOut) ? Type::Timeout : Type::General);
     117    mapPlatformError();
    117118}
    118119
     
    120121    : ResourceError((NSError *)cfError)
    121122{
     123}
     124
     125const String& ResourceError::getNSURLErrorDomain() const
     126{
     127    static const NeverDestroyed<String> errorDomain(NSURLErrorDomain);
     128    return errorDomain.get();
     129}
     130
     131const String& ResourceError::getCFErrorDomainCFNetwork() const
     132{
     133    static const NeverDestroyed<String> errorDomain(kCFErrorDomainCFNetwork);
     134    return errorDomain.get();
     135}
     136
     137void ResourceError::mapPlatformError()
     138{
     139    static_assert(NSURLErrorTimedOut == kCFURLErrorTimedOut, "NSURLErrorTimedOut needs to equal kCFURLErrorTimedOut");
     140    static_assert(NSURLErrorCancelled == kCFURLErrorCancelled, "NSURLErrorCancelled needs to equal kCFURLErrorCancelled");
     141
     142    if (!m_platformError)
     143        return;
     144
     145    auto domain = [m_platformError.get() domain];
     146    auto errorCode = [m_platformError.get() code];
     147
     148    if ([domain isEqualToString:NSURLErrorDomain] || [domain isEqualToString:(__bridge NSString *)kCFErrorDomainCFNetwork])
     149        setType((errorCode == NSURLErrorTimedOut) ? Type::Timeout : (errorCode == NSURLErrorCancelled) ? Type::Cancellation : Type::General);
     150    else
     151        setType(Type::General);
    122152}
    123153
  • trunk/Source/WebKit/ChangeLog

    r229641 r229643  
     12018-03-15  Keith Rollin  <krollin@apple.com>
     2
     3        Telemetry for stalled webpage loads
     4        https://bugs.webkit.org/show_bug.cgi?id=183221
     5        <rdar://problem/36549013>
     6
     7        Reviewed by Chris Dumez.
     8
     9        Add telemetry for page loads, tracking the pages that succeed, fail,
     10        or are canceled. This information will be used to track the overall
     11        health of our page loading as time goes on.
     12
     13        * UIProcess/WebPageProxy.cpp:
     14        (WebKit::WebPageProxy::close):
     15        (WebKit::WebPageProxy::didStartProvisionalLoadForFrame):
     16        (WebKit::WebPageProxy::didFailProvisionalLoadForFrame):
     17        (WebKit::WebPageProxy::didFinishLoadForFrame):
     18        (WebKit::WebPageProxy::didFailLoadForFrame):
     19        (WebKit::WebPageProxy::reportPageLoadResult):
     20        * UIProcess/WebPageProxy.h:
     21        (WebKit::WebPageProxy::reportPageLoadResult):
     22
    1232018-03-15  Wenson Hsieh  <wenson_hsieh@apple.com>
    224
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r229617 r229643  
    777777    m_isClosed = true;
    778778
     779    if (m_pageLoadStart)
     780        reportPageLoadResult(ResourceError { ResourceError::Type::Cancellation });
     781
    779782    if (m_activePopupMenu)
    780783        m_activePopupMenu->cancelTracking();
     
    32583261
    32593262    if (frame->isMainFrame()) {
     3263        if (m_pageLoadStart)
     3264            reportPageLoadResult(ResourceError { ResourceError::Type::Cancellation });
     3265        m_pageLoadStart = MonotonicTime::now();
    32603266        m_pageLoadState.didStartProvisionalLoad(transaction, url, unreachableURL);
    32613267        m_pageClient.didStartProvisionalLoadForMainFrame();
     
    33693375
    33703376    if (frame->isMainFrame()) {
     3377        reportPageLoadResult(error);
    33713378        m_pageLoadState.didFailProvisionalLoad(transaction);
    33723379        m_pageClient.didFailProvisionalLoadForMainFrame();
     
    35383545        m_loaderClient->didFinishLoadForFrame(*this, *frame, navigation.get(), m_process->transformHandlesToObjects(userData.object()).get());
    35393546
    3540     if (isMainFrame)
     3547    if (isMainFrame) {
     3548        reportPageLoadResult();
    35413549        m_pageClient.didFinishLoadForMainFrame();
     3550    }
    35423551
    35433552    m_isLoadingAlternateHTMLStringForFailingProvisionalLoad = false;
     
    35793588        m_loaderClient->didFailLoadWithErrorForFrame(*this, *frame, navigation.get(), error, m_process->transformHandlesToObjects(userData.object()).get());
    35803589
    3581     if (isMainFrame)
     3590    if (isMainFrame) {
     3591        reportPageLoadResult(error);
    35823592        m_pageClient.didFailLoadForMainFrame();
     3593    }
    35833594}
    35843595
     
    73747385#endif
    73757386
     7387namespace {
     7388enum class CompletionCondition {
     7389    Cancellation,
     7390    Error,
     7391    Success,
     7392    Timeout,
     7393};
     7394struct MessageType {
     7395    CompletionCondition condition;
     7396    Seconds seconds;
     7397    String message;
     7398};
     7399}
     7400
     7401void WebPageProxy::reportPageLoadResult(const ResourceError& error)
     7402{
     7403    static const NeverDestroyed<Vector<MessageType>> messages(std::initializer_list<MessageType> {
     7404        { CompletionCondition::Cancellation, 2_s, DiagnosticLoggingKeys::canceledLessThan2SecondsKey() },
     7405        { CompletionCondition::Cancellation, 5_s, DiagnosticLoggingKeys::canceledLessThan5SecondsKey() },
     7406        { CompletionCondition::Cancellation, 20_s, DiagnosticLoggingKeys::canceledLessThan20SecondsKey() },
     7407        { CompletionCondition::Cancellation, Seconds::infinity(), DiagnosticLoggingKeys::canceledMoreThan20SecondsKey() },
     7408
     7409        { CompletionCondition::Error, 2_s, DiagnosticLoggingKeys::failedLessThan2SecondsKey() },
     7410        { CompletionCondition::Error, 5_s, DiagnosticLoggingKeys::failedLessThan5SecondsKey() },
     7411        { CompletionCondition::Error, 20_s, DiagnosticLoggingKeys::failedLessThan20SecondsKey() },
     7412        { CompletionCondition::Error, Seconds::infinity(), DiagnosticLoggingKeys::failedMoreThan20SecondsKey() },
     7413
     7414        { CompletionCondition::Success, 2_s, DiagnosticLoggingKeys::succeededLessThan2SecondsKey() },
     7415        { CompletionCondition::Success, 5_s, DiagnosticLoggingKeys::succeededLessThan5SecondsKey() },
     7416        { CompletionCondition::Success, 20_s, DiagnosticLoggingKeys::succeededLessThan20SecondsKey() },
     7417        { CompletionCondition::Success, Seconds::infinity(), DiagnosticLoggingKeys::succeededMoreThan20SecondsKey() },
     7418
     7419        { CompletionCondition::Timeout, Seconds::infinity(), DiagnosticLoggingKeys::timedOutKey() }
     7420        });
     7421
     7422    ASSERT(m_pageLoadStart);
     7423
     7424    auto pageLoadTime = MonotonicTime::now() - *m_pageLoadStart;
     7425    m_pageLoadStart = std::nullopt;
     7426
     7427    CompletionCondition condition { CompletionCondition::Success };
     7428    if (error.isCancellation())
     7429        condition = CompletionCondition::Cancellation;
     7430    else if (error.isTimeout())
     7431        condition = CompletionCondition::Timeout;
     7432    else if (!error.isNull() || error.errorCode())
     7433        condition = CompletionCondition::Error;
     7434
     7435    for (auto& messageItem : messages.get()) {
     7436        if (condition == messageItem.condition && pageLoadTime < messageItem.seconds) {
     7437            logDiagnosticMessage(DiagnosticLoggingKeys::telemetryPageLoadKey(), messageItem.message, ShouldSample::No);
     7438            logDiagnosticMessage(DiagnosticLoggingKeys::telemetryPageLoadKey(), DiagnosticLoggingKeys::occurredKey(), ShouldSample::No);
     7439            break;
     7440        }
     7441    }
     7442}
     7443
    73767444} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r229617 r229643  
    11/*
    2  * Copyright (C) 2010-2017 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010-2018 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    8888#include <wtf/HashSet.h>
    8989#include <wtf/MonotonicTime.h>
     90#include <wtf/Optional.h>
    9091#include <wtf/ProcessID.h>
    9192#include <wtf/Ref.h>
     
    17211722#endif
    17221723
     1724    void reportPageLoadResult(const WebCore::ResourceError& = { });
     1725
    17231726    PageClient& m_pageClient;
    17241727    Ref<API::PageConfiguration> m_configuration;
     
    21192122    HashMap<String, Ref<WebURLSchemeHandler>> m_urlSchemeHandlersByScheme;
    21202123    HashMap<uint64_t, Ref<WebURLSchemeHandler>> m_urlSchemeHandlersByIdentifier;
     2124
     2125    std::optional<MonotonicTime> m_pageLoadStart;
    21212126};
    21222127
Note: See TracChangeset for help on using the changeset viewer.