Bug 179248 - LayoutTest imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https.html is a flaky failure
Summary: LayoutTest imported/w3c/web-platform-tests/service-workers/service-worker/fet...
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: youenn fablet
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2017-11-03 11:21 PDT by Ryan Haddad
Modified: 2018-03-02 14:10 PST (History)
9 users (show)

See Also:


Attachments
Patch (4.45 KB, patch)
2018-03-01 10:42 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (6.09 KB, patch)
2018-03-01 11:46 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Patch (6.92 KB, patch)
2018-03-01 12:06 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews104 for mac-sierra-wk2 (2.62 MB, application/zip)
2018-03-01 13:16 PST, EWS Watchlist
no flags Details
Archive of layout-test-results from ews124 for ios-simulator-wk2 (2.29 MB, application/zip)
2018-03-01 13:41 PST, EWS Watchlist
no flags Details
Patch (7.58 KB, patch)
2018-03-01 13:59 PST, youenn fablet
no flags Details | Formatted Diff | Diff
Further fix (2.10 KB, patch)
2018-03-02 09:41 PST, youenn fablet
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Haddad 2017-11-03 11:21:03 PDT
LayoutTest imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https.html is a flaky failure

https://build.webkit.org/results/Apple%20Sierra%20Release%20WK2%20(Tests)/r224399%20(5489)/results.html

https://webkit-test-results.webkit.org/dashboards/flakiness_dashboard.html#showAllRuns=true&tests=imported%2Fw3c%2Fweb-platform-tests%2Fservice-workers%2Fservice-worker%2Ffetch-event-within-sw.https.html

--- /Volumes/Data/slave/sierra-release-tests-wk2/build/layout-test-results/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https-expected.txt
+++ /Volumes/Data/slave/sierra-release-tests-wk2/build/layout-test-results/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https-actual.txt
@@ -1,4 +1,6 @@
 
-FAIL Service worker intercepts requests from window assert_equals: fetch intercepted expected "intercepted" but got "Hello world\n"
-FAIL Service worker does not intercept fetch/cache requests within service worker assert_equals: fetch within SW not intercepted expected "Hello world\n" but got "{\"error\": {\"message\": \"\", \"code\": 404}}"
+Harness Error (TIMEOUT), message = null
 
+TIMEOUT Service worker intercepts requests from window Test timed out
+NOTRUN Service worker does not intercept fetch/cache requests within service worker 
+
Comment 1 Ryan Haddad 2017-11-03 14:29:46 PDT
Marked test as flaky in https://trac.webkit.org/changeset/224429/webkit
Comment 2 Radar WebKit Bug Importer 2017-11-06 17:07:48 PST
<rdar://problem/35377756>
Comment 3 Chris Dumez 2018-02-06 10:38:16 PST
Looks like this test is still flaky.
Comment 4 youenn fablet 2018-03-01 10:35:45 PST
Test is no longer timing out.
It sometimes fails:

--- /Volumes/Data/slave/highsierra-release-tests-wk2/build/layout-test-results/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https-expected.txt
+++ /Volumes/Data/slave/highsierra-release-tests-wk2/build/layout-test-results/imported/w3c/web-platform-tests/service-workers/service-worker/fetch-event-within-sw.https-actual.txt
@@ -1,3 +1,4 @@
+CONSOLE MESSAGE: There was an error making test persistent on the filesystem
 
 PASS Service worker intercepts requests from window 
 PASS Service worker does not intercept fetch/cache requests within service worker
