Skip to content

Commit 60b615f

Browse files
authored
add skia cache limits (#24)
1 parent 3a67dea commit 60b615f

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

crates/anyrender_skia/src/scene.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@ impl Default for SkiaSceneCache {
3939
Self {
4040
paint: Paint::default(),
4141
#[cfg(target_os = "macos")]
42-
extracted_font_data: GenerationalCache::new(1),
43-
typeface: GenerationalCache::new(60), // Keep this high until we figure out a fix for skia_safe fontmgr cache leak
44-
normalized_typeface: GenerationalCache::new(60), // Keep this high until we figure out a fix for skia_safe fontmgr cache leak
42+
extracted_font_data: GenerationalCache::new(10),
43+
typeface: GenerationalCache::new(1),
44+
normalized_typeface: GenerationalCache::new(1),
4545
image_shader: GenerationalCache::new(1),
46-
font: GenerationalCache::new(60), // Keep this high until we figure out a fix for skia_safe fontmgr cache leak
46+
font: GenerationalCache::new(1),
4747
font_mgr: FontMgr::new(),
4848
glyph_id_buf: Default::default(),
4949
glyph_pos_buf: Default::default(),

crates/anyrender_skia/src/window_renderer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use anyrender::WindowRenderer;
22
use debug_timer::debug_timer;
3-
use skia_safe::{Color, Surface};
3+
use skia_safe::{Color, Surface, graphics};
44
use std::sync::Arc;
55

66
use crate::{SkiaScenePainter, scene::SkiaSceneCache};
@@ -50,6 +50,10 @@ impl WindowRenderer for SkiaWindowRenderer {
5050
Self: 'a;
5151

5252
fn resume(&mut self, window: Arc<dyn anyrender::WindowHandle>, width: u32, height: u32) {
53+
graphics::set_font_cache_count_limit(100);
54+
graphics::set_typeface_cache_count_limit(100);
55+
graphics::set_resource_cache_total_bytes_limit(10485760);
56+
5357
#[cfg(target_os = "macos")]
5458
let backend = crate::metal::MetalBackend::new(window, width, height);
5559
#[cfg(not(target_os = "macos"))]

0 commit comments

Comments
 (0)