Bug 158019 - Fix ResourceTiming XHR flakiness
Summary: Fix ResourceTiming XHR flakiness
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-24 03:22 PDT by Yoav Weiss
Modified: 2016-05-25 22:32 PDT (History)
9 users (show)

See Also:


Attachments
Patch (7.99 KB, patch)
2016-05-24 03:27 PDT, Yoav Weiss
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-yosemite-wk2 (1.05 MB, application/zip)
2016-05-24 03:51 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews101 for mac-yosemite (998.80 KB, application/zip)
2016-05-24 04:13 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews121 for ios-simulator-wk2 (671.63 KB, application/zip)
2016-05-24 04:24 PDT, Build Bot
no flags Details
Archive of layout-test-results from ews117 for mac-yosemite (1.42 MB, application/zip)
2016-05-24 04:25 PDT, Build Bot
no flags Details
Patch (13.47 KB, patch)
2016-05-24 04:40 PDT, Yoav Weiss
no flags Details | Formatted Diff | Diff
Patch (13.24 KB, patch)
2016-05-24 09:57 PDT, Yoav Weiss
no flags Details | Formatted Diff | Diff
Patch (15.91 KB, patch)
2016-05-24 14:38 PDT, Yoav Weiss
no flags Details | Formatted Diff | Diff
Patch (7.88 KB, patch)
2016-05-25 14:39 PDT, Yoav Weiss
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Yoav Weiss 2016-05-24 03:22:16 PDT
Fix ResourceTiming XHR tests flakiness
Comment 1 Yoav Weiss 2016-05-24 03:27:53 PDT
Created attachment 279638 [details]
Patch
Comment 2 Yoav Weiss 2016-05-24 03:40:15 PDT
This should fix the test flakiness observed in https://bugs.webkit.org/show_bug.cgi?id=157816

It also removes the XHR-specific treatment that I added in https://bugs.webkit.org/show_bug.cgi?id=157669 as it is not required.

It seems like the ResourceTiming entries are added in CachedResourceLoader::loadDone only after the onload event for the XHR is running. I've opened a related spec issue to see what the correct behavior here should be: https://github.com/w3c/resource-timing/issues/55
Comment 3 Build Bot 2016-05-24 03:51:55 PDT
Comment on attachment 279638 [details]
Patch

Attachment 279638 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1373989

