Bug 1457448 - Ensure we flush the async scene builder thread before snapshotting. r=nical
authorKartikaya Gupta <kgupta@mozilla.com>
Fri, 27 Apr 2018 10:46:21 -0400
changeset 416331 6a5dc145f8ecd07be94a1c22bcfa6c5ddfae936c
parent 416330 072c882dccce90b2b2b3e13442dab17752855947
child 416332 25599bf5604d848d78484199781bd99c44b7da0e
push id63450
push userkgupta@mozilla.com
push dateMon, 30 Apr 2018 23:48:28 +0000
treeherderautoland@6a5dc145f8ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnical
bugs1457448
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1457448 - Ensure we flush the async scene builder thread before snapshotting. r=nical MozReview-Commit-ID: 3XTFWiEmk0p
gfx/layers/wr/WebRenderBridgeParent.cpp
gfx/webrender_bindings/WebRenderAPI.cpp
gfx/webrender_bindings/WebRenderAPI.h
gfx/webrender_bindings/src/bindings.rs
gfx/webrender_bindings/webrender_ffi_generated.h
--- a/gfx/layers/wr/WebRenderBridgeParent.cpp
+++ b/gfx/layers/wr/WebRenderBridgeParent.cpp
@@ -865,16 +865,19 @@ WebRenderBridgeParent::RecvGetSnapshot(P
   uint32_t buffer_size = size.width * size.height * 4;
 
   // Assert the stride of the buffer is what webrender expects
   MOZ_ASSERT((uint32_t)(size.width * 4) == stride);
 
   mForceRendering = true;
 
   mCompositorScheduler->FlushPendingComposite();
+  if (gfxPrefs::WebRenderAsyncSceneBuild()) {
+    mApi->FlushSceneBuilder();
+  }
   mApi->Readback(size, buffer, buffer_size);
 
   mForceRendering = false;
 
   return IPC_OK();
 }
 
 void
--- a/gfx/webrender_bindings/WebRenderAPI.cpp
+++ b/gfx/webrender_bindings/WebRenderAPI.cpp
@@ -522,16 +522,22 @@ WebRenderAPI::Resume()
 
 void
 WebRenderAPI::WakeSceneBuilder()
 {
     wr_api_wake_scene_builder(mDocHandle);
 }
 
 void
+WebRenderAPI::FlushSceneBuilder()
+{
+    wr_api_flush_scene_builder(mDocHandle);
+}
+
+void
 WebRenderAPI::WaitFlushed()
 {
     class WaitFlushedEvent : public RendererEvent
     {
         public:
             explicit WaitFlushedEvent(layers::SynchronousTask* aTask)
                 : mTask(aTask)
             {
--- a/gfx/webrender_bindings/WebRenderAPI.h
+++ b/gfx/webrender_bindings/WebRenderAPI.h
@@ -193,16 +193,17 @@ public:
   void RunOnRenderThread(UniquePtr<RendererEvent> aEvent);
 
   void Readback(gfx::IntSize aSize, uint8_t *aBuffer, uint32_t aBufferSize);
 
   void Pause();
   bool Resume();
 
   void WakeSceneBuilder();
+  void FlushSceneBuilder();
 
   wr::WrIdNamespace GetNamespace();
   uint32_t GetMaxTextureSize() const { return mMaxTextureSize; }
   bool GetUseANGLE() const { return mUseANGLE; }
   layers::SyncHandle GetSyncHandle() const { return mSyncHandle; }
 
   void Capture();
 
--- a/gfx/webrender_bindings/src/bindings.rs
+++ b/gfx/webrender_bindings/src/bindings.rs
@@ -1476,16 +1476,21 @@ pub unsafe extern "C" fn wr_api_get_name
     dh.api.get_namespace_id()
 }
 
 #[no_mangle]
 pub unsafe extern "C" fn wr_api_wake_scene_builder(dh: &mut DocumentHandle) {
     dh.api.wake_scene_builder();
 }
 
+#[no_mangle]
+pub unsafe extern "C" fn wr_api_flush_scene_builder(dh: &mut DocumentHandle) {
+    dh.api.flush_scene_builder();
+}
+
 // RenderThread WIP notes:
 // In order to separate the compositor thread (or ipc receiver) and the render
 // thread, some of the logic below needs to be rewritten. In particular
 // the WrWindowState and Notifier implementations aren't designed to work with
 // a separate render thread.
 // As part of that I am moving the bindings closer to WebRender's API boundary,
 // and moving more of the logic in C++ land.
 // This work is tracked by bug 1328602.
--- a/gfx/webrender_bindings/webrender_ffi_generated.h
+++ b/gfx/webrender_bindings/webrender_ffi_generated.h
@@ -1015,16 +1015,20 @@ WR_DESTRUCTOR_SAFE_FUNC;
 WR_INLINE
 void wr_api_finalize_builder(WrState *aState,
                              LayoutSize *aContentSize,
                              BuiltDisplayListDescriptor *aDlDescriptor,
                              WrVecU8 *aDlData)
 WR_FUNC;
 
 WR_INLINE
+void wr_api_flush_scene_builder(DocumentHandle *aDh)
+WR_FUNC;
+
+WR_INLINE
 WrIdNamespace wr_api_get_namespace(DocumentHandle *aDh)
 WR_FUNC;
 
 WR_INLINE
 bool wr_api_hit_test(DocumentHandle *aDh,
                      WorldPoint aPoint,
                      WrPipelineId *aOutPipelineId,
                      uint64_t *aOutScrollId,