Comment 5 youenn fablet 2018-03-01 10:42:27 PST
Created attachment 334825 [details]
Patch
Comment 6 youenn fablet 2018-03-01 11:05:51 PST
Hum, got the following flaky crash.
It seems like our callback given to is IOChannel::write is executed from main thread but sometimes destroyed in a secondary thread.
Or maybe it is not even executed.

 
Thread 8 Crashed:: Dispatch queue: com.apple.libdispatch-io.deviceq.1
0   com.apple.JavaScriptCore      	0x000000011856a834 WTFCrash + 36 (Assertions.cpp:271)
1   com.apple.WebKit              	0x0000000102590d61 WebKit::NetworkCache::Storage::~Storage() + 81 (NetworkCacheStorage.cpp:236)
2   com.apple.WebKit              	0x0000000102591375 WebKit::NetworkCache::Storage::~Storage() + 21 (NetworkCacheStorage.cpp:242)
3   com.apple.WebKit              	0x00000001023a87b7 WTF::ThreadSafeRefCounted<WebKit::NetworkCache::Storage>::deref() const + 71 (ThreadSafeRefCounted.h:71)
4   com.apple.WebKit              	0x00000001023a8711 void WTF::derefIfNotNull<WebKit::NetworkCache::Storage>(WebKit::NetworkCache::Storage*) + 49 (RefPtr.h:46)
5   com.apple.WebKit              	0x00000001023a86d9 WTF::RefPtr<WebKit::NetworkCache::Storage, WTF::DumbPtrTraits<WebKit::NetworkCache::Storage> >::~RefPtr() + 41 (RefPtr.h:70)
6   com.apple.WebKit              	0x00000001023a1035 WTF::RefPtr<WebKit::NetworkCache::Storage, WTF::DumbPtrTraits<WebKit::NetworkCache::Storage> >::~RefPtr() + 21 (RefPtr.h:70)
7   com.apple.WebKit              	0x00000001023a0f64 WebKit::CacheStorage::Caches::~Caches() + 164 (CacheStorageEngineCaches.cpp:56)
8   com.apple.WebKit              	0x00000001023a1095 WebKit::CacheStorage::Caches::~Caches() + 21 (CacheStorageEngineCaches.cpp:56)
9   com.apple.WebKit              	0x0000000102365fe7 WTF::RefCounted<WebKit::CacheStorage::Caches>::deref() const + 71 (RefCounted.h:145)
10  com.apple.WebKit              	0x00000001023744cf WTF::Ref<WebKit::CacheStorage::Caches, WTF::DumbPtrTraits<WebKit::CacheStorage::Caches> >::~Ref() + 47 (Ref.h:62)
11  com.apple.WebKit              	0x0000000102373ee5 WTF::Ref<WebKit::CacheStorage::Caches, WTF::DumbPtrTraits<WebKit::CacheStorage::Caches> >::~Ref() + 21 (Ref.h:62)
12  com.apple.WebKit              	0x00000001023a656c WebKit::CacheStorage::Caches::storeOrigin(WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_2::~$_2() + 44 (CacheStorageEngineCaches.cpp:97)
13  com.apple.WebKit              	0x00000001023a16d5 WebKit::CacheStorage::Caches::storeOrigin(WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_2::~$_2() + 21 (CacheStorageEngineCaches.cpp:97)
14  com.apple.WebKit              	0x00000001023ab021 WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>::CallableWrapper<WebKit::CacheStorage::Caches::storeOrigin(WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_2>::~CallableWrapper() + 49 (Function.h:91)
15  com.apple.WebKit              	0x00000001023aaf25 WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>::CallableWrapper<WebKit::CacheStorage::Caches::storeOrigin(WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_2>::~CallableWrapper() + 21 (Function.h:91)
16  com.apple.WebKit              	0x00000001023aaf49 WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>::CallableWrapper<WebKit::CacheStorage::Caches::storeOrigin(WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_2>::~CallableWrapper() + 25 (Function.h:91)
17  com.apple.WebKit              	0x000000010236811f WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>::~Function() + 175 (memory:2603)
18  com.apple.WebKit              	0x0000000102363815 WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>::~Function() + 21 (Forward.h:56)
19  com.apple.WebKit              	0x0000000102376825 WebKit::CacheStorage::Engine::writeFile(WTF::String const&, WebKit::NetworkCache::Data&&, WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_9::operator()()::'lambda'(int)::~'lambda'(int)() + 21 (CacheStorageEngine.cpp:282)
20  com.apple.WebKit              	0x0000000102375ea5 WebKit::CacheStorage::Engine::writeFile(WTF::String const&, WebKit::NetworkCache::Data&&, WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_9::operator()()::'lambda'(int)::~'lambda'(int)() + 21 (CacheStorageEngine.cpp:282)
21  com.apple.WebKit              	0x00000001023765d1 WTF::Function<void (int)>::CallableWrapper<WebKit::CacheStorage::Engine::writeFile(WTF::String const&, WebKit::NetworkCache::Data&&, WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_9::operator()()::'lambda'(int)>::~CallableWrapper() + 49 (Function.h:91)
22  com.apple.WebKit              	0x0000000102376485 WTF::Function<void (int)>::CallableWrapper<WebKit::CacheStorage::Engine::writeFile(WTF::String const&, WebKit::NetworkCache::Data&&, WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_9::operator()()::'lambda'(int)>::~CallableWrapper() + 21 (Function.h:91)
23  com.apple.WebKit              	0x00000001023764a9 WTF::Function<void (int)>::CallableWrapper<WebKit::CacheStorage::Engine::writeFile(WTF::String const&, WebKit::NetworkCache::Data&&, WTF::Function<void (std::optional<WebCore::DOMCacheEngine::Error>&&)>&&)::$_9::operator()()::'lambda'(int)>::~CallableWrapper() + 25 (Function.h:91)
24  com.apple.WebKit              	0x00000001023767ff WTF::Function<void (int)>::~Function() + 175 (memory:2603)
25  com.apple.WebKit              	0x0000000102375e85 WTF::Function<void (int)>::~Function() + 21 (Forward.h:56)
26  com.apple.WebKit              	0x00000001025589c3 WebKit::NetworkCache::IOChannel::write(unsigned long, WebKit::NetworkCache::Data const&, WTF::WorkQueue*, WTF::Function<void (int)>&&)::$_2::~$_2() + 35 (NetworkCacheIOChannelCocoa.mm:115)
27  com.apple.WebKit              	0x00000001025586d5 WebKit::NetworkCache::IOChannel::write(unsigned long, WebKit::NetworkCache::Data const&, WTF::WorkQueue*, WTF::Function<void (int)>&&)::$_2::~$_2() + 21 (NetworkCacheIOChannelCocoa.mm:115)
28  com.apple.WebKit              	0x0000000102559230 WTF::BlockPtr<void (bool, NSObject<OS_dispatch_data>*, int)> WTF::BlockPtr<void (bool, NSObject<OS_dispatch_data>*, int)>::fromCallable<WebKit::NetworkCache::IOChannel::write(unsigned long, WebKit::NetworkCache::Data const&, WTF::WorkQueue*, WTF::Function<void (int)>&&)::$_2>(WebKit::NetworkCache::IOChannel::write(unsigned long, WebKit::NetworkCache::Data const&, WTF::WorkQueue*, WTF::Function<void (int)>&&)::$_2)::'lambda'(void const*)::operator()(void const*) const + 32 (BlockPtr.h:79)
29  com.apple.WebKit              	0x0000000102559208 WTF::BlockPtr<void (bool, NSObject<OS_dispatch_data>*, int)> WTF::BlockPtr<void (bool, NSObject<OS_dispatch_data>*, int)>::fromCallable<WebKit::NetworkCache::IOChannel::write(unsigned long, WebKit::NetworkCache::Data const&, WTF::WorkQueue*, WTF::Function<void (int)>&&)::$_2>(WebKit::NetworkCache::IOChannel::write(unsigned long, WebKit::NetworkCache::Data const&, WTF::WorkQueue*, WTF::Function<void (int)>&&)::$_2)::'lambda'(void const*)::__invoke(void const*) + 24 (BlockPtr.h:77)
30  libsystem_blocks.dylib        	0x00007fff57d1199d _Block_release + 111
31  libdispatch.dylib             	0x00007fff57c8acd0 _dispatch_dispose + 61
32  libdispatch.dylib             	0x00007fff57c915ca _dispatch_call_block_and_release + 12
33  libdispatch.dylib             	0x00007fff57c89d88 _dispatch_client_callout + 8
34  libdispatch.dylib             	0x00007fff57c9e209 _dispatch_queue_serial_drain + 635
35  libdispatch.dylib             	0x00007fff57c91136 _dispatch_queue_invoke + 373
36  libdispatch.dylib             	0x00007fff57c9eeff _dispatch_root_queue_drain_deferred_wlh + 332
37  libdispatch.dylib             	0x00007fff57ca2d13 _dispatch_workloop_worker_thread + 880
38  libsystem_pthread.dylib       	0x00007fff57fce033 _pthread_wqthread + 980
39  libsystem_pthread.dylib       	0x00007fff57fcdc4d start_wqthread + 13
Comment 7 youenn fablet 2018-03-01 11:46:58 PST
Created attachment 334832 [details]
Patch
Comment 8 youenn fablet 2018-03-01 11:55:58 PST
(In reply to youenn fablet from comment #7)
> Created attachment 334832 [details]
> Patch

Updated CacheStorage::Engine::writeFile/readFile and it seems to fix the crash locally.
If that is the real issue, I guess this could be fixed in IOChannel::read/IOChannel::write instead as a follow-up.
I would need to dig further into dispatch_io_read/dispatch_io_write.
Comment 9 youenn fablet 2018-03-01 12:06:53 PST
Created attachment 334836 [details]
Patch
Comment 10 EWS Watchlist 2018-03-01 13:16:18 PST
Comment on attachment 334836 [details]
Patch

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

New failing tests:
http/tests/cache-storage/cache-clearing-origin.https.html
http/tests/cache-storage/cache-clearing-all.https.html
http/tests/cache-storage/cache-origins.https.html
Comment 11 EWS Watchlist 2018-03-01 13:16:20 PST
Created attachment 334844 [details]
Archive of layout-test-results from ews104 for mac-sierra-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews104  Port: mac-sierra-wk2  Platform: Mac OS X 10.12.6
Comment 12 EWS Watchlist 2018-03-01 13:41:33 PST
Comment on attachment 334836 [details]
Patch

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

New failing tests:
http/tests/cache-storage/cache-clearing-origin.https.html
http/tests/cache-storage/cache-clearing-all.https.html
http/tests/cache-storage/cache-origins.https.html
Comment 13 EWS Watchlist 2018-03-01 13:41:34 PST
Created attachment 334847 [details]
Archive of layout-test-results from ews124 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews124  Port: ios-simulator-wk2  Platform: Mac OS X 10.12.6
Comment 14 youenn fablet 2018-03-01 13:59:51 PST
Created attachment 334851 [details]
Patch
Comment 15 WebKit Commit Bot 2018-03-01 15:19:12 PST
Comment on attachment 334851 [details]
Patch

Clearing flags on attachment: 334851

Committed r229151: <https://trac.webkit.org/changeset/229151>
Comment 16 WebKit Commit Bot 2018-03-01 15:19:14 PST
All reviewed patches have been landed.  Closing bug.
Comment 17 youenn fablet 2018-03-02 08:25:13 PST
This is apparently not sufficient.
Bots now also get some errors like:

FAIL Service worker intercepts requests from window assert_equals: cache.add intercepted expected "intercepted" but got "cache match failed"
Comment 18 youenn fablet 2018-03-02 09:41:00 PST
Reopening to attach new patch.
Comment 19 youenn fablet 2018-03-02 09:41:01 PST
Created attachment 334902 [details]
Further fix
Comment 20 WebKit Commit Bot 2018-03-02 14:10:21 PST
Comment on attachment 334902 [details]
Further fix

Clearing flags on attachment: 334902

Committed r229188: <https://trac.webkit.org/changeset/229188>
Comment 21 WebKit Commit Bot 2018-03-02 14:10:22 PST
All reviewed patches have been landed.  Closing bug.