Changeset 280454 in webkit


Ignore:
Timestamp:
Jul 29, 2021 4:02:09 PM (3 years ago)
Author:
achristensen@apple.com
Message:

[ Mac ] fast/dom/webtiming-document-open.html is a flaky failure
https://bugs.webkit.org/show_bug.cgi?id=228571

Reviewed by Chris Dumez.

Source/WebCore:

In r278391 I made PerformanceTiming::monotonicTimeToIntegerMilliseconds call MonotonicTime::approximateWallTime,
which, if called multiple times, can give slightly different values, usually differing by 1 (millisecond, in this case).
To fix this, cache the value from the first call. This uses an additional 168 bytes per frame in pages that use PerformanceTiming.
Once bug 227336 is turned on and the web is given a year or so to move to that replacement API, this whole API will be removed.

  • page/PerformanceTiming.cpp:

(WebCore::PerformanceTiming::navigationStart const):
(WebCore::PerformanceTiming::unloadEventStart const):
(WebCore::PerformanceTiming::unloadEventEnd const):
(WebCore::PerformanceTiming::redirectStart const):
(WebCore::PerformanceTiming::redirectEnd const):
(WebCore::PerformanceTiming::fetchStart const):
(WebCore::PerformanceTiming::domainLookupStart const):
(WebCore::PerformanceTiming::domainLookupEnd const):
(WebCore::PerformanceTiming::connectStart const):
(WebCore::PerformanceTiming::connectEnd const):
(WebCore::PerformanceTiming::secureConnectionStart const):
(WebCore::PerformanceTiming::requestStart const):
(WebCore::PerformanceTiming::responseStart const):
(WebCore::PerformanceTiming::responseEnd const):
(WebCore::PerformanceTiming::domLoading const):
(WebCore::PerformanceTiming::domInteractive const):
(WebCore::PerformanceTiming::domContentLoadedEventStart const):
(WebCore::PerformanceTiming::domContentLoadedEventEnd const):
(WebCore::PerformanceTiming::domComplete const):
(WebCore::PerformanceTiming::loadEventStart const):
(WebCore::PerformanceTiming::loadEventEnd const):

  • page/PerformanceTiming.h:

