gecko-dev/dom/workers
Eden Chuang b68bc791d0 Bug 1892644 - Handling WorkerThreadRunnable::Run() after Worker is "Dead". r=asuth
In bug 1769913, we remove the WorkerThreadRunnable's raw pointer to the corresponding WorkerPrivate and expect the corresponding WorkerPrivate to be obtained by GetCurrentThreadWorkerPrivate() when WorkerThreadRunnable::Run executing.

In general, the assumption is correct. However, it could be violated in the following two situations.

1. WorkerJSContext initialization fails.
2. WorkerThreadRunnable dispatching after CycleCollector shutdown.
In both cases, there is no corresponding WorkerJSContext to get its mWorkerPrivate by GetCurrentThreadWorkerPrivate(), which causes WorkerThreadRunnable to have no WorkerPrivate for executing.

For case 1, the WorkerThreadRunnables are all from WorkerPrivate::mPreStartRunnables. These runnables need a WorkerPrivate to execute WorkerRun(). To cleanup the resources through WorkerRun() if Worker initialization fails or shutdown before DoRunLoop() starts, WorkerThreadRunnable saves a CheckedUnsafePtr<WorkerPrivate> when the runnable is dispacthed to WorkerPrivate::mPreStartRunnables.

For case 2, the solution could be much easier since the WorkerThreadRunnable is not really a WorkerThreadRunnable. Because the Worker is in the "Dead" state, the WorkerThreadRunnable could not be dispatched normally, which means by WorkerThreadRunnable::Dispatch(WorkerPrivate). So it must be from NS_DispatchToCurrentThread(), WorkerThread::Dispatch(), or other ways which treat WorkerThread as nsIThread/nsISerialEventTarget, where the runnable is wrapped as a WorkerThreadRunnable and call nsThread::Dispatch() directly. In this case, the runnable does not need to be WorkerThreadRunnable, so we should be able to call the runnable's Run() directly.

Differential Revision: https://phabricator.services.mozilla.com/D208259
2024-05-02 06:37:51 +00:00
..
loader Bug 1887719 - More consistently use UTF8String/nsCString for URLs. r=necko-reviewers,webidl,anti-tracking-reviewers,places-reviewers,jari,kershaw,janv,smaug,hsivonen 2024-04-04 11:49:57 +00:00
remoteworkers Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
sharedworkers
test Bug 1887081 - Relax test_interfaces check for JSTag. r=jandem,webidl,emilio 2024-04-25 12:53:42 +00:00
ChromeWorker.cpp
ChromeWorker.h
ChromeWorkerScope.cpp
ChromeWorkerScope.h
EventWithOptionsRunnable.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
EventWithOptionsRunnable.h
JSExecutionManager.cpp
JSExecutionManager.h
JSSettings.h
MessageEventRunnable.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
MessageEventRunnable.h Bug 1769913 - P2 WorkerParentThreadRunnable for the runnables dispatched to worker's parent thread. r=dom-worker-reviewers,asuth 2024-04-19 09:41:57 +00:00
moz.build
nsIWorkerChannelInfo.idl
nsIWorkerDebugger.idl Bug 1881863 - Part 1: Standardize on boolean over bool in xpidl, r=xpcom-reviewers,necko-reviewers,valentin,extension-reviewers,application-update-reviewers,media-playback-reviewers,credential-management-reviewers,search-reviewers,anti-tracking-reviewers,places-reviewers,nalexander,emilio,zombie,sgalich,karlt,lina,Standard8 2024-04-04 18:45:21 +00:00
nsIWorkerDebuggerManager.idl
Queue.h
RegisterBindings.cpp
RuntimeService.cpp Bug 1891277 - correctly match JS GC memory pref names r=arai 2024-04-22 23:55:57 +00:00
RuntimeService.h
ScriptLoader.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
ScriptLoader.h
Worker.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
Worker.h Bug 1858809 - Enforce Worker::PostEventWithOptions invariants. r=bwc,dom-worker-reviewers,smaug 2024-04-10 01:38:36 +00:00
WorkerChannelInfo.cpp
WorkerChannelInfo.h
WorkerCommon.h
WorkerCSPEventListener.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
WorkerCSPEventListener.h
WorkerDebugger.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
WorkerDebugger.h
WorkerDebuggerManager.cpp
WorkerDebuggerManager.h
WorkerDocumentListener.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
WorkerDocumentListener.h
WorkerError.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
WorkerError.h
WorkerEventTarget.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
WorkerEventTarget.h
WorkerIPCUtils.h Bug 1640839 - Add IPC serializer for WebIDL enums. r=mccr8,jgilbert,media-playback-reviewers,dom-storage-reviewers,janv,padenot 2024-03-02 07:50:22 +00:00
WorkerLoadInfo.cpp Bug 1876575, part 2 - Make Workers use ancestor chain for third-partiness check - r=anti-tracking-reviewers,timhuang,asuth 2024-04-02 18:53:26 +00:00
WorkerLoadInfo.h Bug 1876575, part 2 - Make Workers use ancestor chain for third-partiness check - r=anti-tracking-reviewers,timhuang,asuth 2024-04-02 18:53:26 +00:00
WorkerLocation.cpp
WorkerLocation.h
WorkerNavigator.cpp Bug 1848406 - Keep track of storage access in web workers. r=bvandersloot,asuth 2024-04-17 20:29:05 +00:00
WorkerNavigator.h
WorkerPrivate.cpp Bug 1892644 - Handling WorkerThreadRunnable::Run() after Worker is "Dead". r=asuth 2024-05-02 06:37:51 +00:00
WorkerPrivate.h Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
WorkerRef.cpp Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
WorkerRef.h Bug 1769913 - P3 Remove WorkerRunnable::mWorkerPrivate. r=dom-worker-reviewers,asuth 2024-04-19 09:41:58 +00:00
WorkerRunnable.cpp Bug 1892644 - Handling WorkerThreadRunnable::Run() after Worker is "Dead". r=asuth 2024-05-02 06:37:51 +00:00
WorkerRunnable.h Bug 1892644 - Handling WorkerThreadRunnable::Run() after Worker is "Dead". r=asuth 2024-05-02 06:37:51 +00:00
WorkerScope.cpp Bug 1848406 - Keep track of storage access in web workers. r=bvandersloot,asuth 2024-04-17 20:29:05 +00:00
WorkerScope.h Bug 1887719 - More consistently use UTF8String/nsCString for URLs. r=necko-reviewers,webidl,anti-tracking-reviewers,places-reviewers,jari,kershaw,janv,smaug,hsivonen 2024-04-04 11:49:57 +00:00
WorkerStatus.h
WorkerTestUtils.cpp
WorkerTestUtils.h
WorkerThread.cpp Bug 1892644 - Handling WorkerThreadRunnable::Run() after Worker is "Dead". r=asuth 2024-05-02 06:37:51 +00:00
WorkerThread.h Bug 1769913 - P1 Make WorkerRunnable to be a base class for runnables on Worker thread and Worker's parent thread. r=dom-worker-reviewers,asuth 2024-04-19 09:41:57 +00:00