Don't send DidNotProduceFrame message 54/293454/4
authorJakub Gajownik <j.gajownik2@samsung.com>
Thu, 25 May 2023 14:07:29 +0000 (16:07 +0200)
committerBot Blink <blinkbot@samsung.com>
Mon, 29 May 2023 13:46:35 +0000 (13:46 +0000)
[Issue]
Memory increase when MediaStream video track is being rendered

[Cause]
When draw is throttled in cc::scheduler, scheduler is somehow
looped in triggering new deadlines for frame until CompositorFrameAck
is received. But, as there are multiple DidNotProduceFrame messages
also send, they might delay submission of compositor frame.
If so, CompositorFrameAck is also delayed which in return
just increases number of DidNotProduceFrame messages.
Main thread is not capable of processing them all. That's
the cause of memory increase - messages buffering. When video
rendering is suspended and buffered messages are processed,
memory returns to its normal value.

[Solution]
As we have custom implementation of CompositorFrameSink with
DidNotProduceFrame handler that is doing nothing, we can skip
posting mojo IPC message from renderer to browser.

Bug: https://cam.sprc.samsung.pl/browse/VDGAME-279
Change-Id: I39f9fc1201240705a3fe4eafc9488ca75f0343d3
Signed-off-by: Jakub Gajownik <j.gajownik2@samsung.com>
cc/mojo_embedder/async_layer_tree_frame_sink.cc
content/browser/renderer_host/render_widget_host_impl.cc

index 55ed234e582da8caddd9fbd0e7657218ebcc273c..a8e28dd9d7880f9da12c41f904e26c00f70f014d 100644 (file)
@@ -290,7 +290,12 @@ void AsyncLayerTreeFrameSink::DidNotProduceFrame(const viz::BeginFrameAck& ack,
   bool frame_completed = reason == FrameSkippedReason::kNoDamage;
   bool waiting_on_main = reason == FrameSkippedReason::kWaitingOnMain;
   power_mode_voter_.OnFrameSkipped(frame_completed, waiting_on_main);
+#if !defined(USE_EFL)
+  // DidNotProduceFrame is not implemented in browser side
+  // (RenderWidgetHostImpl). So there is no sense in blocking mojo IPC
+  // with messages that have no effect.
   compositor_frame_sink_ptr_->DidNotProduceFrame(ack);
+#endif
 }
 
 void AsyncLayerTreeFrameSink::DidAllocateSharedBitmap(
index 62faa0ea00bd4e12a6db9430ba71e2e3c04a02d7..f043d09858ff3565b506102bcef2e364871ced0c 100644 (file)
@@ -3916,7 +3916,10 @@ void RenderWidgetHostImpl::SubmitCompositorFrameSync(
     uint64_t submit_time,
     const SubmitCompositorFrameSyncCallback callback) {}
 
-void RenderWidgetHostImpl::DidNotProduceFrame(const viz::BeginFrameAck& ack) {}
+void RenderWidgetHostImpl::DidNotProduceFrame(const viz::BeginFrameAck& ack) {
+  // In case any implementation lands here, see related comment in
+  // AsyncLayerTreeFrameSink::DidNotProduceFrame.
+}
 
 void RenderWidgetHostImpl::DidAllocateSharedBitmap(
     base::ReadOnlySharedMemoryRegion region,