New failing tests:
http/tests/performance/performance-resource-timing-xhr-single-entry.html
Comment 4 Build Bot 2016-05-24 03:51:59 PDT
Created attachment 279640 [details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 5 Build Bot 2016-05-24 04:13:47 PDT
Comment on attachment 279638 [details]
Patch

Attachment 279638 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/1374049

New failing tests:
http/tests/performance/performance-resource-timing-xhr-single-entry.html
Comment 6 Build Bot 2016-05-24 04:13:52 PDT
Created attachment 279641 [details]
Archive of layout-test-results from ews101 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 7 Build Bot 2016-05-24 04:24:07 PDT
Comment on attachment 279638 [details]
Patch

Attachment 279638 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/1374057

New failing tests:
http/tests/performance/performance-resource-timing-xhr-single-entry.html
Comment 8 Build Bot 2016-05-24 04:24:12 PDT
Created attachment 279642 [details]
Archive of layout-test-results from ews121 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews121  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.4
Comment 9 Build Bot 2016-05-24 04:25:14 PDT
Comment on attachment 279638 [details]
Patch

Attachment 279638 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/1374054

New failing tests:
http/tests/performance/performance-resource-timing-xhr-single-entry.html
Comment 10 Build Bot 2016-05-24 04:25:19 PDT
Created attachment 279643 [details]
Archive of layout-test-results from ews117 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews117  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 11 Yoav Weiss 2016-05-24 04:40:03 PDT
Created attachment 279645 [details]
Patch
Comment 12 Alexey Proskuryakov 2016-05-24 08:27:52 PDT
Comment on attachment 279645 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=279645&action=review

> LayoutTests/http/tests/performance/performance-resource-timing-cached-entries.html:35
> +            setTimeout(runTest, 10);

A timeout of 10 ms is never right in regression tests. A process can be easily suspended for much longer. It's especially expected on GuardMalloc and ASan tests, but even release build tests have a lot of competition for resources.
Comment 13 Yoav Weiss 2016-05-24 08:42:42 PDT
(In reply to comment #12)
> Comment on attachment 279645 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=279645&action=review
> 
> > LayoutTests/http/tests/performance/performance-resource-timing-cached-entries.html:35
> > +            setTimeout(runTest, 10);
> 
> A timeout of 10 ms is never right in regression tests. A process can be
> easily suspended for much longer. It's especially expected on GuardMalloc
> and ASan tests, but even release build tests have a lot of competition for
> resources.

Any timeout would do here, it's just that I need for the test to run after the XHR's load event is over. So if the process will get suspended for a longer period, that's not an issue as long as the test's timeout is not exceeded. Let me know if a different timeout value (or a different method to run the test after the onload is over) is preferred.
Comment 14 Alex Christensen 2016-05-24 08:50:39 PDT
Comment on attachment 279645 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=279645&action=review

Would it work with a timeout of 0?  I think a better approach would be to create the xhr after you're done with the first runTest call to make sure it will never start before the first one.

> LayoutTests/http/tests/performance/performance-resource-timing-xhr-single-entry.html:35
> +            setTimeout(runTest, 10);

Why do you call runTest twice but only expect it to be run once?
Comment 15 Yoav Weiss 2016-05-24 09:01:52 PDT
(In reply to comment #14)
> Comment on attachment 279645 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=279645&action=review
> 
> Would it work with a timeout of 0?

I believe it would.

> I think a better approach would be to
> create the xhr after you're done with the first runTest call to make sure it
> will never start before the first one.
> 
> > LayoutTests/http/tests/performance/performance-resource-timing-xhr-single-entry.html:35
> > +            setTimeout(runTest, 10);
> 
> Why do you call runTest twice but only expect it to be run once?

I copied this mechanism from another test where the XHR call is racing with window's onload event (as XHR is not blocking onload). So, I wanted the test to run once at the later one of those events, but not inside XHR's onload event, as the entries are not yet added at this point. It's true that for the xhr-single-entry I could just eliminate the window.onload part altogether.
Comment 16 Yoav Weiss 2016-05-24 09:57:30 PDT
Created attachment 279666 [details]
Patch
Comment 17 Yoav Weiss 2016-05-24 14:38:52 PDT
Created attachment 279707 [details]
Patch
Comment 18 Yoav Weiss 2016-05-24 22:44:52 PDT
Latest patch adds back the tests that got rolled out in http://trac.webkit.org/changeset/201343, as this fixes their flakiness.

Let me know if it's preferred that I'll split this patch into two separate ones (as it treats two different flakiness issues).
Comment 19 Alex Christensen 2016-05-25 14:14:51 PDT
Could you describe the difference in your latest patch?
Comment 20 Yoav Weiss 2016-05-25 14:39:48 PDT
Created attachment 279818 [details]
Patch
Comment 21 Yoav Weiss 2016-05-25 14:41:42 PDT
I removed the parts related to initiator tests flakiness, and only left in the parts related to XHR flakiness, in order to make the patch clearer. I'll submit the initiator parts as a separate patch.
Comment 22 Yoav Weiss 2016-05-25 15:00:20 PDT
Initiator changes are at https://bugs.webkit.org/show_bug.cgi?id=158094
Comment 23 WebKit Commit Bot 2016-05-25 22:32:49 PDT
Comment on attachment 279818 [details]
Patch

Clearing flags on attachment: 279818

Committed r201414: <http://trac.webkit.org/changeset/201414>
Comment 24 WebKit Commit Bot 2016-05-25 22:32:55 PDT
All reviewed patches have been landed.  Closing bug.