Pending->Canceling->Killing (WorkerNeverRan)
Need to clear WorkerPrivate::mPreStartRunnables
Could we call WorkerRunnable::WorkerRun() to release resource? There could be no WorkerGlobalScope...
Pending->Running->Closing->Canceling->Killing(WorkerRan)
Pending->Running->Canceling->Killing(WorkerRan)
When entering “Closing”
1. Keeping receives normal WorkerRunnables
2. Making ParentStatus as Closing
3. Cancel all timeout
4. Don’t clear the main event queue anymore. But we still wait for all SyncLoops be completed.
5. Call WorkerGlobalScope::NoteTerminating() and nsIGlobalObject::DisconnectEventTargetObjects().
6. Switching to “Canceling” by asking parent thread to call WorkerPrivate::Cancel()
When entering “Canceling”
1. Call WorkerGlobalScope::NoteTerminating()
2. Notify StrongWorkerRefs, worker is in “Canceling”, send and complete the corresponding shutdown work right now.
3. Executing all runnables until no normal WorkerRunnables in queue and no WorkerRefs, SyncLoops and children workers
4. Stop receiving normal WorkerRunnables and DisconnectEventTargetObjects of WorkerScope.
4. Entering “Killing”
When entering “Killing”
1. We would not notify WorkerRefs anymore. Logically all WorkerRefs should be released in “Canceling”
2. Executing all remaining ControlRunnables
3. Release corresponding resources of Worker on worker thread.
Depends on D173850
Differential Revision: https://phabricator.services.mozilla.com/D177511
The boolean is used to initialize WorkerGlobalScopeBase::mShouldResistFingerprinting which is similar
in its behavior to the precomputed mShouldResistFingerprinting in Document.
Differential Revision: https://phabricator.services.mozilla.com/D178660
It can fail when canceling the worker (though I couldn't reproduce the
crash locally). Some things were already accounting for it.
Rename some things for consistency.
Differential Revision: https://phabricator.services.mozilla.com/D175126
The default value for the target is Unknown, so all callsites
keep working.
We also add a Target value used for Document precomputation. This
value is enabled in RFP Lite mode, and allows us to precompute
ShouldRFP and cache it for faster computations later. (The later
computations will still check the Target, but won't need to do the
other expensive checks.)
Differential Revision: https://phabricator.services.mozilla.com/D170891
The default value for the target is Unknown, so all callsites
keep working.
We also add a Target value used for Document precomputation. This
value is enabled in RFP Lite mode, and allows us to precompute
ShouldRFP and cache it for faster computations later. (The later
computations will still check the Target, but won't need to do the
other expensive checks.)
Differential Revision: https://phabricator.services.mozilla.com/D170891
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).
Depends on D147324
Differential Revision: https://phabricator.services.mozilla.com/D147326
These methods only existed because nsIGlobalObject::PrincipalOrNull was not
available off-main-thread, so can now be removed.
Depends on D165198
Differential Revision: https://phabricator.services.mozilla.com/D165199
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).
Depends on D147324
Differential Revision: https://phabricator.services.mozilla.com/D147326
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).
Depends on D147324
Differential Revision: https://phabricator.services.mozilla.com/D147326
In some unusual cases, WorkerGlobalScope could live longer than WorkerPrivate since some other objects hold a reference on WorkerGlobalScope. We try to use CC/GC to release WorkerGlobalScope and force disconnect them from the WorkerPrivate before releasing WorkerPrivate. https://searchfox.org/mozilla-central/rev/83b86005c6913c2062419efb8aabdf2e683aa47f/dom/workers/RuntimeService.cpp#2068-2109
The previous implementation focused on nulling the WorkerGlobalScopeBase::mWorkerPrivate. However, it is not enough since WorkerGlobalScope's member could possibly hold a CheckedUnsafePtr<WorkerPrivate>, i.e. WorkerGlobalScope::mPerformance.
In this patch, we focus on breaking these connections.
Differential Revision: https://phabricator.services.mozilla.com/D162575
This centralizes the logic in one place.
In order to do this, we will need to check the principal
off-main thread. (Well, we need to know if it's System
Principal.) Worker and Worklet need special ways to do
this, so create a virtual method for it and let them
override it. This is analogous to the ShouldRFP method
on GlobalObject.
Differential Revision: https://phabricator.services.mozilla.com/D157564
This does not remove mShouldResistFingerprinting from
WorkerPrivate->mLoadInfo. This is because in between
mLoadInfo getting initialized (including where shouldRFP gets
set) and when the worker's global scope is constructed, we
need to keep track of whether we shouldRFP or not. We could
make this single bool an outparam of GetLoadInfo to later
pass to GetOrCreateGlobalScope, but that seems noisy.
Differential Revision: https://phabricator.services.mozilla.com/D157563
This centralizes the logic in one place.
In order to do this, we will need to check the principal
off-main thread. (Well, we need to know if it's System
Principal.) Worker and Worklet need special ways to do
this, so create a virtual method for it and let them
override it. This is analogous to the ShouldRFP method
on GlobalObject.
Differential Revision: https://phabricator.services.mozilla.com/D157564
This does not remove mShouldResistFingerprinting from
WorkerPrivate->mLoadInfo. This is because in between
mLoadInfo getting initialized (including where shouldRFP gets
set) and when the worker's global scope is constructed, we
need to keep track of whether we shouldRFP or not. We could
make this single bool an outparam of GetLoadInfo to later
pass to GetOrCreateGlobalScope, but that seems noisy.
Differential Revision: https://phabricator.services.mozilla.com/D157563
This centralizes the logic in one place.
In order to do this, we will need to check the principal
off-main thread. (Well, we need to know if it's System
Principal.) Worker and Worklet need special ways to do
this, so create a virtual method for it and let them
override it. This is analogous to the ShouldRFP method
on GlobalObject.
Differential Revision: https://phabricator.services.mozilla.com/D157564
This does not remove mShouldResistFingerprinting from
WorkerPrivate->mLoadInfo. This is because in between
mLoadInfo getting initialized (including where shouldRFP gets
set) and when the worker's global scope is constructed, we
need to keep track of whether we shouldRFP or not. We could
make this single bool an outparam of GetLoadInfo to later
pass to GetOrCreateGlobalScope, but that seems noisy.
Differential Revision: https://phabricator.services.mozilla.com/D157563
The patch D138442 wanted to guard us against the late use of global scope's reference to WorkerPrivate by nulling it out. The rational behind this was to enforce the invariant, that a `WorkerGlobalScopeBase` derived object should never outlive its `WorkerPrivate`. It turned out that during further worker cleanup at the end of `WorkerThreadPrimaryRunnable::Run` we still process pending events (while the `WorkerPrivate` is still alive) that might want to access the global scope and in particular its `mWorkerPrivate` legitimately.
The purpose of this patch is to:
- Postpone the unrooting until after the last expected event processing.
- Enforce the invariant "Lifetime(global scope) < Lifetime(WorkerPrivate)" by asserting that the global scope went away after GC/CC.
- Do the nulling of global scope's `mWorkerPrivate` only if needed after the CC shut down.
- Do the nulling of debugger global scope's `mWorkerPrivate` while unrooting as it does not support weak references.
Differential Revision: https://phabricator.services.mozilla.com/D141507
This will be used from the DevTools webconsole to clear events when
the user hits the clear button in the UI.
A test for the console is added in the next patch of the queue.
Differential Revision: https://phabricator.services.mozilla.com/D138314
This will be used from the DevTools webconsole to clear events when
the user hits the clear button in the UI.
A test for the console is added in the next patch of the queue.
Differential Revision: https://phabricator.services.mozilla.com/D138314