forked from mirrors/gecko-dev
Bug 1850843 - Keeping doing nothing for NotificationWorkerRunnable when the worker is dying. r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D187433
This commit is contained in:
parent
34cef822f7
commit
ccc3244a24
1 changed files with 21 additions and 5 deletions
|
|
@ -320,7 +320,14 @@ class NotificationWorkerRunnable : public MainThreadWorkerRunnable {
|
|||
bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override {
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(true);
|
||||
WorkerRunInternal(aWorkerPrivate);
|
||||
// WorkerScope might start dying at the moment. And WorkerRunInternal()
|
||||
// should not be executed once WorkerScope is dying, since
|
||||
// WorkerRunInternal() might access resources which already been freed
|
||||
// during WorkerRef::Notify().
|
||||
if (aWorkerPrivate->GlobalScope() &&
|
||||
!aWorkerPrivate->GlobalScope()->IsDying()) {
|
||||
WorkerRunInternal(aWorkerPrivate);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -347,10 +354,7 @@ class NotificationEventWorkerRunnable final
|
|||
mEventName(aEventName) {}
|
||||
|
||||
void WorkerRunInternal(WorkerPrivate* aWorkerPrivate) override {
|
||||
if (aWorkerPrivate->GlobalScope() &&
|
||||
!aWorkerPrivate->GlobalScope()->IsDying()) {
|
||||
mNotification->DispatchTrustedEvent(mEventName);
|
||||
}
|
||||
mNotification->DispatchTrustedEvent(mEventName);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -362,6 +366,18 @@ class ReleaseNotificationRunnable final : public NotificationWorkerRunnable {
|
|||
: NotificationWorkerRunnable(aNotification->mWorkerPrivate),
|
||||
mNotification(aNotification) {}
|
||||
|
||||
bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override {
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
aWorkerPrivate->ModifyBusyCountFromWorker(true);
|
||||
// ReleaseNotificationRunnable is only used in StrongWorkerRef's shutdown
|
||||
// callback. At the moment, it is supposed to executing
|
||||
// mNotification->ReleaseObject() safely even though the corresponding
|
||||
// WorkerScope::IsDying() is true. It is unlike other
|
||||
// NotificationWorkerRunnable.
|
||||
WorkerRunInternal(aWorkerPrivate);
|
||||
return true;
|
||||
}
|
||||
|
||||
void WorkerRunInternal(WorkerPrivate* aWorkerPrivate) override {
|
||||
mNotification->ReleaseObject();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue