Bug 1683418. Add an autoreleasepool to staunch some of the bleeding. r=mstange,aosmond
authorJeff Muizelaar <jmuizelaar@mozilla.com>
Tue, 22 Dec 2020 03:05:06 +0000
changeset 561553 54a95a4088a237cd14acc087cb433cb43216fbd1
parent 561552 49e85f1c2f324b15623df53f444cc14f311f5d0e
child 561554 b7973553b72310024b31fb374f082762b1d7abc5
child 561580 dadf797a5b5bc9d8c57d52bac86710714a1bbe57
push id133260
push userjmuizelaar@mozilla.com
push dateTue, 22 Dec 2020 03:12:16 +0000
treeherderautoland@54a95a4088a2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange, aosmond
bugs1683418
milestone86.0a1
first release with
nightly linux32
54a95a4088a2 / 86.0a1 / 20201222093533 / files
nightly linux64
54a95a4088a2 / 86.0a1 / 20201222093533 / files
nightly mac
54a95a4088a2 / 86.0a1 / 20201222093533 / files
nightly win32
54a95a4088a2 / 86.0a1 / 20201222093533 / files
nightly win64
54a95a4088a2 / 86.0a1 / 20201222093533 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1683418. Add an autoreleasepool to staunch some of the bleeding. r=mstange,aosmond There are probably other places that have this kind of problem but this keeps thing simple for now and might be sufficient to get things under control. Further work will follow. Differential Revision: https://phabricator.services.mozilla.com/D100294
Cargo.lock
gfx/wr/Cargo.lock
gfx/wr/webrender/Cargo.toml
gfx/wr/webrender/src/platform/macos/font.rs
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -5763,16 +5763,17 @@ dependencies = [
  "gleam",
  "glslopt",
  "image",
  "lazy_static",
  "libc",
  "log",
  "malloc_size_of_derive",
  "num-traits",
+ "objc",
  "plane-split",
  "rayon",
  "ron",
  "serde",
  "serde_json",
  "smallvec",
  "svg_fmt",
  "time",
--- a/gfx/wr/Cargo.lock
+++ b/gfx/wr/Cargo.lock
@@ -1807,16 +1807,17 @@ dependencies = [
  "glslopt 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "image 0.23.3 (registry+https://github.com/rust-lang/crates.io-index)",
  "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "libc 0.2.68 (registry+https://github.com/rust-lang/crates.io-index)",
  "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)",
  "malloc_size_of_derive 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "mozangle 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "num-traits 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
+ "objc 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
  "plane-split 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
  "png 0.16.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "rand 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
  "rayon 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
  "ron 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde 1.0.106 (registry+https://github.com/rust-lang/crates.io-index)",
  "serde_json 1.0.51 (registry+https://github.com/rust-lang/crates.io-index)",
  "smallvec 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
--- a/gfx/wr/webrender/Cargo.toml
+++ b/gfx/wr/webrender/Cargo.toml
@@ -68,8 +68,9 @@ libc = "0.2"
 
 [target.'cfg(target_os = "windows")'.dependencies]
 dwrote = "0.11"
 
 [target.'cfg(target_os = "macos")'.dependencies]
 core-foundation = "0.9"
 core-graphics = "0.22"
 core-text = { version = "19", default-features = false }
+objc = "0.2"
--- a/gfx/wr/webrender/src/platform/macos/font.rs
+++ b/gfx/wr/webrender/src/platform/macos/font.rs
@@ -416,26 +416,29 @@ impl FontContext {
     }
 
     fn get_ct_font(
         &mut self,
         font_key: FontKey,
         size: f64,
         variations: &[FontVariation],
     ) -> Option<(CTFont, CTFontSymbolicTraits)> {
-        match self.ct_fonts.entry((font_key, FontSize::from_f64_px(size), variations.to_vec())) {
-            Entry::Occupied(entry) => Some((*entry.get()).clone()),
-            Entry::Vacant(entry) => {
-                let desc_or_font = self.desc_or_fonts.get(&font_key)?;
-                let ct_font = new_ct_font_with_variations(desc_or_font, size, variations);
-                let traits = ct_font.symbolic_traits();
-                entry.insert((ct_font.clone(), traits));
-                Some((ct_font, traits))
+        // Interacting with CoreText can create autorelease garbage.
+        objc::rc::autoreleasepool(|| {
+            match self.ct_fonts.entry((font_key, FontSize::from_f64_px(size), variations.to_vec())) {
+                Entry::Occupied(entry) => Some((*entry.get()).clone()),
+                Entry::Vacant(entry) => {
+                    let desc_or_font = self.desc_or_fonts.get(&font_key)?;
+                    let ct_font = new_ct_font_with_variations(desc_or_font, size, variations);
+                    let traits = ct_font.symbolic_traits();
+                    entry.insert((ct_font.clone(), traits));
+                    Some((ct_font, traits))
+                }
             }
-        }
+        })
     }
 
     pub fn get_glyph_index(&mut self, font_key: FontKey, ch: char) -> Option<u32> {
         let character = ch as u16;
         let mut glyph = 0;
 
         self.get_ct_font(font_key, 16.0, &[])
             .and_then(|(ct_font, _)| {