LayoutTests:

  • platform/mac/TestExpectations:
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r280450 r280454  
     12021-07-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        [ Mac ] fast/dom/webtiming-document-open.html is a flaky failure
     4        https://bugs.webkit.org/show_bug.cgi?id=228571
     5
     6        Reviewed by Chris Dumez.
     7
     8        * platform/mac/TestExpectations:
     9
    1102021-07-29  Ayumi Kojima  <ayumi_kojima@apple.com>
    211
  • trunk/LayoutTests/platform/mac/TestExpectations

    r280416 r280454  
    23642364[ Monterey Debug arm64 ] imported/w3c/web-platform-tests/webrtc/RTCPeerConnection-restartIce.https.html [ Pass Failure Crash ]
    23652365
    2366 webkit.org/b/228571 fast/dom/webtiming-document-open.html [ Pass Failure ]
    2367 
    23682366webkit.org/b/228396 fast/speechsynthesis/speech-synthesis-speak-empty-string.html [ Pass Failure ]
    23692367
  • trunk/Source/WebCore/ChangeLog

    r280448 r280454  
     12021-07-29  Alex Christensen  <achristensen@webkit.org>
     2
     3        [ Mac ] fast/dom/webtiming-document-open.html is a flaky failure
     4        https://bugs.webkit.org/show_bug.cgi?id=228571
     5
     6        Reviewed by Chris Dumez.
     7
     8        In r278391 I made PerformanceTiming::monotonicTimeToIntegerMilliseconds call MonotonicTime::approximateWallTime,
     9        which, if called multiple times, can give slightly different values, usually differing by 1 (millisecond, in this case).
     10        To fix this, cache the value from the first call.  This uses an additional 168 bytes per frame in pages that use PerformanceTiming.
     11        Once bug 227336 is turned on and the web is given a year or so to move to that replacement API, this whole API will be removed.
     12
     13        * page/PerformanceTiming.cpp:
     14        (WebCore::PerformanceTiming::navigationStart const):
     15        (WebCore::PerformanceTiming::unloadEventStart const):
     16        (WebCore::PerformanceTiming::unloadEventEnd const):
     17        (WebCore::PerformanceTiming::redirectStart const):
     18        (WebCore::PerformanceTiming::redirectEnd const):
     19        (WebCore::PerformanceTiming::fetchStart const):
     20        (WebCore::PerformanceTiming::domainLookupStart const):
     21        (WebCore::PerformanceTiming::domainLookupEnd const):
     22        (WebCore::PerformanceTiming::connectStart const):
     23        (WebCore::PerformanceTiming::connectEnd const):
     24        (WebCore::PerformanceTiming::secureConnectionStart const):
     25        (WebCore::PerformanceTiming::requestStart const):
     26        (WebCore::PerformanceTiming::responseStart const):
     27        (WebCore::PerformanceTiming::responseEnd const):
     28        (WebCore::PerformanceTiming::domLoading const):
     29        (WebCore::PerformanceTiming::domInteractive const):
     30        (WebCore::PerformanceTiming::domContentLoadedEventStart const):
     31        (WebCore::PerformanceTiming::domContentLoadedEventEnd const):
     32        (WebCore::PerformanceTiming::domComplete const):
     33        (WebCore::PerformanceTiming::loadEventStart const):
     34        (WebCore::PerformanceTiming::loadEventEnd const):
     35        * page/PerformanceTiming.h:
     36
    1372021-07-29  Michael Catanzaro  <mcatanzaro@gnome.org>
    238
  • trunk/Source/WebCore/page/PerformanceTiming.cpp

    r278738 r280454  
    5151unsigned long long PerformanceTiming::navigationStart() const
    5252{
    53     auto* timing = documentLoadTiming();
    54     if (!timing)
    55         return 0;
    56 
    57     return monotonicTimeToIntegerMilliseconds(timing->startTime());
     53    if (m_navigationStart)
     54        return m_navigationStart;
     55
     56    auto* timing = documentLoadTiming();
     57    if (!timing)
     58        return 0;
     59
     60    m_navigationStart = monotonicTimeToIntegerMilliseconds(timing->startTime());
     61    return m_navigationStart;
    5862}
    5963
    6064unsigned long long PerformanceTiming::unloadEventStart() const
    6165{
     66    if (m_unloadEventStart)
     67        return m_unloadEventStart;
     68
    6269    auto* timing = documentLoadTiming();
    6370    if (!timing)
     
    7178        return 0;
    7279
    73     return monotonicTimeToIntegerMilliseconds(timing->unloadEventStart());
     80    m_unloadEventStart = monotonicTimeToIntegerMilliseconds(timing->unloadEventStart());
     81    return m_unloadEventStart;
    7482}
    7583
    7684unsigned long long PerformanceTiming::unloadEventEnd() const
    7785{
     86    if (m_unloadEventEnd)
     87        return m_unloadEventEnd;
     88
    7889    auto* timing = documentLoadTiming();
    7990    if (!timing)
     
    8798        return 0;
    8899
    89     return monotonicTimeToIntegerMilliseconds(timing->unloadEventEnd());
     100    m_unloadEventEnd = monotonicTimeToIntegerMilliseconds(timing->unloadEventEnd());
     101    return m_unloadEventEnd;
    90102}
    91103
    92104unsigned long long PerformanceTiming::redirectStart() const
    93105{
     106    if (m_redirectStart)
     107        return m_redirectStart;
     108
    94109    auto* metrics = networkLoadMetrics();
    95110    if (!metrics
     
    98113        return 0;
    99114
    100     return monotonicTimeToIntegerMilliseconds(metrics->redirectStart);
     115    m_redirectStart = monotonicTimeToIntegerMilliseconds(metrics->redirectStart);
     116    return m_redirectStart;
    101117}
    102118
    103119unsigned long long PerformanceTiming::redirectEnd() const
    104120{
     121    if (m_redirectEnd)
     122        return m_redirectEnd;
     123
    105124    auto* metrics = networkLoadMetrics();
    106125    if (!metrics
     
    109128        return 0;
    110129
    111     return monotonicTimeToIntegerMilliseconds(metrics->fetchStart);
     130    m_redirectEnd = monotonicTimeToIntegerMilliseconds(metrics->fetchStart);
     131    return m_redirectEnd;
    112132}
    113133
    114134unsigned long long PerformanceTiming::fetchStart() const
    115135{
     136    if (m_fetchStart)
     137        return m_fetchStart;
     138
    116139    auto* metrics = networkLoadMetrics();
    117140    if (!metrics)
    118141        return 0;
    119142
    120     return monotonicTimeToIntegerMilliseconds(metrics->fetchStart);
     143    m_fetchStart = monotonicTimeToIntegerMilliseconds(metrics->fetchStart);
     144    return m_fetchStart;
    121145}
    122146
    123147unsigned long long PerformanceTiming::domainLookupStart() const
    124148{
     149    if (m_domainLookupStart)
     150        return m_domainLookupStart;
     151
    125152    auto* metrics = networkLoadMetrics();
    126153    if (!metrics || !metrics->domainLookupStart)
    127154        return fetchStart();
    128155
    129     return monotonicTimeToIntegerMilliseconds(metrics->domainLookupStart);
     156    m_domainLookupStart = monotonicTimeToIntegerMilliseconds(metrics->domainLookupStart);
     157    return m_domainLookupStart;
    130158}
    131159
    132160unsigned long long PerformanceTiming::domainLookupEnd() const
    133161{
     162    if (m_domainLookupEnd)
     163        return m_domainLookupEnd;
     164
    134165    auto* metrics = networkLoadMetrics();
    135166    if (!metrics || !metrics->domainLookupEnd)
    136167        return domainLookupStart();
    137168
    138     return monotonicTimeToIntegerMilliseconds(metrics->domainLookupEnd);
     169    m_domainLookupEnd = monotonicTimeToIntegerMilliseconds(metrics->domainLookupEnd);
     170    return m_domainLookupEnd;
    139171}
    140172
    141173unsigned long long PerformanceTiming::connectStart() const
    142174{
     175    if (m_connectStart)
     176        return m_connectStart;
     177
    143178    auto* metrics = networkLoadMetrics();
    144179    if (!metrics || !metrics->connectStart
     
    146181        return domainLookupEnd();
    147182
    148     return monotonicTimeToIntegerMilliseconds(metrics->connectStart);
     183    m_connectStart = monotonicTimeToIntegerMilliseconds(metrics->connectStart);
     184    return m_connectStart;
    149185}
    150186
    151187unsigned long long PerformanceTiming::connectEnd() const
    152188{
     189    if (m_connectEnd)
     190        return m_connectEnd;
     191
    153192    auto* metrics = networkLoadMetrics();
    154193    if (!metrics || !metrics->connectEnd)
    155194        return connectStart();
    156195
    157     return monotonicTimeToIntegerMilliseconds(metrics->connectEnd);
     196    m_connectEnd = monotonicTimeToIntegerMilliseconds(metrics->connectEnd);
     197    return m_connectEnd;
    158198}
    159199
    160200unsigned long long PerformanceTiming::secureConnectionStart() const
    161201{
     202    if (m_secureConnectionStart)
     203        return m_secureConnectionStart;
     204
    162205    auto* metrics = networkLoadMetrics();
    163206    if (!metrics)
     
    168211        return 0;
    169212
    170     return monotonicTimeToIntegerMilliseconds(metrics->secureConnectionStart);
     213    m_secureConnectionStart = monotonicTimeToIntegerMilliseconds(metrics->secureConnectionStart);
     214    return m_secureConnectionStart;
    171215}
    172216
    173217unsigned long long PerformanceTiming::requestStart() const
    174218{
     219    if (m_requestStart)
     220        return m_requestStart;
     221
    175222    auto* metrics = networkLoadMetrics();
    176223    if (!metrics || !metrics->requestStart)
    177224        return connectEnd();
    178225   
    179     return monotonicTimeToIntegerMilliseconds(metrics->requestStart);
     226    m_requestStart = monotonicTimeToIntegerMilliseconds(metrics->requestStart);
     227    return m_requestStart;
    180228}
    181229
    182230unsigned long long PerformanceTiming::responseStart() const
    183231{
     232    if (m_responseStart)
     233        return m_responseStart;
     234
    184235    auto* metrics = networkLoadMetrics();
    185236    if (!metrics || !metrics->responseStart)
    186237        return requestStart();
    187238
    188     return monotonicTimeToIntegerMilliseconds(metrics->responseStart);
     239    m_responseStart = monotonicTimeToIntegerMilliseconds(metrics->responseStart);
     240    return m_responseStart;
    189241}
    190242
    191243unsigned long long PerformanceTiming::responseEnd() const
    192244{
     245    if (m_responseEnd)
     246        return m_responseEnd;
     247
    193248    auto* metrics = networkLoadMetrics();
    194249    if (!metrics || !metrics->responseEnd)
    195250        return responseStart();
    196251
    197     return monotonicTimeToIntegerMilliseconds(metrics->responseEnd);
     252    m_responseEnd = monotonicTimeToIntegerMilliseconds(metrics->responseEnd);
     253    return m_responseEnd;
    198254}
    199255
    200256unsigned long long PerformanceTiming::domLoading() const
    201257{
     258    if (m_domLoading)
     259        return m_domLoading;
     260
    202261    auto* timing = documentEventTiming();
    203262    if (!timing)
    204263        return fetchStart();
    205264
    206     return monotonicTimeToIntegerMilliseconds(timing->domLoading);
     265    m_domLoading = monotonicTimeToIntegerMilliseconds(timing->domLoading);
     266    return m_domLoading;
    207267}
    208268
    209269unsigned long long PerformanceTiming::domInteractive() const
    210270{
    211     auto* timing = documentEventTiming();
    212     if (!timing)
    213         return 0;
    214 
    215     return monotonicTimeToIntegerMilliseconds(timing->domInteractive);
     271    if (m_domInteractive)
     272        return m_domInteractive;
     273
     274    auto* timing = documentEventTiming();
     275    if (!timing)
     276        return 0;
     277
     278    m_domInteractive = monotonicTimeToIntegerMilliseconds(timing->domInteractive);
     279    return m_domInteractive;
    216280}
    217281
    218282unsigned long long PerformanceTiming::domContentLoadedEventStart() const
    219283{
    220     auto* timing = documentEventTiming();
    221     if (!timing)
    222         return 0;
    223 
    224     return monotonicTimeToIntegerMilliseconds(timing->domContentLoadedEventStart);
     284    if (m_domContentLoadedEventStart)
     285        return m_domContentLoadedEventStart;
     286
     287    auto* timing = documentEventTiming();
     288    if (!timing)
     289        return 0;
     290
     291    m_domContentLoadedEventStart = monotonicTimeToIntegerMilliseconds(timing->domContentLoadedEventStart);
     292    return m_domContentLoadedEventStart;
    225293}
    226294
    227295unsigned long long PerformanceTiming::domContentLoadedEventEnd() const
    228296{
    229     auto* timing = documentEventTiming();
    230     if (!timing)
    231         return 0;
    232 
    233     return monotonicTimeToIntegerMilliseconds(timing->domContentLoadedEventEnd);
     297    if (m_domContentLoadedEventEnd)
     298        return m_domContentLoadedEventEnd;
     299
     300    auto* timing = documentEventTiming();
     301    if (!timing)
     302        return 0;
     303
     304    m_domContentLoadedEventEnd = monotonicTimeToIntegerMilliseconds(timing->domContentLoadedEventEnd);
     305    return m_domContentLoadedEventEnd;
    234306}
    235307
    236308unsigned long long PerformanceTiming::domComplete() const
    237309{
    238     auto* timing = documentEventTiming();
    239     if (!timing)
    240         return 0;
    241 
    242     return monotonicTimeToIntegerMilliseconds(timing->domComplete);
     310    if (m_domComplete)
     311        return m_domComplete;
     312
     313    auto* timing = documentEventTiming();
     314    if (!timing)
     315        return 0;
     316
     317    m_domComplete = monotonicTimeToIntegerMilliseconds(timing->domComplete);
     318    return m_domComplete;
    243319}
    244320
    245321unsigned long long PerformanceTiming::loadEventStart() const
    246322{
    247     auto* timing = documentLoadTiming();
    248     if (!timing)
    249         return 0;
    250 
    251     return monotonicTimeToIntegerMilliseconds(timing->loadEventStart());
     323    if (m_loadEventStart)
     324        return m_loadEventStart;
     325
     326    auto* timing = documentLoadTiming();
     327    if (!timing)
     328        return 0;
     329
     330    m_loadEventStart = monotonicTimeToIntegerMilliseconds(timing->loadEventStart());
     331    return m_loadEventStart;
    252332}
    253333
    254334unsigned long long PerformanceTiming::loadEventEnd() const
    255335{
    256     auto* timing = documentLoadTiming();
    257     if (!timing)
    258         return 0;
    259 
    260     return monotonicTimeToIntegerMilliseconds(timing->loadEventEnd());
     336    if (m_loadEventEnd)
     337        return m_loadEventEnd;
     338
     339    auto* timing = documentLoadTiming();
     340    if (!timing)
     341        return 0;
     342
     343    m_loadEventEnd = monotonicTimeToIntegerMilliseconds(timing->loadEventEnd());
     344    return m_loadEventEnd;
    261345}
    262346
  • trunk/Source/WebCore/page/PerformanceTiming.h

    r278391 r280454  
    7979    const NetworkLoadMetrics* networkLoadMetrics() const;
    8080    unsigned long long monotonicTimeToIntegerMilliseconds(MonotonicTime) const;
     81
     82    mutable unsigned long long m_navigationStart { 0 };
     83    mutable unsigned long long m_unloadEventStart { 0 };
     84    mutable unsigned long long m_unloadEventEnd { 0 };
     85    mutable unsigned long long m_redirectStart { 0 };
     86    mutable unsigned long long m_redirectEnd { 0 };
     87    mutable unsigned long long m_fetchStart { 0 };
     88    mutable unsigned long long m_domainLookupStart { 0 };
     89    mutable unsigned long long m_domainLookupEnd { 0 };
     90    mutable unsigned long long m_connectStart { 0 };
     91    mutable unsigned long long m_connectEnd { 0 };
     92    mutable unsigned long long m_secureConnectionStart { 0 };
     93    mutable unsigned long long m_requestStart { 0 };
     94    mutable unsigned long long m_responseStart { 0 };
     95    mutable unsigned long long m_responseEnd { 0 };
     96    mutable unsigned long long m_domLoading { 0 };
     97    mutable unsigned long long m_domInteractive { 0 };
     98    mutable unsigned long long m_domContentLoadedEventStart { 0 };
     99    mutable unsigned long long m_domContentLoadedEventEnd { 0 };
     100    mutable unsigned long long m_domComplete { 0 };
     101    mutable unsigned long long m_loadEventStart { 0 };
     102    mutable unsigned long long m_loadEventEnd { 0 };
    81103};
    82104
Note: See TracChangeset for help on using the changeset viewer.