Changeset 284226 in webkit
- Timestamp:
- Oct 14, 2021, 7:02:14 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r284225 r284226 1 2021-10-14 Chris Dumez <cdumez@apple.com> 2 3 Service workers running on the main thread should use the main VM 4 https://bugs.webkit.org/show_bug.cgi?id=231753 5 6 Reviewed by Geoffrey Garen. 7 8 ervice workers running on the main thread should use the main VM. This makes life easier for injected 9 bundle clients and there is no strong reason to use a separate VM since VMs are mainly used for thread 10 safety / isolation. 11 12 No new tests, extended existing API test. 13 14 * workers/WorkerOrWorkletGlobalScope.cpp: 15 (WebCore::WorkerOrWorkletGlobalScope::isContextThread const): 16 WorkerOrWorkletThread::thread() returns null when the service worker is running on the main thread. 17 Update WorkerOrWorkletGlobalScope::isContextThread() to deal with that and properly treats the 18 main thread as the context thread in this case. 19 20 * workers/WorkerOrWorkletScriptController.cpp: 21 (WebCore::WorkerOrWorkletScriptController::WorkerOrWorkletScriptController): 22 (WebCore::WorkerOrWorkletScriptController::scheduleExecutionTermination): 23 1 24 2021-10-14 Aditya Keerthi <akeerthi@apple.com> 2 25 -
trunk/Source/WebCore/workers/WorkerGlobalScope.cpp
r284093 r284226 32 32 #include "CSSValueList.h" 33 33 #include "CSSValuePool.h" 34 #include "CommonVM.h" 34 35 #include "ContentSecurityPolicy.h" 35 36 #include "Crypto.h" … … 80 81 81 82 WorkerGlobalScope::WorkerGlobalScope(WorkerThreadType type, const WorkerParameters& params, Ref<SecurityOrigin>&& origin, WorkerThread& thread, Ref<SecurityOrigin>&& topOrigin, IDBClient::IDBConnectionProxy* connectionProxy, SocketProvider* socketProvider) 82 : WorkerOrWorkletGlobalScope(type, JSC::VM::create(), &thread)83 : WorkerOrWorkletGlobalScope(type, isMainThread() ? Ref { commonVM() } : JSC::VM::create(), &thread) 83 84 , m_url(params.scriptURL) 84 85 , m_identifier(params.identifier) -
trunk/Source/WebCore/workers/WorkerOrWorkletGlobalScope.cpp
r273203 r284226 112 112 { 113 113 auto* thread = workerOrWorkletThread(); 114 return thread ? thread->thread() == &Thread::current() : isMainThread();114 return thread && thread->thread() ? thread->thread() == &Thread::current() : isMainThread(); 115 115 } 116 116 -
trunk/Source/WebCore/workers/WorkerOrWorkletScriptController.cpp
r284093 r284226 28 28 #include "WorkerOrWorkletScriptController.h" 29 29 30 #include "CommonVM.h" 30 31 #include "DedicatedWorkerGlobalScope.h" 31 32 #include "EventLoop.h" … … 69 70 , m_globalScopeWrapper(*m_vm) 70 71 { 71 m_vm->heap.acquireAccess(); // It's not clear that we have good discipline for heap access, so turn it on permanently. 72 { 73 JSLockHolder lock(m_vm.get()); 74 m_vm->ensureTerminationException(); 75 } 76 77 JSVMClientData::initNormalWorld(m_vm.get(), type); 72 if (!isMainThread() || m_vm != &commonVM()) { 73 m_vm->heap.acquireAccess(); // It's not clear that we have good discipline for heap access, so turn it on permanently. 74 { 75 JSLockHolder lock(m_vm.get()); 76 m_vm->ensureTerminationException(); 77 } 78 79 JSVMClientData::initNormalWorld(m_vm.get(), type); 80 } 78 81 } 79 82 … … 130 133 m_isTerminatingExecution = true; 131 134 } 132 m_vm->notifyNeedTermination(); 135 if (m_vm != &commonVM()) 136 m_vm->notifyNeedTermination(); 133 137 } 134 138 -
trunk/Tools/ChangeLog
r284223 r284226 1 2021-10-14 Chris Dumez <cdumez@apple.com> 2 3 Service workers running on the main thread should use the main VM 4 https://bugs.webkit.org/show_bug.cgi?id=231753 5 6 Reviewed by Geoffrey Garen. 7 8 Extend API test coverage. 9 10 * TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerPagePlugIn.mm: 11 (-[ServiceWorkerPagePlugIn webProcessPlugInBrowserContextController:serviceWorkerGlobalObjectIsAvailableForFrame:inScriptWorld:]): 12 1 13 2021-10-14 Wenson Hsieh <wenson_hsieh@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerPagePlugIn.mm
r283522 r284226 27 27 28 28 #import "ServiceWorkerPageProtocol.h" 29 #import <JavaScriptCore/JSContextRef.h> 29 30 #import <WebKit/WKBundlePage.h> 30 31 #import <WebKit/WKWebProcessPlugIn.h> … … 33 34 #import <WebKit/WKWebProcessPlugInFramePrivate.h> 34 35 #import <WebKit/WKWebProcessPlugInLoadDelegate.h> 36 #import <WebKit/WKWebProcessPlugInScriptWorld.h> 35 37 #import <WebKit/_WKRemoteObjectInterface.h> 36 38 #import <WebKit/_WKRemoteObjectRegistry.h> … … 48 50 RELEASE_ASSERT(RunLoop::isMain()); 49 51 RELEASE_ASSERT(frame); 50 JSContext * jsContext = [frame jsContextForServiceWorkerWorld:scriptWorld];51 RELEASE_ASSERT( jsContext);52 RELEASE_ASSERT([WKWebProcessPlugInFrame lookUpFrameFromJSContext: jsContext] == frame);52 JSContext *serviceWorkerJSContext = [frame jsContextForServiceWorkerWorld:scriptWorld]; 53 RELEASE_ASSERT(serviceWorkerJSContext); 54 RELEASE_ASSERT([WKWebProcessPlugInFrame lookUpFrameFromJSContext:serviceWorkerJSContext] == frame); 53 55 54 JSValue *globalIsServiceWorkerGlobalScope = [jsContext evaluateScript:@"self.__proto__ === ServiceWorkerGlobalScope.prototype"]; 56 JSContext *mainFrameJSContext = [frame jsContextForWorld:[WKWebProcessPlugInScriptWorld normalWorld]]; 57 RELEASE_ASSERT(mainFrameJSContext); 58 59 // The main frame and the service worker should have different JSContexts but should use the same VM. 60 RELEASE_ASSERT(mainFrameJSContext != serviceWorkerJSContext); 61 RELEASE_ASSERT(JSContextGetGroup(mainFrameJSContext.JSGlobalContextRef) == JSContextGetGroup(serviceWorkerJSContext.JSGlobalContextRef)); 62 63 RELEASE_ASSERT(scriptWorld == [WKWebProcessPlugInScriptWorld normalWorld]); 64 65 JSValue *globalIsServiceWorkerGlobalScope = [serviceWorkerJSContext evaluateScript:@"self.__proto__ === ServiceWorkerGlobalScope.prototype"]; 55 66 RELEASE_ASSERT(!!globalIsServiceWorkerGlobalScope); 56 67 RELEASE_ASSERT([globalIsServiceWorkerGlobalScope toBool]);
Note:
See TracChangeset
for help on using the changeset viewer.