Bug 1110928, ensure zone GC collects the zone from which canvas context is originated, r=mccr8
--- a/dom/canvas/CanvasRenderingContext2D.cpp
+++ b/dom/canvas/CanvasRenderingContext2D.cpp
@@ -66,16 +66,17 @@
#include "nsStyleUtil.h"
#include "CanvasImageCache.h"
#include <algorithm>
#include "jsapi.h"
#include "jsfriendapi.h"
#include "js/Conversions.h"
+#include "js/HeapAPI.h"
#include "mozilla/Alignment.h"
#include "mozilla/Assertions.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/DebugOnly.h"
#include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/ImageBitmap.h"
#include "mozilla/dom/ImageData.h"
@@ -114,16 +115,17 @@
#include "SVGContentUtils.h"
#include "nsIScreenManager.h"
#include "nsFilterInstance.h"
#include "nsSVGLength2.h"
#include "nsDeviceContext.h"
#include "nsFontMetrics.h"
#include "Units.h"
#include "CanvasUtils.h"
+#include "mozilla/CycleCollectedJSContext.h"
#include "mozilla/StyleSetHandle.h"
#include "mozilla/StyleSetHandleInlines.h"
#include "mozilla/layers/CanvasClient.h"
#undef free // apparently defined by some windows header, clashing with a free()
// method in SkTypes.h
#include "SkiaGLGlue.h"
#ifdef USE_SKIA
@@ -1737,16 +1739,22 @@ CanvasRenderingContext2D::RegisterAlloca
RegisterStrongMemoryReporter(new Canvas2dPixelsReporter());
}
gCanvasAzureMemoryUsed += mWidth * mHeight * 4;
JSContext* context = nsContentUtils::GetCurrentJSContext();
if (context) {
JS_updateMallocCounter(context, mWidth * mHeight * 4);
}
+
+ JSObject* wrapper = GetWrapperPreserveColor();
+ if (wrapper) {
+ CycleCollectedJSContext::Get()->
+ AddZoneWaitingForGC(JS::GetObjectZone(wrapper));
+ }
}
static already_AddRefed<LayerManager>
LayerManagerFromCanvasElement(nsINode* aCanvasElement)
{
if (!aCanvasElement || !aCanvasElement->OwnerDoc()) {
return nullptr;
}