mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
b68bc791d0
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 |
||
---|---|---|
.. | ||
loader | ||
remoteworkers | ||
sharedworkers | ||
test | ||
ChromeWorker.cpp | ||
ChromeWorker.h | ||
ChromeWorkerScope.cpp | ||
ChromeWorkerScope.h | ||
EventWithOptionsRunnable.cpp | ||
EventWithOptionsRunnable.h | ||
JSExecutionManager.cpp | ||
JSExecutionManager.h | ||
JSSettings.h | ||
MessageEventRunnable.cpp | ||
MessageEventRunnable.h | ||
moz.build | ||
nsIWorkerChannelInfo.idl | ||
nsIWorkerDebugger.idl | ||
nsIWorkerDebuggerManager.idl | ||
Queue.h | ||
RegisterBindings.cpp | ||
RuntimeService.cpp | ||
RuntimeService.h | ||
ScriptLoader.cpp | ||
ScriptLoader.h | ||
Worker.cpp | ||
Worker.h | ||
WorkerChannelInfo.cpp | ||
WorkerChannelInfo.h | ||
WorkerCommon.h | ||
WorkerCSPEventListener.cpp | ||
WorkerCSPEventListener.h | ||
WorkerDebugger.cpp | ||
WorkerDebugger.h | ||
WorkerDebuggerManager.cpp | ||
WorkerDebuggerManager.h | ||
WorkerDocumentListener.cpp | ||
WorkerDocumentListener.h | ||
WorkerError.cpp | ||
WorkerError.h | ||
WorkerEventTarget.cpp | ||
WorkerEventTarget.h | ||
WorkerIPCUtils.h | ||
WorkerLoadInfo.cpp | ||
WorkerLoadInfo.h | ||
WorkerLocation.cpp | ||
WorkerLocation.h | ||
WorkerNavigator.cpp | ||
WorkerNavigator.h | ||
WorkerPrivate.cpp | ||
WorkerPrivate.h | ||
WorkerRef.cpp | ||
WorkerRef.h | ||
WorkerRunnable.cpp | ||
WorkerRunnable.h | ||
WorkerScope.cpp | ||
WorkerScope.h | ||
WorkerStatus.h | ||
WorkerTestUtils.cpp | ||
WorkerTestUtils.h | ||
WorkerThread.cpp | ||
WorkerThread.h |