Bug 182558

Summary: ASSERTION FAILED: m_timeOrigin in Performance::Performance()
Product: WebKit Reporter: Daniel Bates <dbates>
Component: WebCore Misc.Assignee: youenn fablet <youennf>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, cdumez, commit-queue, ews-watchlist, japhet, rniwa, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: iPhone / iPad   
OS: iOS 11   
URL: http://www.twitter.com
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews102 for mac-sierra
none
Archive of layout-test-results from ews113 for mac-sierra
none
Archive of layout-test-results from ews200 for win-future
none
Moving test to WK2 only none

Description Daniel Bates 2018-02-06 16:42:00 PST
Using a build of WebKit for iOS Simulator, perform the following:

1. Open MobileSafari.
2. Visit http://www.twitter.com.
3. Sign into Twitter.

Then the WebContent process will crash because the ASSERT(m_timeOrigin) fails in Performance::Performance(). If it does not crash, try refreshing the page.
Comment 1 Daniel Bates 2018-02-06 16:51:29 PST
#0	0x0000000115c7bf94 in ::WTFCrash() at /Volumes/Data/WebKitDevGit/OpenSource/Source/WTF/wtf/Assertions.cpp:272
#1	0x000000011a9638af in WebCore::Performance::Performance(WebCore::ScriptExecutionContext&, WTF::MonotonicTime) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebCore/page/Performance.cpp:59
#2	0x000000011a963d97 in WebCore::Performance::Performance(WebCore::ScriptExecutionContext&, WTF::MonotonicTime) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebCore/page/Performance.cpp:58
#3	0x000000011a884288 in WebCore::Performance::create(WebCore::ScriptExecutionContext&, WTF::MonotonicTime) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebCore/page/Performance.h:57
#4	0x000000011a8841d5 in WebCore::DOMWindow::performance() const at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebCore/page/DOMWindow.cpp:794
#5	0x000000011a7a8531 in WebCore::ResourceTimingInformation::addResourceTiming(WebCore::CachedResource&, WebCore::Document&, WebCore::ResourceTiming&&) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebCore/loader/ResourceTimingInformation.cpp:81
#6	0x000000011a7bb85b in WebCore::SubresourceLoader::reportResourceTiming(WebCore::NetworkLoadMetrics const&) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebCore/loader/SubresourceLoader.cpp:747
#7	0x000000011a7b94ed in WebCore::SubresourceLoader::didFinishLoading(WebCore::NetworkLoadMetrics const&) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebCore/loader/SubresourceLoader.cpp:587
#8	0x000000010953be98 in WebKit::WebResourceLoader::didFinishResourceLoad(WebCore::NetworkLoadMetrics const&) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/WebProcess/Network/WebResourceLoader.cpp:150
#9	0x000000010953f9ea in void IPC::callMemberFunctionImpl<WebKit::WebResourceLoader, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&), std::__1::tuple<WebCore::NetworkLoadMetrics>, 0ul>(WebKit::WebResourceLoader*, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&), std::__1::tuple<WebCore::NetworkLoadMetrics>&&, std::__1::integer_sequence<unsigned long, 0ul>) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/Platform/IPC/HandleMessage.h:40
#10	0x000000010953f850 in void IPC::callMemberFunction<WebKit::WebResourceLoader, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&), std::__1::tuple<WebCore::NetworkLoadMetrics>, std::__1::integer_sequence<unsigned long, 0ul> >(std::__1::tuple<WebCore::NetworkLoadMetrics>&&, WebKit::WebResourceLoader*, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&)) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/Platform/IPC/HandleMessage.h:46
#11	0x000000010953ebb6 in void IPC::handleMessage<Messages::WebResourceLoader::DidFinishResourceLoad, WebKit::WebResourceLoader, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&)>(IPC::Decoder&, WebKit::WebResourceLoader*, void (WebKit::WebResourceLoader::*)(WebCore::NetworkLoadMetrics const&)) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/Platform/IPC/HandleMessage.h:126
#12	0x000000010953e22c in WebKit::WebResourceLoader::didReceiveWebResourceLoaderMessage(IPC::Connection&, IPC::Decoder&) at /Volumes/Data/WebKitDevGit/OpenSource/WebKitBuild/Debug-iphonesimulator/DerivedSources/WebKit2/WebResourceLoaderMessageReceiver.cpp:65
#13	0x0000000108ca9569 in WebKit::NetworkProcessConnection::didReceiveMessage(IPC::Connection&, IPC::Decoder&) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/WebProcess/Network/NetworkProcessConnection.cpp:69
#14	0x0000000108a65ea3 in IPC::Connection::dispatchMessage(IPC::Decoder&) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/Platform/IPC/Connection.cpp:907
#15	0x0000000108a5b508 in IPC::Connection::dispatchMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/Platform/IPC/Connection.cpp:934
#16	0x0000000108a664f4 in IPC::Connection::dispatchOneMessage() at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/Platform/IPC/Connection.cpp:965
#17	0x0000000108a7db7d in IPC::Connection::enqueueIncomingMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)::$_14::operator()() at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/Platform/IPC/Connection.cpp:901
#18	0x0000000108a7dad9 in WTF::Function<void ()>::CallableWrapper<IPC::Connection::enqueueIncomingMessage(std::__1::unique_ptr<IPC::Decoder, std::__1::default_delete<IPC::Decoder> >)::$_14>::call() at /Volumes/Data/WebKitDevGit/OpenSource/WebKitBuild/Debug-iphonesimulator/usr/local/include/wtf/Function.h:101
#19	0x0000000115c9818b in WTF::Function<void ()>::operator()() const at /Volumes/Data/WebKitDevGit/OpenSource/WebKitBuild/Debug-iphonesimulator/usr/local/include/wtf/Function.h:56
#20	0x0000000115cdd2d3 in WTF::RunLoop::performWork() at /Volumes/Data/WebKitDevGit/OpenSource/Source/WTF/wtf/RunLoop.cpp:106
#21	0x0000000115cddb74 in WTF::RunLoop::performWork(void*) at /Volumes/Data/WebKitDevGit/OpenSource/Source/WTF/wtf/cf/RunLoopCF.cpp:38
#22	0x000000010d32e0d1 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ ()
#23	0x000000010d312a8f in __CFRunLoopDoSources0 ()
#24	0x000000010d31204f in __CFRunLoopRun ()
#25	0x000000010d3118eb in CFRunLoopRunSpecific ()
#26	0x0000000108325aaa in -[NSRunLoop(NSRunLoop) runMode:beforeDate:] ()
#27	0x0000000108325985 in -[NSRunLoop(NSRunLoop) run] ()
#28	0x000000010ef2d915 in _xpc_objc_main ()
#29	0x000000010ef2fdbf in xpc_main ()
#30	0x0000000108026c5e in main at /Volumes/Data/WebKitDevGit/OpenSource/Source/WebKit/Shared/EntryPointUtilities/mac/XPCService/XPCServiceMain.mm:148
#31	0x000000010eb7e955 in start ()
Comment 2 Daniel Bates 2018-02-06 16:52:57 PST
Twitter.com fetches <https://api.twitter.com/1.1/jot/client_event.json> initiated from ServiceWorkerThreadProxy. For some reason fetching this resource makes a CORS preflight request, but we do not propagate the initiator context of the request that caused the preflight request (InitiatorContext::Worker). In the async case, CrossOriginPreflightChecker::startPreflight() is called and the preflight request is made with initiator context InitiatorContext::Document (the default since CrossOriginPreflightChecker::startPreflight() does not override it). As a result, we do not execute the Worker code path in SubresourceLoader::reportResourceTiming: <http://trac.webkit.org/browser/trunk/Source/WebCore/loader/SubresourceLoader.cpp?rev=228183#L740>.
Comment 3 youenn fablet 2018-02-06 18:23:09 PST
Thanks for the report and precise description!
Are you planning to fix it or are you fine someone else takes over?
Comment 4 Radar WebKit Bug Importer 2018-02-06 18:23:34 PST
<rdar://problem/37297551>
Comment 5 Daniel Bates 2018-02-06 19:48:57 PST
(In reply to youenn fablet from comment #3)
> Thanks for the report and precise description!
> Are you planning to fix it or are you fine someone else takes over?

Feel free to take this bug and fix it.
Comment 6 youenn fablet 2018-02-06 22:57:00 PST
Created attachment 333268 [details]
Patch
Comment 7 EWS Watchlist 2018-02-06 23:56:58 PST
Comment on attachment 333268 [details]
Patch

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

New failing tests:
media/modern-media-controls/tracks-support/tracks-support-show-panel-after-dragging-controls.html
http/wpt/fetch/cors-preflight-star.any.serviceworker.html
Comment 8 EWS Watchlist 2018-02-06 23:56:59 PST
Created attachment 333270 [details]
Archive of layout-test-results from ews102 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 9 EWS Watchlist 2018-02-07 00:25:01 PST
Comment on attachment 333268 [details]
Patch

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

New failing tests:
http/wpt/fetch/cors-preflight-star.any.serviceworker.html
Comment 10 EWS Watchlist 2018-02-07 00:25:03 PST
Created attachment 333271 [details]
Archive of layout-test-results from ews113 for mac-sierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-sierra  Platform: Mac OS X 10.12.6
Comment 11 EWS Watchlist 2018-02-07 00:48:27 PST
Comment on attachment 333268 [details]
Patch

Attachment 333268 [details] did not pass win-ews (win):
Output: http://webkit-queues.webkit.org/results/6395127

New failing tests:
http/wpt/fetch/cors-preflight-star.any.serviceworker.html
Comment 12 EWS Watchlist 2018-02-07 00:48:38 PST
Created attachment 333272 [details]
Archive of layout-test-results from ews200 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews200  Port: win-future  Platform: CYGWIN_NT-6.1-2.9.0-0.318-5-3-x86_64-64bit
Comment 13 youenn fablet 2018-02-07 08:29:55 PST
Created attachment 333289 [details]
Moving test to WK2 only
Comment 14 Daniel Bates 2018-02-07 10:01:29 PST
Comment on attachment 333289 [details]
Moving test to WK2 only

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

> LayoutTests/ChangeLog:12
> +        * http/wpt/service-workers/cors-preflight-star.any.js: Added.

It would also be good to add tests for async and sync CORS preflight requests initiated from a Web Worker. We do not need to do this in this patch. It can be done in a subsequent bug/patch.

> LayoutTests/http/wpt/service-workers/cors-preflight-star.any.js:44
> +preflightTest(true, false, "get", "x-test", "GET", ["X-Test", "1"])
> +preflightTest(true, false, "*", "x-test", "SUPER", ["X-Test", "1"])
> +preflightTest(true, false, "*", "*", "OK", ["X-Test", "1"])
> +preflightTest(false, true, "*", "*", "OK", ["X-Test", "1"])
> +preflightTest(false, true, "*", "", "PUT", [])
> +preflightTest(true, true, "PUT", "*", "PUT", [])
> +preflightTest(false, true, "put", "*", "PUT", [])
> +preflightTest(false, true, "get", "*", "GET", ["X-Test", "1"])
> +preflightTest(false, true, "*", "*", "GET", ["X-Test", "1"])
> +preflightTest(true, true, "*", "*", "*", ["*", "1"])

These test are good for ensuring we do not cause the ASSERT(m_timeOrigin) to fail. Out of curiosity, is there any way we could test the effects of m_timeOrigin being 0 other than via an assertion failure?
Comment 15 youenn fablet 2018-02-07 11:07:41 PST
(In reply to Daniel Bates from comment #14)
> Comment on attachment 333289 [details]
> Moving test to WK2 only
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=333289&action=review
> 
> > LayoutTests/ChangeLog:12
> > +        * http/wpt/service-workers/cors-preflight-star.any.js: Added.
> 
> It would also be good to add tests for async and sync CORS preflight
> requests initiated from a Web Worker. We do not need to do this in this
> patch. It can be done in a subsequent bug/patch.

WPT has this for web workers but not for service workers which behave differently as they are related to a specific kind of Documents.

> > LayoutTests/http/wpt/service-workers/cors-preflight-star.any.js:44
> > +preflightTest(true, false, "get", "x-test", "GET", ["X-Test", "1"])
> > +preflightTest(true, false, "*", "x-test", "SUPER", ["X-Test", "1"])
> > +preflightTest(true, false, "*", "*", "OK", ["X-Test", "1"])
> > +preflightTest(false, true, "*", "*", "OK", ["X-Test", "1"])
> > +preflightTest(false, true, "*", "", "PUT", [])
> > +preflightTest(true, true, "PUT", "*", "PUT", [])
> > +preflightTest(false, true, "put", "*", "PUT", [])
> > +preflightTest(false, true, "get", "*", "GET", ["X-Test", "1"])
> > +preflightTest(false, true, "*", "*", "GET", ["X-Test", "1"])
> > +preflightTest(true, true, "*", "*", "*", ["*", "1"])
> 
> These test are good for ensuring we do not cause the ASSERT(m_timeOrigin) to
> fail. Out of curiosity, is there any way we could test the effects of
> m_timeOrigin being 0 other than via an assertion failure?

I am not familiar with this code so am not sure of the expected effects here.
Comment 16 WebKit Commit Bot 2018-02-07 13:55:27 PST
Comment on attachment 333289 [details]
Moving test to WK2 only

Clearing flags on attachment: 333289

Committed r228241: <https://trac.webkit.org/changeset/228241>
Comment 17 WebKit Commit Bot 2018-02-07 13:55:29 PST
All reviewed patches have been landed.  Closing bug.