Bug 1946361 - Add debug prefs for missing snapshots. r=gw

Differential Revision: https://phabricator.services.mozilla.com/D237008
This commit is contained in:
Nicolas Silva
2025-02-10 07:52:57 +00:00
parent e12c1ae551
commit 617245d33a
6 changed files with 50 additions and 8 deletions

View File

@@ -51,7 +51,7 @@ class gfxVarReceiver;
_(WebglAllowCoreProfile, bool, true) \
_(WebglAllowWindowsNativeGl, bool, false) \
_(WebRenderMaxPartialPresentRects, int32_t, 0) \
_(WebRenderDebugFlags, int32_t, 0) \
_(WebRenderDebugFlags, uint64_t, 0) \
_(WebRenderBoolParameters, int32_t, 0) \
_(WebRenderBatchingLookback, int32_t, 10) \
_(WebRenderBlobTileSize, int32_t, 256) \

View File

@@ -71,6 +71,7 @@ union GfxVarValue
nsCString;
nsString;
int32_t;
uint64_t;
float;
uint64_t[];
};

View File

@@ -556,6 +556,10 @@ static void WebRenderDebugPrefChangeCallback(const char* aPrefName, void*) {
GFX_WEBRENDER_DEBUG(".restrict-blob-size", wr::DebugFlags::RESTRICT_BLOB_SIZE)
GFX_WEBRENDER_DEBUG(".surface-promotion-logging",
wr::DebugFlags::SURFACE_PROMOTION_LOGGING)
GFX_WEBRENDER_DEBUG(".missing-snapshot-panic",
wr::DebugFlags::MISSING_SNAPSHOT_PANIC)
GFX_WEBRENDER_DEBUG(".missing-snapshot-pink",
wr::DebugFlags::MISSING_SNAPSHOT_PINK)
#undef GFX_WEBRENDER_DEBUG
gfx::gfxVars::SetWebRenderDebugFlags(flags._0);

View File

@@ -516,6 +516,8 @@ pub struct ResourceCache {
/// Over time it would be better to handle each of these cases explicitly
/// and make it a hard error to fail to snapshot a stacking context.
fallback_handle: TextureCacheHandle,
debug_fallback_panic: bool,
debug_fallback_pink: bool,
}
impl ResourceCache {
@@ -554,6 +556,8 @@ impl ResourceCache {
font_templates_memory: 0,
render_target_pool: Vec::new(),
fallback_handle: TextureCacheHandle::invalid(),
debug_fallback_panic: false,
debug_fallback_pink: false,
}
}
@@ -1367,6 +1371,9 @@ impl ResourceCache {
if self.resources.image_templates
.get(request.key)
.map_or(false, |img| img.data.is_snapshot()) {
if self.debug_fallback_panic {
panic!("Missing snapshot image");
}
return self.get_texture_cache_item(&self.fallback_handle);
}
@@ -1514,6 +1521,11 @@ impl ResourceCache {
profile_scope!("update_texture_cache");
if self.fallback_handle == TextureCacheHandle::invalid() {
let fallback_color = if self.debug_fallback_pink {
vec![255, 0, 255, 255]
} else {
vec![0, 0, 0, 0]
};
self.texture_cache.update(
&mut self.fallback_handle,
ImageDescriptor {
@@ -1524,7 +1536,7 @@ impl ResourceCache {
offset: 0,
},
TextureFilter::Linear,
Some(CachedImageData::Raw(Arc::new(vec![0, 0, 0, 0]))),
Some(CachedImageData::Raw(Arc::new(fallback_color))),
[0.0; 4],
DirtyRect::All,
gpu_cache,
@@ -1808,6 +1820,13 @@ impl ResourceCache {
GLYPH_FLASHING.store(flags.contains(DebugFlags::GLYPH_FLASHING), std::sync::atomic::Ordering::Relaxed);
self.texture_cache.set_debug_flags(flags);
self.picture_textures.set_debug_flags(flags);
self.debug_fallback_panic = flags.contains(DebugFlags::MISSING_SNAPSHOT_PANIC);
let fallback_pink = flags.contains(DebugFlags::MISSING_SNAPSHOT_PINK);
if fallback_pink != self.debug_fallback_pink && self.fallback_handle != TextureCacheHandle::invalid() {
self.texture_cache.evict_handle(&self.fallback_handle);
}
self.debug_fallback_pink = fallback_pink;
}
pub fn clear(&mut self, what: ClearCache) {

View File

@@ -663,10 +663,10 @@ impl RenderReasons {
/// Flags to enable/disable various builtin debugging tools.
#[repr(C)]
#[derive(Copy, PartialEq, Eq, Clone, PartialOrd, Ord, Hash, Default, Deserialize, MallocSizeOf, Serialize)]
pub struct DebugFlags(u32);
pub struct DebugFlags(u64);
bitflags! {
impl DebugFlags: u32 {
impl DebugFlags: u64 {
/// Display the frame profiler on screen.
const PROFILER_DBG = 1 << 0;
/// Display intermediate render targets on screen.
@@ -725,9 +725,9 @@ bitflags! {
/// If set, dump picture cache invalidation debug to console.
const INVALIDATION_DBG = 1 << 23;
/// Collect and dump profiler statistics to captures.
const PROFILER_CAPTURE = (1 as u32) << 25; // need "as u32" until we have cbindgen#556
const PROFILER_CAPTURE = 1 << 25;
/// Invalidate picture tiles every frames (useful when inspecting GPU work in external tools).
const FORCE_PICTURE_INVALIDATION = (1 as u32) << 26;
const FORCE_PICTURE_INVALIDATION = 1 << 26;
/// Display window visibility on screen.
const WINDOW_VISIBILITY_DBG = 1 << 27;
/// Render large blobs with at a smaller size (incorrectly). This is a temporary workaround for
@@ -735,8 +735,12 @@ bitflags! {
const RESTRICT_BLOB_SIZE = 1 << 28;
/// Enable surface promotion logging.
const SURFACE_PROMOTION_LOGGING = 1 << 29;
/// Show picture caching debug overlay
const PICTURE_BORDERS = 1 << 30;
/// Show picture caching debug overlay.
const PICTURE_BORDERS = 1 << 30;
/// Panic when a attempting to display a missing stacking context snapshot.
const MISSING_SNAPSHOT_PANIC = (1 as u64) << 31; // need "as u32" until we have cbindgen#556
/// Panic when a attempting to display a missing stacking context snapshot.
const MISSING_SNAPSHOT_PINK = (1 as u64) << 32;
}
}

View File

@@ -7155,6 +7155,20 @@
value: false
mirror: always
# When true, missing stacking context snapshots will crash the GPU or Parent
# process.
- name: gfx.webrender.debug.missing-snapshot-panic
type: RelaxedAtomicBool
value: false
mirror: always
# When true, missing stacking context snapshots will render as an opaque
# pink image.
- name: gfx.webrender.debug.missing-snapshot-pink
type: RelaxedAtomicBool
value: false
mirror: always
#ifdef MOZ_WIDGET_GTK
- name: gfx.webrender.reject-software-driver
type: bool