Bug 265263

Summary: Worker IDL Interface is not exposed to 'SharedWorker'
Product: WebKit Reporter: Ahmad Saleem <ahmad.saleem792>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: cdumez, Hironori.Fujii, mike, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Ahmad Saleem 2023-11-22 12:23:50 PST
Hi Team,

While looking into Workers.idl file in WebKit, I noticed that it is not exposed to 'SharedWorker' as per Web standard.

Web-Spec: https://html.spec.whatwg.org/multipage/workers.html#dedicated-workers-and-the-worker-interface

WebKit Source: https://searchfox.org/wubkat/rev/225be872c8ca8c801d73c28d87205f6bef773846/Source/WebCore/workers/Worker.idl#29

It might be leading to following WPT test failure (didn't test or confirmed).

WPT Test Case: https://wpt.fyi/results/workers/semantics/interface-objects/003.any.sharedworker.html?label=master&label=experimental&aligned=&q=safari%3Afail

Or if it is not progressing above, it might be failing few others.

I just wanted to raise so we can fix it.

Thanks!
Comment 2 Alexey Proskuryakov 2023-11-25 13:37:08 PST
Does it work when exposed? We do support nested workers, but I'm not sure if it automatically means that workers inside shared workers are supported.
Comment 3 Ahmad Saleem 2023-11-25 13:39:40 PST
(In reply to Alexey Proskuryakov from comment #2)
> Does it work when exposed? We do support nested workers, but I'm not sure if
> it automatically means that workers inside shared workers are supported.

Yes, it compiles and progress above mentioned two WPT test cases.
Comment 4 Chris Dumez 2023-11-25 19:58:48 PST
(In reply to Ahmad Saleem from comment #3)
> (In reply to Alexey Proskuryakov from comment #2)
> > Does it work when exposed? We do support nested workers, but I'm not sure if
> > it automatically means that workers inside shared workers are supported.
> 
> Yes, it compiles and progress above mentioned two WPT test cases.

It should in theory just work if we expose it. Please upload a PR if you can.
Comment 5 Ahmad Saleem 2023-11-26 05:01:04 PST
PR Attempt (Draft) - https://github.com/WebKit/WebKit/pull/20902
Comment 6 Radar WebKit Bug Importer 2023-11-29 12:24:14 PST
<rdar://problem/118945089>
Comment 7 Ahmad Saleem 2023-11-30 17:55:56 PST
This change leads to consistent crash in 'debug' build on following test:

imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-sharedworker-success.https.html

Crash log: https://ews-build.s3-us-west-2.amazonaws.com/macOS-AppleSilicon-Sonoma-Debug-WK2-Tests-EWS/e035bd8d-3120/imported/w3c/web-platform-tests/html/infrastructure/safe-passing-of-structured-data/shared-array-buffers/nested-sharedworker-success.https-crash-log.txt

No crash log found for WebKitTestRunner:20478.

stdout:

stderr:
ASSERTION FAILED: RunLoop::isMain()
/Volumes/Data/worker/macOS-AppleSilicon-Sonoma-Debug-Build-EWS/build/Source/WebKit/WebProcess/WebProcess.cpp(1183) : NetworkProcessConnection &WebKit::WebProcess::ensureNetworkProcessConnection()
1   0x137dfd248 WTFCrash
2   0x11e725cd0 std::__1::span<unsigned char const, 18446744073709551615ul>::span[abi:v160006]<unsigned char const*>(unsigned char const*, unsigned long)
3   0x120904afc WebKit::WebProcess::ensureNetworkProcessConnection()
4   0x120d24b70 WebKit::WebLoaderStrategy::addOnlineStateChangeListener(WTF::Function<void (bool)>&&)
5   0x285c461a8 WebCore::Worker::Worker(WebCore::ScriptExecutionContext&, JSC::RuntimeFlags, WebCore::WorkerOptions&&)
6   0x285c463b8 WebCore::Worker::Worker(WebCore::ScriptExecutionContext&, JSC::RuntimeFlags, WebCore::WorkerOptions&&)
7   0x285c46434 WebCore::Worker::create(WebCore::ScriptExecutionContext&, JSC::RuntimeFlags, WTF::String const&, WebCore::WorkerOptions&&)
8   0x281fa87cc WebCore::JSDOMConstructor<WebCore::JSWorker>::construct(JSC::JSGlobalObject*, JSC::CallFrame*)
9   0x2a4e54270 8   ???                                 0x00000002a4e54270 0x0 + 11356422768
10  0x1384f37c4 llint_entry
11  0x1384f4838 llint_entry
12  0x1384f32ac llint_entry
13  0x1384f32ac llint_entry
14  0x1384f37c4 llint_entry
15  0x1384f32ac llint_entry
16  0x1384ccfb4 vmEntryToJavaScript
17  0x13965b5fc JSC::Interpreter::executeCallImpl(JSC::VM&, JSC::JSObject*, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
18  0x13965b6ec JSC::Interpreter::executeCall(JSC::JSObject*, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
19  0x1398ead38 JSC::call(JSC::JSGlobalObject*, JSC::JSValue, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
20  0x1398eaff8 JSC::profiledCall(JSC::JSGlobalObject*, JSC::ProfilingReason, JSC::JSValue, JSC::CallData const&, JSC::JSValue, JSC::ArgList const&)
21  0x139b4e278 JSC::runJSMicrotask(JSC::JSGlobalObject*, WTF::ObjectIdentifierGeneric<JSC::MicrotaskIdentifierType, WTF::ObjectIdentifierThreadSafeAccessTraits>, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue, JSC::JSValue)
22  0x139b4e424 JSC::JSMicrotask::run(JSC::JSGlobalObject*)
23  0x283150a74 WebCore::JSExecState::runTask(JSC::JSGlobalObject*, JSC::Microtask&)
24  0x28328ef28 WebCore::JSMicrotaskCallback::call()
25  0x28328eea8 WebCore::JSWorkerGlobalScopeBase::queueMicrotaskToEventLoop(JSC::JSGlobalObject&, WTF::Ref<JSC::Microtask, WTF::RawPtrTraits<JSC::Microtask>>&&)::$_3::operator()()
26  0x28328ee04 WTF::Detail::CallableWrapper<WebCore::JSWorkerGlobalScopeBase::queueMicrotaskToEventLoop(JSC::JSGlobalObject&, WTF::Ref<JSC::Microtask, WTF::RawPtrTraits<JSC::Microtask>>&&)::$_3, void>::call()
27  0x2800260e8 WTF::Function<void ()>::operator()() const
28  0x283ab0aec WebCore::EventLoopFunctionDispatchTask::execute()
29  0x283b155c0 WebCore::MicrotaskQueue::performMicrotaskCheckpoint()
30  0x283aa77a4 WebCore::EventLoop::performMicrotaskCheckpoint()
31  0x283aa9f40 WebCore::EventLoopTaskGroup::performMicrotaskCheckpoint()

> I think I should close my PR or change to draft till figure out, what could be the reason of above 'assertion'.
Comment 8 Ahmad Saleem 2023-11-30 17:58:09 PST
Although if I look into 'WebProcess.cpp', we only have this as 'RELEASE_ASSERT' except here:

https://searchfox.org/wubkat/rev/1531d41a4ef64103835343c7ca448db7defee9de/Source/WebKit/WebProcess/WebProcess.cpp#2139

which is behind:

#if HAVE(DISPLAY_LINK)