Skip to content

Commit 2691f18

Browse files
author
bors-servo
authored
Auto merge of #3382 - kvark:blob-rasterizer, r=jrmuizel
Pass AsyncImageBlobRasterizer through the stack explicitly Similar to #3378, this PR attempts to address our failures in bug 1492241. If we aren't sure that the blob image rasterizer, being a state of the resource cache, is the right one to build the scene, then perhaps it shouldn't be a state in the first place. This is what this PR is doing. It's not guaranteed to fix anything, just bringing more clarity to the code, hopefully helping us to rule out one of the possible causes. r? @nical cc @aosmond Gecko try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=726e01545625a20153893dbb22509b70294651bb <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/3382) <!-- Reviewable:end -->
2 parents add1538 + 8a1d9dc commit 2691f18

File tree

3 files changed

+22
-26
lines changed

3 files changed

+22
-26
lines changed

webrender/src/frame_builder.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5+
use api::{AsyncBlobImageRasterizer};
56
use api::{ColorF, DeviceIntPoint, DevicePixelScale, LayoutPixel, PicturePixel, RasterPixel};
67
use api::{DeviceIntRect, DeviceIntSize, DocumentLayer, FontRenderMode};
78
use api::{LayoutPoint, LayoutRect, LayoutSize, PipelineId, RasterSpace, WorldPoint, WorldRect, WorldPixel};
@@ -372,6 +373,7 @@ impl FrameBuilder {
372373
scene_properties: &SceneProperties,
373374
resources: &mut FrameResources,
374375
scratch: &mut PrimitiveScratchBuffer,
376+
blob_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
375377
) -> Frame {
376378
profile_scope!("build");
377379
debug_assert!(
@@ -416,9 +418,12 @@ impl FrameBuilder {
416418
scratch,
417419
);
418420

419-
resource_cache.block_until_all_resources_added(gpu_cache,
420-
&mut render_tasks,
421-
texture_cache_profile);
421+
resource_cache.block_until_all_resources_added(
422+
gpu_cache,
423+
&mut render_tasks,
424+
blob_rasterizer,
425+
texture_cache_profile,
426+
);
422427

423428
let mut passes = vec![
424429
special_render_passes.alpha_glyph_pass,

webrender/src/render_backend.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
//! See the comment at the top of the `renderer` module for a description of
99
//! how these two pieces interact.
1010
11-
use api::{ApiMsg, BuiltDisplayList, ClearCache, DebugCommand};
11+
use api::{ApiMsg, AsyncBlobImageRasterizer, BuiltDisplayList, ClearCache, DebugCommand};
1212
#[cfg(feature = "debugger")]
1313
use api::{BuiltDisplayListIter, SpecificDisplayItem};
1414
use api::{DevicePixelScale, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
@@ -405,6 +405,7 @@ impl Document {
405405
&mut self,
406406
resource_cache: &mut ResourceCache,
407407
gpu_cache: &mut GpuCache,
408+
blob_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
408409
resource_profile: &mut ResourceProfileCounters,
409410
) -> RenderedDocument {
410411
let accumulated_scale_factor = self.view.accumulated_scale_factor();
@@ -432,6 +433,7 @@ impl Document {
432433
&self.dynamic_properties,
433434
&mut self.resources,
434435
&mut self.scratch,
436+
blob_rasterizer,
435437
);
436438
self.hit_tester = Some(frame_builder.create_hit_tester(
437439
&self.clip_scroll_tree,
@@ -786,9 +788,6 @@ impl RenderBackend {
786788
self.resource_cache.add_rasterized_blob_images(
787789
replace(&mut txn.rasterized_blobs, Vec::new())
788790
);
789-
if let Some(rasterizer) = txn.blob_rasterizer.take() {
790-
self.resource_cache.set_blob_rasterizer(rasterizer);
791-
}
792791

793792
self.update_document(
794793
txn.document_id,
@@ -798,6 +797,7 @@ impl RenderBackend {
798797
replace(&mut txn.notifications, Vec::new()),
799798
txn.render_frame,
800799
txn.invalidate_rendered_frame,
800+
txn.blob_rasterizer.take(),
801801
&mut frame_counter,
802802
&mut profile_counters,
803803
has_built_scene,
@@ -1111,9 +1111,6 @@ impl RenderBackend {
11111111
}
11121112

11131113
if !transaction_msg.use_scene_builder_thread && txn.can_skip_scene_builder() {
1114-
if let Some(rasterizer) = txn.blob_rasterizer.take() {
1115-
self.resource_cache.set_blob_rasterizer(rasterizer);
1116-
}
11171114
self.update_document(
11181115
txn.document_id,
11191116
replace(&mut txn.resource_updates, Vec::new()),
@@ -1122,6 +1119,7 @@ impl RenderBackend {
11221119
replace(&mut txn.notifications, Vec::new()),
11231120
txn.render_frame,
11241121
txn.invalidate_rendered_frame,
1122+
txn.blob_rasterizer.take(),
11251123
frame_counter,
11261124
profile_counters,
11271125
false
@@ -1158,6 +1156,7 @@ impl RenderBackend {
11581156
mut notifications: Vec<NotificationRequest>,
11591157
mut render_frame: bool,
11601158
invalidate_rendered_frame: bool,
1159+
blob_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
11611160
frame_counter: &mut u32,
11621161
profile_counters: &mut BackendProfileCounters,
11631162
has_built_scene: bool,
@@ -1242,6 +1241,7 @@ impl RenderBackend {
12421241
let rendered_document = doc.build_frame(
12431242
&mut self.resource_cache,
12441243
&mut self.gpu_cache,
1244+
blob_rasterizer,
12451245
&mut profile_counters.resources,
12461246
);
12471247

@@ -1492,6 +1492,7 @@ impl RenderBackend {
14921492
let rendered_document = doc.build_frame(
14931493
&mut self.resource_cache,
14941494
&mut self.gpu_cache,
1495+
None,
14951496
&mut profile_counters.resources,
14961497
);
14971498
//TODO: write down doc's pipeline info?

webrender/src/resource_cache.rs

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -435,8 +435,6 @@ pub struct ResourceCache {
435435
// If while building a frame we encounter blobs that we didn't already
436436
// rasterize, add them to this list and rasterize them synchronously.
437437
missing_blob_images: Vec<BlobImageParams>,
438-
// The rasterizer associated with the current scene.
439-
blob_image_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
440438
// A log of the last three frames worth of deleted image keys kept
441439
// for debugging purposes.
442440
deleted_blob_keys: VecDeque<Vec<BlobImageKey>>
@@ -463,7 +461,6 @@ impl ResourceCache {
463461
rasterized_blob_images: FastHashMap::default(),
464462
blob_image_templates: FastHashMap::default(),
465463
missing_blob_images: Vec::new(),
466-
blob_image_rasterizer: None,
467464
// We want to keep three frames worth of delete blob keys
468465
deleted_blob_keys: vec![Vec::new(), Vec::new(), Vec::new()].into(),
469466
}
@@ -640,10 +637,6 @@ impl ResourceCache {
640637
);
641638
}
642639

643-
pub fn set_blob_rasterizer(&mut self, rasterizer: Box<AsyncBlobImageRasterizer>) {
644-
self.blob_image_rasterizer = Some(rasterizer);
645-
}
646-
647640
pub fn add_rasterized_blob_images(&mut self, images: Vec<(BlobImageRequest, BlobImageResult)>) {
648641
for (request, result) in images {
649642
let data = match result {
@@ -1478,6 +1471,7 @@ impl ResourceCache {
14781471
&mut self,
14791472
gpu_cache: &mut GpuCache,
14801473
render_tasks: &mut RenderTaskTree,
1474+
blob_image_rasterizer: Option<Box<AsyncBlobImageRasterizer>>,
14811475
texture_cache_profile: &mut TextureCacheProfileCounters,
14821476
) {
14831477
profile_scope!("block_until_all_resources_added");
@@ -1494,7 +1488,9 @@ impl ResourceCache {
14941488
texture_cache_profile,
14951489
);
14961490

1497-
self.rasterize_missing_blob_images();
1491+
if !self.missing_blob_images.is_empty() {
1492+
self.rasterize_missing_blob_images(&mut *blob_image_rasterizer.unwrap());
1493+
}
14981494

14991495
// Apply any updates of new / updated images (incl. blobs) to the texture cache.
15001496
self.update_texture_cache(gpu_cache);
@@ -1507,11 +1503,7 @@ impl ResourceCache {
15071503
self.texture_cache.end_frame(texture_cache_profile);
15081504
}
15091505

1510-
fn rasterize_missing_blob_images(&mut self) {
1511-
if self.missing_blob_images.is_empty() {
1512-
return;
1513-
}
1514-
1506+
fn rasterize_missing_blob_images(&mut self, blob_image_rasterizer: &mut AsyncBlobImageRasterizer) {
15151507
self.blob_image_handler
15161508
.as_mut()
15171509
.unwrap()
@@ -1524,9 +1516,7 @@ impl ResourceCache {
15241516
}
15251517
}
15261518
let is_low_priority = false;
1527-
let rasterized_blobs = self.blob_image_rasterizer
1528-
.as_mut()
1529-
.unwrap()
1519+
let rasterized_blobs = blob_image_rasterizer
15301520
.rasterize(&self.missing_blob_images, is_low_priority);
15311521

15321522
self.add_rasterized_blob_images(rasterized_blobs);

0 commit comments

Comments
 (0)