Commit 92c9cb36 authored by Doug Thayer's avatar Doug Thayer
Browse files

Bug 1538540 - Sanity check frames after TextureCache clears r=bholley

In trying to diagnose bug 1538540, I'm hitting my limits as far as
simply staring at the code and trying to work out possible ways to
hit the crash goes. This assertion will split the search space into
clear-related causes and non-clear-related causes to narrow things
down.

Differential Revision: https://phabricator.services.mozilla.com/D29420

--HG--
extra : moz-landing-system : lando
parent 7944190a
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -168,6 +168,9 @@ pub struct TextureCacheUpdate {
/// important to allow coalescing of certain allocation operations.
#[derive(Default)]
pub struct TextureUpdateList {
    /// Indicates that there was some kind of cleanup clear operation. Used for
    /// sanity checks.
    pub clears_shared_cache: bool,
    /// Commands to alloc/realloc/free the textures. Processed first.
    pub allocations: Vec<TextureCacheAllocation>,
    /// Commands to update the contents of the textures. Processed second.
@@ -178,11 +181,18 @@ impl TextureUpdateList {
    /// Mints a new `TextureUpdateList`.
    pub fn new() -> Self {
        TextureUpdateList {
            clears_shared_cache: false,
            allocations: Vec::new(),
            updates: Vec::new(),
        }
    }

    /// Sets the clears_shared_cache flag for renderer-side sanity checks.
    #[inline]
    pub fn note_clear(&mut self) {
        self.clears_shared_cache = true;
    }

    /// Pushes an update operation onto the list.
    #[inline]
    pub fn push_update(&mut self, update: TextureCacheUpdate) {
+25 −2
Original line number Diff line number Diff line
@@ -66,7 +66,7 @@ use gpu_cache::{GpuCacheDebugChunk, GpuCacheDebugCmd};
use gpu_glyph_renderer::GpuGlyphRenderer;
use gpu_types::{PrimitiveHeaderI, PrimitiveHeaderF, ScalingInstance, TransformData, ResolveInstanceData};
use internal_types::{TextureSource, ORTHO_FAR_PLANE, ORTHO_NEAR_PLANE, ResourceCacheError};
use internal_types::{CacheTextureId, DebugOutput, FastHashMap, LayerIndex, RenderedDocument, ResultMsg};
use internal_types::{CacheTextureId, DebugOutput, FastHashMap, FastHashSet, LayerIndex, RenderedDocument, ResultMsg};
use internal_types::{TextureCacheAllocationKind, TextureCacheUpdate, TextureUpdateList, TextureUpdateSource};
use internal_types::{RenderTargetInfo, SavedTargetIndex};
use malloc_size_of::MallocSizeOfOps;
@@ -1941,6 +1941,13 @@ pub struct Renderer {
    /// functionality only, such as the debug zoom widget.
    cursor_position: DeviceIntPoint,

    /// Guards to check if we might be rendering a frame with expired texture
    /// cache entries.
    shared_texture_cache_cleared: bool,

    /// The set of documents which we've seen a publish for since last render.
    documents_seen: FastHashSet<DocumentId>,

    #[cfg(feature = "capture")]
    read_fbo: FBOId,
    #[cfg(feature = "replay")]
@@ -2418,6 +2425,8 @@ impl Renderer {
            device_size: None,
            zoom_debug_texture: None,
            cursor_position: DeviceIntPoint::zero(),
            shared_texture_cache_cleared: false,
            documents_seen: FastHashSet::default(),
        };

        // We initially set the flags to default and then now call set_debug_flags
@@ -2482,6 +2491,8 @@ impl Renderer {
                    texture_update_list,
                    profile_counters,
                ) => {
                    self.documents_seen.insert(document_id);

                    if doc.is_new_scene {
                        self.new_scene_indicator.changed();
                    }
@@ -3021,7 +3032,12 @@ impl Renderer {
            );

            let last_document_index = active_documents.len() - 1;
            for (doc_index, (_, RenderedDocument { ref mut frame, .. })) in active_documents.iter_mut().enumerate() {
            for (doc_index, (document_id, RenderedDocument { ref mut frame, .. })) in active_documents.iter_mut().enumerate() {
                if self.shared_texture_cache_cleared {
                    assert!(self.documents_seen.contains(&document_id),
                            "Cleared texture cache without sending new document frame.");
                }

                frame.profile_counters.reset_targets();
                self.prepare_gpu_cache(frame);
                assert!(frame.gpu_cache_frame_id <= self.gpu_cache_frame_id,
@@ -3174,6 +3190,9 @@ impl Renderer {
            self.last_time = current_time;
        }

        self.documents_seen.clear();
        self.shared_texture_cache_cleared = false;

        if self.renderer_errors.is_empty() {
            Ok(results)
        } else {
@@ -3386,6 +3405,10 @@ impl Renderer {
                    };
                    self.profile_counters.texture_data_uploaded.add(bytes_uploaded >> 10);
                }

                if update_list.clears_shared_cache {
                    self.shared_texture_cache_cleared = true;
                }
            }

            drain_filter(
+2 −0
Original line number Diff line number Diff line
@@ -624,6 +624,8 @@ impl TextureCache {
                self.free(&entry);
            }
        }

        self.pending_updates.note_clear();
        self.per_doc_data = per_doc_data;
        self.require_frame_build = true;
    }