bug 1328964 don't try to cycle collect after worklet cycle collector has been shut down r?baku
MozReview-Commit-ID: 5BTcAOZwvIU
--- 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: