Backed out changeset 42781c597745 (bug 1448703) cpu process leakcchecks
authorAndreea Pavel <apavel@mozilla.com>
Tue, 24 Apr 2018 06:47:19 +0300
changeset 415221 4f3e0c71818804f816c5e37f326ec4d9a4446f00
parent 415220 e46a44d9b62e3fd555885c6b5dffde236397e67f
child 415222 5579f92920c321f2011db2dbe4118bb3110a46fc
push id33892
push userebalazs@mozilla.com
push dateTue, 24 Apr 2018 09:42:58 +0000
treeherdermozilla-central@26e53729a109 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1448703
milestone61.0a1
backs out42781c5977453fc4c1ac9538c9eef240456b3e10
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 42781c597745 (bug 1448703) cpu process leakcchecks
gfx/webrender_bindings/Moz2DImageRenderer.cpp
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/src/moz2d_renderer.rs
--- a/gfx/webrender_bindings/Moz2DImageRenderer.cpp
+++ b/gfx/webrender_bindings/Moz2DImageRenderer.cpp
@@ -89,33 +89,33 @@ static struct FontDeleteLog {
       } else if (mEntries[offset] == namespaceEntry) {
         return "cleared namespace";
       }
     } while (offset != mNextEntry);
     return "unknown font";
   }
 } sFontDeleteLog;
 
-extern "C" {
 void
 ClearBlobImageResources(WrIdNamespace aNamespace) {
   StaticMutexAutoLock lock(sFontDataTableLock);
   sFontDeleteLog.Add(aNamespace);
   for (auto i = sFontDataTable.begin(); i != sFontDataTable.end();) {
     if (i->first.mNamespace == aNamespace) {
       if (i->second.mVec) {
         wr_dec_ref_arc(i->second.mVec);
       }
       i = sFontDataTable.erase(i);
     } else {
       i++;
     }
   }
 }
 
+extern "C" {
 void
 AddFontData(WrFontKey aKey, const uint8_t *aData, size_t aSize, uint32_t aIndex, const ArcVecU8 *aVec) {
   StaticMutexAutoLock lock(sFontDataTableLock);
   auto i = sFontDataTable.find(aKey);
   if (i == sFontDataTable.end()) {
     FontTemplate font;
     font.mData = aData;
     font.mSize = aSize;
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -352,16 +352,18 @@ WebRenderAPI::CreateDocument(LayoutDevic
   return api.forget();
 }
 
 wr::WrIdNamespace
 WebRenderAPI::GetNamespace() {
   return wr_api_get_namespace(mDocHandle);
 }
 
+extern void ClearBlobImageResources(WrIdNamespace aNamespace);
+
 WebRenderAPI::~WebRenderAPI()
 {
   if (!mRootDocumentApi) {
     wr_api_delete_document(mDocHandle);
   }
 
   if (!mRootApi) {
     RenderThread::Get()->SetDestroyed(GetId());
@@ -369,16 +371,31 @@ WebRenderAPI::~WebRenderAPI()
     layers::SynchronousTask task("Destroy WebRenderAPI");
     auto event = MakeUnique<RemoveRenderer>(&task);
     RunOnRenderThread(Move(event));
     task.Wait();
 
     wr_api_shut_down(mDocHandle);
   }
 
+  // wr_api_get_namespace cannot be marked destructor-safe because it has a
+  // return value, and we can't call it if MOZ_BUILD_WEBRENDER is not defined
+  // because it's not destructor-safe. So let's just ifdef around it. This is
+  // basically a hack to get around compile-time warnings, this code never runs
+  // unless MOZ_BUILD_WEBRENDER is defined anyway.
+#ifdef MOZ_BUILD_WEBRENDER
+  wr::WrIdNamespace ns = GetNamespace();
+#else
+  wr::WrIdNamespace ns{0};
+#endif
+
+  // Clean up any resources the blob image renderer is holding onto that
+  // can no longer be used once this WR API instance goes away.
+  ClearBlobImageResources(ns);
+
   wr_api_delete(mDocHandle);
 }
 
 void
 WebRenderAPI::SendTransaction(TransactionBuilder& aTxn)
 {
   wr_transaction_update_resources(aTxn.Raw(), aTxn.RawUpdates());
   wr_api_send_transaction(mDocHandle, aTxn.Raw());
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -58,17 +58,17 @@ impl WrExternalImageBufferType {
 /// cbindgen:field-names=[mHandle]
 /// cbindgen:derive-lt=true
 /// cbindgen:derive-lte=true
 type WrEpoch = Epoch;
 /// cbindgen:field-names=[mHandle]
 /// cbindgen:derive-lt=true
 /// cbindgen:derive-lte=true
 /// cbindgen:derive-neq=true
-pub type WrIdNamespace = IdNamespace;
+type WrIdNamespace = IdNamespace;
 
 /// cbindgen:field-names=[mNamespace, mHandle]
 type WrPipelineId = PipelineId;
 /// cbindgen:field-names=[mNamespace, mHandle]
 /// cbindgen:derive-neq=true
 type WrImageKey = ImageKey;
 /// cbindgen:field-names=[mNamespace, mHandle]
 pub type WrFontKey = FontKey;
--- a/gfx/webrender_bindings/src/moz2d_renderer.rs
+++ b/gfx/webrender_bindings/src/moz2d_renderer.rs
@@ -489,29 +489,27 @@ impl BlobImageRenderer for Moz2dImageRen
     }
     fn delete_font(&mut self, font: FontKey) {
         unsafe { DeleteFontData(font); }
     }
 
     fn delete_font_instance(&mut self, _key: FontInstanceKey) {
     }
 
-    fn clear_namespace(&mut self, namespace: IdNamespace) {
-        unsafe { ClearBlobImageResources(namespace); }
+    fn clear_namespace(&mut self, _namespace: IdNamespace) {
     }
 }
 
-use bindings::{WrFontKey, WrIdNamespace};
+use bindings::WrFontKey;
 
 #[allow(improper_ctypes)] // this is needed so that rustc doesn't complain about passing the &Arc<Vec> to an extern function
 extern "C" {
     fn AddFontData(key: WrFontKey, data: *const u8, size: usize, index: u32, vec: &ArcVecU8);
     fn AddNativeFontHandle(key: WrFontKey, handle: *mut c_void, index: u32);
     fn DeleteFontData(key: WrFontKey);
-    fn ClearBlobImageResources(namespace: WrIdNamespace);
 }
 
 impl Moz2dImageRenderer {
     pub fn new(workers: Arc<ThreadPool>) -> Self {
         let (tx, rx) = channel();
         Moz2dImageRenderer {
             blob_commands: HashMap::new(),
             rendered_images: HashMap::new(),