Project: chromium Issues People Development process History Sign in
New issue
Advanced search Search tips
Starred by 3 users
Status: Fixed
Owner:
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocked on:
issue 676131
issue 685426

Blocking:
issue 563816



Sign in to add a comment
Use the BeginFrame signal to drive OffscreenCanvas animations.
Project Member Reported by junov@chromium.org, Dec 15 2016 Back to list
I am attempting to use OffscreenCanvasFrameDispatcherImpl::OnBeginFrame
to drive OffscreenCanvas animations in workers.  Unfortunately, this method is currently never called.


If I understand the code correctly, The key to fixing this is in the constructor of OffscreenCanvasCompositorFrameSink.  It currently passes a nullptr as the "display" argument to the CompositorFrameSinkSupport constructor.  A display seems to be required for driving BeginFrame events.

I attempted to create or retrieve a cc:Display object in OffscreenCanvasCompositorFrameSink::Create, but this seems to be a highly non-trivial thing (at least for someone unfamiliar with this area)


 
Comment 1 by junov@chromium.org, Dec 15 2016
FWIW: For now, I can workaround the issue by hacking something around ReclaimResources as a signal that the pipeline has advanced.  But this will not properly align with vsync. :-(
What needs to be done is to add the OffscreenCanvasCompositorFrameSink to the BeginFrame hierarchy via AddChildSink...I'll explain further later tonight.
Actually, I'm looking again at this: in a nutshell you need to call SurfaceManager::RegisterFrameSinkHierarchy(top level page's FrameSinkId, canvas' FrameSinkId) in the display compositor (in the browser).

In this patch: https://codereview.chromium.org/2584643002/patch/100001/110024

CanvasSurfaceLayerBridge gets a FrameSinkId. One solution is to plumb that newly created FrameSinkId back through content. Perhaps we can expose the Renderer interface in Blink or some place? There could be a Renderer::AddChildFrameSink(and pass in the canvas FrameSinkId). That will cause BeginFrames to be pumped at the same rate they're pumped to the main thread.

We can chat more about details tomorrow.
Comment 4 by junov@chromium.org, Dec 16 2016
Thanks for the tips.

I just want to make sure what it means for "BeginFrames to be pumped at the same rate they're pumped to the main thread". The BeginFrame signal will be dispatched to the OffscreenCanvasCompositorFrameSink without interruption, even if the main frame is busy and unable to produce frames for a period of time, right? 

Just making sure because this is sort of the whole point of OffscreenCanvas.
Ohh yea, absolutely. What I mean is the display compositor will send BeginFrame IPCs to the canvas along with the main page. The main page can be slow, but the beginframes will be sent regardless. The beginframes will be sent from either the browser or mus and won't be throttled by the main page.
Comment 6 by junov@chromium.org, Dec 16 2016
Owner: junov@chromium.org
Status: Started
Comment 7 by junov@chromium.org, Dec 20 2016
Blockedon: 676131
Blocking: 563816
Comment 8 by junov@chromium.org, Jan 16 2017
Cc: junov@chromium.org
Owner: xlai@chromium.org
Comment 9 by xlai@chromium.org, Jan 25 2017
Blockedon: 685426
Project Member Comment 10 by bugdroid1@chromium.org, Jan 28 2017
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d0df339711fb34c94decb02ac90e0d9fddc1e8d1

commit d0df339711fb34c94decb02ac90e0d9fddc1e8d1
Author: xlai <xlai@chromium.org>
Date: Sat Jan 28 03:24:49 2017

Make OffscreenCanvas animation in sync with its placeholder canvas's parent frame rate

This CL makes OffscreenCanvasFrameDispatcherImpl::OnBeginFrame get fired when
the OffscreenCanvas's corresponding placeholder canvas's parent frame is
starting a new frame. In this way, we make sure that OffscreenCanvas animation
matches the frame rate of display, which is part of the spec requirement in
OffscreenCanvas
(https://wiki.whatwg.org/wiki/OffscreenCanvas.requestAnimationFrame).

Implementation in this CL can be broadly seen as two parts:

1. Registration of OffscreenCanvas's frame sink id to the FrameSinkHierarchy of
its parent frame's frame sink id. The parent frame sink id is obtained by
plumbing into WebLayerTreeView from HTMLCanvasElement; it is then sent to
OffscreenCanvasSurfaceImpl and cached there. When
OffscreenCanvasCompositorFrameSink is created (together with the support_), we
then register this parent-child hierarchy to SurfaceManager.

2. OffscreenCanvas signals that it needs BeginFrame when users invoke commit().
This allows OffscreenCanvas.beginFrame() to be triggered to either resolve an
existing promise and doCommit on the last overdraw compositorFrame sent by the
user in the same frame window. When a promise is resolved, OffscreenCanvas
signals that it no longer needs BeginFrame, so as to avoid overhead from its
parent frame.

BUG= 674744 
CQ_INCLUDE_TRYBOTS=master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel;master.tryserver.chromium.android:android_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2644653003
Cr-Commit-Position: refs/heads/master@{#446898}

[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink.cc
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_provider_impl.cc
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_compositor_frame_sink_provider_impl.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_surface_factory_impl.cc
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_surface_factory_impl.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_surface_impl.cc
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_surface_impl.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_surface_manager.cc
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_surface_manager.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/browser/renderer_host/offscreen_canvas_surface_manager_unittest.cc
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/renderer/gpu/render_widget_compositor.cc
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/renderer/gpu/render_widget_compositor.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/test/data/gpu/pixel_offscreenCanvas_2d_commit_main.html
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/test/data/gpu/pixel_offscreenCanvas_2d_commit_worker.html
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/test/data/gpu/pixel_offscreenCanvas_webgl_commit_main.html
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/content/test/data/gpu/pixel_offscreenCanvas_webgl_commit_worker.html
[add] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/LayoutTests/fast/canvas/OffscreenCanvas-commit-frameless-doc.html
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/core/html/HTMLCanvasElement.cpp
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/core/offscreencanvas/OffscreenCanvas.cpp
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/core/page/ChromeClient.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.cpp
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridge.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcher.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/web/ChromeClientImpl.cpp
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/Source/web/ChromeClientImpl.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/public/platform/WebLayerTreeView.h
[modify] https://crrev.com/d0df339711fb34c94decb02ac90e0d9fddc1e8d1/third_party/WebKit/public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom

Comment 11 by xlai@chromium.org, Jan 31 2017
Status: Fixed
Sign in to add a comment