[tbb-commits] [tor-browser/esr24] Bug 913805 - Hold a lock on the RasterImage in ScaleRequest so that the srcFrame doesn't go away if we need to discard images to free up memory. r=seth, a=abillings

mikeperry at torproject.org mikeperry at torproject.org
Fri Aug 29 05:26:42 UTC 2014


commit f3f9e0f211c9c179f9f240eafd4bfcbfc903c3d4
Author: George Wright <george at mozilla.com>
Date:   Fri Jun 6 14:26:21 2014 -0400

    Bug 913805 - Hold a lock on the RasterImage in ScaleRequest so that the srcFrame doesn't go away if we need to discard images to free up memory. r=seth, a=abillings
---
 image/src/RasterImage.cpp |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/image/src/RasterImage.cpp b/image/src/RasterImage.cpp
index 42d4232..fdd9654 100644
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -208,6 +208,9 @@ public:
 
     bool success = false;
     if (!dstLocked) {
+      // We need to hold a lock onto the RasterImage object itself so that
+      // it (and its associated imgFrames) aren't marked as discardable.
+      bool imgLocked = NS_SUCCEEDED(image->LockImage());
       bool srcLocked = NS_SUCCEEDED(srcFrame->LockImageData());
       dstLocked = NS_SUCCEEDED(dstFrame->LockImageData());
 
@@ -216,7 +219,7 @@ public:
       success = srcLocked && NS_SUCCEEDED(srcFrame->GetSurface(getter_AddRefs(srcASurf)));
       success = success && dstLocked && NS_SUCCEEDED(dstFrame->GetSurface(getter_AddRefs(dstASurf)));
 
-      success = success && srcLocked && dstLocked && srcASurf && dstASurf;
+      success = success && imgLocked && srcLocked && dstLocked && srcASurf && dstASurf;
 
       if (success) {
         srcSurface = srcASurf->GetAsImageSurface();
@@ -254,6 +257,7 @@ public:
     bool success = false;
     if (dstLocked) {
       success = NS_SUCCEEDED(dstFrame->UnlockImageData());
+      success = success && NS_SUCCEEDED(image->UnlockImage());
 
       dstLocked = false;
       srcData = nullptr;





More information about the tbb-commits mailing list