Commit 73d506b2 authored by Eden Chuang's avatar Eden Chuang
Browse files

Bug 1850843 - Keeping doing nothing for NotificationWorkerRunnable when the...

Bug 1850843 - Keeping doing nothing for NotificationWorkerRunnable when the worker is dying. r=dom-worker-reviewers,smaug a=pascalc

Differential Revision: https://phabricator.services.mozilla.com/D187433
parent 7af79efe
Loading
Loading
Loading
Loading
+20 −1
Original line number Diff line number Diff line
@@ -321,7 +321,14 @@ class NotificationWorkerRunnable : public MainThreadWorkerRunnable {
  bool WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override {
    aWorkerPrivate->AssertIsOnWorkerThread();
    aWorkerPrivate->ModifyBusyCountFromWorker(true);
    // 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;
  }

@@ -360,6 +367,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();
  }