Skip to content

Commit c66f8c3

Browse files
committed
Bug 1946361 - Add debug prefs for missing snapshots. r=gw
Differential Revision: https://phabricator.services.mozilla.com/D237008
1 parent 59261d6 commit c66f8c3

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

webrender/src/resource_cache.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,8 @@ pub struct ResourceCache {
516516
/// Over time it would be better to handle each of these cases explicitly
517517
/// and make it a hard error to fail to snapshot a stacking context.
518518
fallback_handle: TextureCacheHandle,
519+
debug_fallback_panic: bool,
520+
debug_fallback_pink: bool,
519521
}
520522

521523
impl ResourceCache {
@@ -554,6 +556,8 @@ impl ResourceCache {
554556
font_templates_memory: 0,
555557
render_target_pool: Vec::new(),
556558
fallback_handle: TextureCacheHandle::invalid(),
559+
debug_fallback_panic: false,
560+
debug_fallback_pink: false,
557561
}
558562
}
559563

@@ -1367,6 +1371,9 @@ impl ResourceCache {
13671371
if self.resources.image_templates
13681372
.get(request.key)
13691373
.map_or(false, |img| img.data.is_snapshot()) {
1374+
if self.debug_fallback_panic {
1375+
panic!("Missing snapshot image");
1376+
}
13701377
return self.get_texture_cache_item(&self.fallback_handle);
13711378
}
13721379

@@ -1514,6 +1521,11 @@ impl ResourceCache {
15141521
profile_scope!("update_texture_cache");
15151522

15161523
if self.fallback_handle == TextureCacheHandle::invalid() {
1524+
let fallback_color = if self.debug_fallback_pink {
1525+
vec![255, 0, 255, 255]
1526+
} else {
1527+
vec![0, 0, 0, 0]
1528+
};
15171529
self.texture_cache.update(
15181530
&mut self.fallback_handle,
15191531
ImageDescriptor {
@@ -1524,7 +1536,7 @@ impl ResourceCache {
15241536
offset: 0,
15251537
},
15261538
TextureFilter::Linear,
1527-
Some(CachedImageData::Raw(Arc::new(vec![0, 0, 0, 0]))),
1539+
Some(CachedImageData::Raw(Arc::new(fallback_color))),
15281540
[0.0; 4],
15291541
DirtyRect::All,
15301542
gpu_cache,
@@ -1808,6 +1820,13 @@ impl ResourceCache {
18081820
GLYPH_FLASHING.store(flags.contains(DebugFlags::GLYPH_FLASHING), std::sync::atomic::Ordering::Relaxed);
18091821
self.texture_cache.set_debug_flags(flags);
18101822
self.picture_textures.set_debug_flags(flags);
1823+
self.debug_fallback_panic = flags.contains(DebugFlags::MISSING_SNAPSHOT_PANIC);
1824+
let fallback_pink = flags.contains(DebugFlags::MISSING_SNAPSHOT_PINK);
1825+
1826+
if fallback_pink != self.debug_fallback_pink && self.fallback_handle != TextureCacheHandle::invalid() {
1827+
self.texture_cache.evict_handle(&self.fallback_handle);
1828+
}
1829+
self.debug_fallback_pink = fallback_pink;
18111830
}
18121831

18131832
pub fn clear(&mut self, what: ClearCache) {

webrender_api/src/lib.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -663,10 +663,10 @@ impl RenderReasons {
663663
/// Flags to enable/disable various builtin debugging tools.
664664
#[repr(C)]
665665
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Default, Deserialize, MallocSizeOf, Serialize)]
666-
pub struct DebugFlags(u32);
666+
pub struct DebugFlags(u64);
667667

668668
bitflags! {
669-
impl DebugFlags: u32 {
669+
impl DebugFlags: u64 {
670670
/// Display the frame profiler on screen.
671671
const PROFILER_DBG = 1 << 0;
672672
/// Display intermediate render targets on screen.
@@ -725,18 +725,22 @@ bitflags! {
725725
/// If set, dump picture cache invalidation debug to console.
726726
const INVALIDATION_DBG = 1 << 23;
727727
/// Collect and dump profiler statistics to captures.
728-
const PROFILER_CAPTURE = (1 as u32) << 25; // need "as u32" until we have cbindgen#556
728+
const PROFILER_CAPTURE = 1 << 25;
729729
/// Invalidate picture tiles every frames (useful when inspecting GPU work in external tools).
730-
const FORCE_PICTURE_INVALIDATION = (1 as u32) << 26;
730+
const FORCE_PICTURE_INVALIDATION = 1 << 26;
731731
/// Display window visibility on screen.
732732
const WINDOW_VISIBILITY_DBG = 1 << 27;
733733
/// Render large blobs with at a smaller size (incorrectly). This is a temporary workaround for
734734
/// fuzzing.
735735
const RESTRICT_BLOB_SIZE = 1 << 28;
736736
/// Enable surface promotion logging.
737737
const SURFACE_PROMOTION_LOGGING = 1 << 29;
738-
/// Show picture caching debug overlay
739-
const PICTURE_BORDERS = 1 << 30;
738+
/// Show picture caching debug overlay.
739+
const PICTURE_BORDERS = 1 << 30;
740+
/// Panic when a attempting to display a missing stacking context snapshot.
741+
const MISSING_SNAPSHOT_PANIC = (1 as u64) << 31; // need "as u32" until we have cbindgen#556
742+
/// Panic when a attempting to display a missing stacking context snapshot.
743+
const MISSING_SNAPSHOT_PINK = (1 as u64) << 32;
740744
}
741745
}
742746

0 commit comments

Comments
 (0)