Bug 1640103 - Call clear_namespace on the blob image handler. r=gw

This should fix a memory usage regression from a9eaeeec41 which I suspect was caused by not clearing the blob's namespace anymore after destroying the api object.

Depends on D76489

Differential Revision: https://phabricator.services.mozilla.com/D76490
This commit is contained in:
Nicolas Silva 2020-05-25 20:58:03 +00:00
Родитель 8ac1a956ac
Коммит 9a64982c05
2 изменённых файлов: 16 добавлений и 1 удалений

Просмотреть файл

@ -8,7 +8,7 @@
//! See the comment at the top of the `renderer` module for a description of
//! how these two pieces interact.
use api::{ApiMsg, ClearCache, DebugCommand, DebugFlags};
use api::{ApiMsg, ClearCache, DebugCommand, DebugFlags, BlobImageHandler};
use api::{DocumentId, DocumentLayer, ExternalScrollId, FrameMsg, HitTestFlags, HitTestResult};
use api::{IdNamespace, MemoryReport, PipelineId, RenderNotifier, ScrollClamping};
use api::{ScrollLocation, TransactionMsg, ResourceUpdate};
@ -773,6 +773,11 @@ pub struct RenderBackend {
debug_flags: DebugFlags,
namespace_alloc_by_client: bool,
// We keep one around to be able to call clear_namespace
// after the api object is deleted. For most purposes the
// api object's blob handler should be used instead.
blob_image_handler: Option<Box<dyn BlobImageHandler>>,
recycler: Recycler,
#[cfg(feature = "capture")]
capture_config: Option<CaptureConfig>,
@ -791,6 +796,7 @@ impl RenderBackend {
default_device_pixel_ratio: f32,
resource_cache: ResourceCache,
notifier: Box<dyn RenderNotifier>,
blob_image_handler: Option<Box<dyn BlobImageHandler>>,
frame_config: FrameBuilderConfig,
sampler: Option<Box<dyn AsyncPropertySampler + Send>>,
size_of_ops: Option<MallocSizeOfOps>,
@ -817,6 +823,7 @@ impl RenderBackend {
debug_flags,
namespace_alloc_by_client,
recycler: Recycler::new(),
blob_image_handler,
#[cfg(feature = "capture")]
capture_config: None,
#[cfg(feature = "replay")]
@ -903,6 +910,9 @@ impl RenderBackend {
SceneBuilderResult::ClearNamespace(id) => {
self.resource_cache.clear_namespace(id);
self.documents.retain(|doc_id, _doc| doc_id.namespace_id != id);
if let Some(handler) = &mut self.blob_image_handler {
handler.clear_namespace(id);
}
}
SceneBuilderResult::Stopped => {
panic!("We haven't sent a Stop yet, how did we get a Stopped back?");

Просмотреть файл

@ -2526,6 +2526,10 @@ impl Renderer {
scene_tx.clone()
};
let backend_blob_handler = blob_image_handler
.as_ref()
.map(|handler| handler.create_similar());
let rb_font_instances = font_instances.clone();
let enable_multithreading = options.enable_multithreading;
thread::Builder::new().name(rb_thread_name.clone()).spawn(move || {
@ -2568,6 +2572,7 @@ impl Renderer {
device_pixel_ratio,
resource_cache,
backend_notifier,
backend_blob_handler,
config,
sampler,
make_size_of_ops(),