From 8efbd9be96331a2890d73a044d5c9d1820188947 Mon Sep 17 00:00:00 2001 From: Doug Thayer Date: Mon, 6 May 2019 17:21:22 +0000 Subject: [PATCH] Bug 1541078 - Add pre/post frames hooks into save_capture r=kvark There's two ways we could get around this. We could add a path around the prepared_for_frames assertion in GpuCache::end_frame, or we can do this, and leave the TODO explicit with the assertion. I took the latter approach because we can clear the GpuCache / TextureCache through other routes than frame building anyway, so we could hit this failure path before any of the patches in this bug landed. Differential Revision: https://phabricator.services.mozilla.com/D29884 --HG-- extra : moz-landing-system : lando --- gfx/wr/webrender/src/gpu_cache.rs | 1 + gfx/wr/webrender/src/render_backend.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/gfx/wr/webrender/src/gpu_cache.rs b/gfx/wr/webrender/src/gpu_cache.rs index 04b0e92aaa03..516c02001e83 100644 --- a/gfx/wr/webrender/src/gpu_cache.rs +++ b/gfx/wr/webrender/src/gpu_cache.rs @@ -728,6 +728,7 @@ impl GpuCache { let mut cache = Self::new(); let mut now = FrameStamp::first(DocumentId::new(IdNamespace(1), 1)); now.advance(); + cache.prepared_for_frames = true; cache.begin_frame(now); cache } diff --git a/gfx/wr/webrender/src/render_backend.rs b/gfx/wr/webrender/src/render_backend.rs index d99f9c8bbddf..ad06a463206c 100644 --- a/gfx/wr/webrender/src/render_backend.rs +++ b/gfx/wr/webrender/src/render_backend.rs @@ -1665,6 +1665,10 @@ impl RenderBackend { } let config = CaptureConfig::new(root, bits); + if config.bits.contains(CaptureBits::FRAME) { + self.prepare_for_frames(); + } + for (&id, doc) in &mut self.documents { debug!("\tdocument {:?}", id); if config.bits.contains(CaptureBits::SCENE) { @@ -1706,6 +1710,14 @@ impl RenderBackend { config.serialize(&doc.data_stores, data_stores_name); } + if config.bits.contains(CaptureBits::FRAME) { + // TODO: there is no guarantee that we won't hit this case, but we want to + // report it here if we do. If we don't, it will simply crash in + // Renderer::render_impl and give us less information about the source. + assert!(!self.requires_frame_build(), "Caches were cleared during a capture."); + self.bookkeep_after_frames(); + } + debug!("\tscene builder"); self.scene_tx.send(SceneBuilderRequest::SaveScene(config.clone())).unwrap();