bug 1328964 don't try to cycle collect after worklet cycle collector has been shut down r?baku draft
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 06 Mar 2018 19:23:07 +1300
changeset 780865 5867b4d64462c598b657634d9ca9fb6893977c42
parent 780864 c784a58cb8a6d904f5f8f350c62e50899dd4ff83
child 780866 58e4aeef280ca23466367c713f3669a74e468f6e
push id106145
push userktomlinson@mozilla.com
push dateThu, 12 Apr 2018 05:09:40 +0000
reviewersbaku
bugs1328964
milestone61.0a1
bug 1328964 don't try to cycle collect after worklet cycle collector has been shut down r?baku MozReview-Commit-ID: 5BTcAOZwvIU
dom/worklet/WorkletThread.cpp
--- a/dom/worklet/WorkletThread.cpp
+++ b/dom/worklet/WorkletThread.cpp
@@ -132,17 +132,22 @@ public:
   {
     MOZ_ASSERT(!aContinuation);
     nsCycleCollector_doDeferredDeletion();
   }
 
   virtual void
   CustomGCCallback(JSGCStatus aStatus) override
   {
-    if (aStatus == JSGC_END) {
+    // nsCycleCollector_collect() requires a cycle collector but
+    // ~WorkletJSContext calls nsCycleCollector_shutdown() and the base class
+    // destructor will trigger a final GC.  The nsCycleCollector_collect()
+    // call can be skipped in this GC as ~CycleCollectedJSContext removes the
+    // context from |this|.
+    if (aStatus == JSGC_END && !Contexts().isEmpty()) {
       nsCycleCollector_collect(nullptr);
     }
   }
 };
 
 class WorkletJSContext final : public CycleCollectedJSContext
 {
 public: