Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(368)

Issue 13844021: Move compositor thread input handling logic into content (Closed)

Created:
7 years, 7 months ago by jamesr
Modified:
7 years, 7 months ago
Reviewers:
danakj, piman, jamesr1
CC:
chromium-reviews, joi+watch-content_chromium.org, darin-cc_chromium.org, jam, apatrick_chromium, jdduke (slow), michaelbai
Visibility:
Public.

Description

The moves the compositor thread's input event cracking logic in to content/ from Blink. This significantly decreases the amount of plumbing involved with setting up and tearing down the input filtering and makes it easier to extend without having to go through API rolls. The startup sequence is as follows, all in the render process: 1.) [main thread] Compositor initialized in content::RenderWidgetCompositor::Create(). During initialization, cc::LayerTreeHost grabs a base::WeakPtr<cc::InputHandler> bounds to the compositor thread. The cc::InputHandler interface is implemented by cc::LayerTreeHostImpl. 2.) [main thread] RenderViewImpl::didActivateCompositor() grabs a WeakPtr to itself and a WeakPtr<cc::InputHandler> from the RenderWidgetCompositor and calls InputHandlerManager::AddInputHandler() 2.) [main thread] InputHandlerManager grabs a WeakPtr<> to its MessageLoopProxy posts a task to itself on the compositor thread to AddInputHandlerOnCompositorThread() 3.) [compositor thread] InputHandlerManager::AddInputHandlerOnCompositorThread() checks if the WeakPtr<cc::InputHandler> is still valid. If the WeakPtr has been invalidated or there's already an entry for this routing_id, it bails. Otherwise InputHandlerManager adds the new routing_id to the filter (which takes a lock on the [ipc thread]) and constructs a new InputHandlerWrapper and adds it to its input_handlers_ map 4.) [compositor thread] InputHandlerWrapper constructs a new InputHandlerClientImpl 5.) [compositor thread] InputHandlerProxy binds itself as the client for the cc::InputHandler After this completes successfully, the cc::LayerTreeHostImpl has a weak (raw) pointer to the cc::InputHandlerClient, which is the content::InputHandlerProxy, and the InputHandlerProxy has a weak (raw) ptr to the cc::InputHandler, which is the cc::LayerTreeHostImpl. The flow for incoming IPCs is thus: 1.) [ipc thread] IPC message arrives and is dispatched at all IPC filters. 2.) [ipc thread] InputEventFilter::OnMessageReceived checks if the message is an InputMsg_ type. If so, it takes a lock on routes_ and checks if the IPC is intended for a routing_id with filtering. If so, it posts the message to the InputHandlerManager (via ForwardToHandler). If any of these checks fail, the filter rejects the message (returns false) and the IPC goes down the normal handling path which routes it to the main thread. 3.) [compositor thread] InputHandlerManager::HandleInputEvent() looks for an entry in its input_handlers_ map matching the message's routing_id. If there is one, it calls InputHandlerProxy::HandleInputEvent(). If there isn't, it sends the input event to the main thread. 4.) [compositor thread] InputHandlerProxy::HandleInputEvent() examines the fields on the input event and determines what set of logical scroll/pinch/whatnots should occur as a result of the event. To do this, it communicates with the compositor via the cc::InputHandler. After it has determined the disposition of the event, it returns a status to its embedder via the content::InputHandlerProxyClient interface (which is the content::InputHandlerWrapper). 5.) [compositor thread] content::InputHandlerWrapper forwards the event disposition back to the InputEventFilter, which can forward the message to the main thread or send an ACK as appropriate. Shutdown: 1.) [compositor thread] ~cc::LayerTreeHostImpl() calls WillShutdown() its input_handler_client_, which is a content::InputHandlerProxy 2.) [compositor thread] content::InputHandlerProxy::WillShutdown() calls client_->WillShutdown() 3.) [compositor thread] content::InputHandlerWrapper::WillShutdown() calls input_handler_manager_->RemoveInputHandler() for its routing_id 4.) [compositor thread] content::InputHandlerManager::RemoveInputHandler() calls filters_->RemoveRoute(), which takes a lock on the InputEventFilter's routing table and removes the id, then erases the matching input_handlers_ entry which derefs the InputHandlerWrapper After step 4 no more messages will be posted from the ipc thread to the compositor thread for the given routing id, but of course any number of tasks may already be posted. When these tasks run InputHandlerManager::HandleInputEvent() will find no matching entries in the input_handlers_ map and will send the messages back to the main thread. BUG=236096 Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=201016

Patch Set 1 #

Patch Set 2 : #

Patch Set 3 : wip #

Patch Set 4 : it\'s alive\! #

Patch Set 5 : #

Total comments: 30

Patch Set 6 : addresses most feedback #

Patch Set 7 : fix shutdown #

Patch Set 8 : fix comments around dcheck #

Patch Set 9 : 55% more compilation #

Patch Set 10 : fix win component build #

Total comments: 14

Patch Set 11 : fix up ownership and comments #

Patch Set 12 : patch in blink changes to WebCompositorInputHandlerImpl* #

Total comments: 8

Patch Set 13 : address feedback #

Total comments: 2

Patch Set 14 : moar dcheck #

Patch Set 15 : rebased #

Patch Set 16 : fix browser_tests #

Patch Set 17 : rebased #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1866 lines, -501 lines) Patch
M cc/input/input_handler.h View 1 2 3 4 5 6 7 8 9 10 3 chunks +20 lines, -15 lines 0 comments Download
M cc/test/fake_layer_tree_host_client.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +0 lines, -1 line 0 comments Download
M cc/test/fake_layer_tree_host_client.cc View 1 2 3 1 chunk +0 lines, -5 lines 0 comments Download
M cc/test/layer_tree_test.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +0 lines, -4 lines 0 comments Download
M cc/trees/layer_tree_host.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 4 chunks +5 lines, -1 line 0 comments Download
M cc/trees/layer_tree_host.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 2 chunks +1 line, -4 lines 0 comments Download
M cc/trees/layer_tree_host_client.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +0 lines, -1 line 0 comments Download
M cc/trees/layer_tree_host_impl.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 4 chunks +10 lines, -5 lines 0 comments Download
M cc/trees/layer_tree_host_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5 chunks +18 lines, -0 lines 0 comments Download
M cc/trees/layer_tree_host_unittest_scroll.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 22 chunks +95 lines, -146 lines 0 comments Download
M cc/trees/thread_proxy.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +1 line, -4 lines 0 comments Download
M cc/trees/thread_proxy.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 6 chunks +3 lines, -19 lines 0 comments Download
M content/browser/renderer_host/compositor_impl_android.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +0 lines, -2 lines 0 comments Download
M content/browser/renderer_host/compositor_impl_android.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +0 lines, -4 lines 0 comments Download
M content/content_renderer.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +4 lines, -0 lines 0 comments Download
M content/content_tests.gypi View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +1 line, -0 lines 0 comments Download
M content/renderer/gpu/input_handler_manager.h View 1 2 3 4 5 6 7 8 9 10 4 chunks +15 lines, -10 lines 0 comments Download
M content/renderer/gpu/input_handler_manager.cc View 1 2 3 4 5 6 7 8 4 chunks +12 lines, -82 lines 0 comments Download
A content/renderer/gpu/input_handler_proxy.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +92 lines, -0 lines 0 comments Download
A content/renderer/gpu/input_handler_proxy.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +406 lines, -0 lines 0 comments Download
A content/renderer/gpu/input_handler_proxy_client.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +53 lines, -0 lines 0 comments Download
A content/renderer/gpu/input_handler_proxy_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +995 lines, -0 lines 0 comments Download
A content/renderer/gpu/input_handler_wrapper.h View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +59 lines, -0 lines 0 comments Download
A content/renderer/gpu/input_handler_wrapper.cc View 1 2 3 4 5 6 7 8 1 chunk +60 lines, -0 lines 0 comments Download
M content/renderer/gpu/render_widget_compositor.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 5 chunks +4 lines, -3 lines 0 comments Download
M content/renderer/gpu/render_widget_compositor.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 4 chunks +6 lines, -11 lines 0 comments Download
M content/renderer/render_view_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1 chunk +6 lines, -3 lines 0 comments Download
M ui/compositor/compositor.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +0 lines, -2 lines 0 comments Download
M ui/compositor/compositor.cc View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +0 lines, -4 lines 0 comments Download
M webkit/renderer/compositor_bindings/compositor_bindings.gyp View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +0 lines, -2 lines 0 comments Download
M webkit/renderer/compositor_bindings/web_layer_tree_view_impl_for_testing.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +0 lines, -2 lines 0 comments Download
M webkit/renderer/compositor_bindings/web_layer_tree_view_impl_for_testing.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 2 chunks +0 lines, -8 lines 0 comments Download
D webkit/renderer/compositor_bindings/web_to_ccinput_handler_adapter.h View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +0 lines, -39 lines 0 comments Download
D webkit/renderer/compositor_bindings/web_to_ccinput_handler_adapter.cc View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 1 chunk +0 lines, -124 lines 0 comments Download

Messages

Total messages: 28 (0 generated)
jamesr
Dana and/or Enne, would one of y'all like to take a look? I've put a ...
7 years, 7 months ago (2013-05-01 01:58:00 UTC) #1
danakj
Can Animate() or MainThreadHasStoppedFlinging() happen in the LTHI before the InputHandlerClient has had a chance ...
7 years, 7 months ago (2013-05-01 19:20:43 UTC) #2
danakj
https://codereview.chromium.org/13844021/diff/11001/content/renderer/gpu/input_handler_manager.cc File content/renderer/gpu/input_handler_manager.cc (right): https://codereview.chromium.org/13844021/diff/11001/content/renderer/gpu/input_handler_manager.cc#newcode125 content/renderer/gpu/input_handler_manager.cc:125: it->second->input_handler()->HandleInputEvent(*input_event); This will be null deref once the LTHI ...
7 years, 7 months ago (2013-05-01 19:39:04 UTC) #3
jamesr
On 2013/05/01 19:20:43, danakj wrote: > Can Animate() or MainThreadHasStoppedFlinging() happen in the LTHI before ...
7 years, 7 months ago (2013-05-01 21:50:56 UTC) #4
jamesr
On 2013/05/01 19:39:04, danakj wrote: > https://codereview.chromium.org/13844021/diff/11001/content/renderer/gpu/input_handler_manager.cc > File content/renderer/gpu/input_handler_manager.cc (right): > > https://codereview.chromium.org/13844021/diff/11001/content/renderer/gpu/input_handler_manager.cc#newcode125 > ...
7 years, 7 months ago (2013-05-01 21:53:20 UTC) #5
jamesr
OK, ready for another look. I've fixed up the shutdown path and summarized it in ...
7 years, 7 months ago (2013-05-03 03:35:59 UTC) #6
danakj
https://codereview.chromium.org/13844021/diff/41001/cc/trees/layer_tree_host_impl.cc File cc/trees/layer_tree_host_impl.cc (right): https://codereview.chromium.org/13844021/diff/41001/cc/trees/layer_tree_host_impl.cc#newcode1478 cc/trees/layer_tree_host_impl.cc:1478: void LayerTreeHostImpl::BindToClient(InputHandlerClient* client) { If this is going to ...
7 years, 7 months ago (2013-05-06 16:33:38 UTC) #7
jamesr
OK! I think I've sorted the client ownership. How it works now: cc::InputHandler only has ...
7 years, 7 months ago (2013-05-10 04:08:16 UTC) #8
jamesr
ping?
7 years, 7 months ago (2013-05-14 06:57:46 UTC) #9
danakj
LGTM https://codereview.chromium.org/13844021/diff/56001/content/renderer/gpu/input_handler_proxy.cc File content/renderer/gpu/input_handler_proxy.cc (right): https://codereview.chromium.org/13844021/diff/56001/content/renderer/gpu/input_handler_proxy.cc#newcode79 content/renderer/gpu/input_handler_proxy.cc:79: // thread, to punt it to the main ...
7 years, 7 months ago (2013-05-15 19:21:51 UTC) #10
piman
I think it all works, I mostly have suggestions about how to maybe simplify a ...
7 years, 7 months ago (2013-05-15 21:51:03 UTC) #11
jamesr
On 2013/05/15 21:51:03, piman wrote: > I think it all works, I mostly have suggestions ...
7 years, 7 months ago (2013-05-16 23:48:42 UTC) #12
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/13844021/73001
7 years, 7 months ago (2013-05-16 23:49:50 UTC) #13
commit-bot: I haz the power
Failed to apply patch for content/renderer/gpu/render_widget_compositor.cc: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file ...
7 years, 7 months ago (2013-05-16 23:50:01 UTC) #14
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/13844021/77001
7 years, 7 months ago (2013-05-17 00:00:36 UTC) #15
commit-bot: I haz the power
Retried try job too often on chromium_presubmit for step(s) presubmit http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=chromium_presubmit&number=3437
7 years, 7 months ago (2013-05-17 00:12:12 UTC) #16
piman
LGTM On 2013/05/16 23:48:42, jamesr wrote: > On 2013/05/15 21:51:03, piman wrote: > > I ...
7 years, 7 months ago (2013-05-17 00:48:27 UTC) #17
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/13844021/77001
7 years, 7 months ago (2013-05-17 02:10:56 UTC) #18
commit-bot: I haz the power
Retried try job too often on linux_chromeos for step(s) browser_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_chromeos&number=115432
7 years, 7 months ago (2013-05-17 05:21:27 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/13844021/77001
7 years, 7 months ago (2013-05-17 05:27:56 UTC) #20
commit-bot: I haz the power
Retried try job too often on linux_chromeos for step(s) browser_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_chromeos&number=115465
7 years, 7 months ago (2013-05-17 07:13:28 UTC) #21
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/13844021/77001
7 years, 7 months ago (2013-05-17 13:33:22 UTC) #22
commit-bot: I haz the power
Retried try job too often on linux_chromeos for step(s) browser_tests http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=linux_chromeos&number=115556
7 years, 7 months ago (2013-05-17 15:32:43 UTC) #23
jamesr1
Failure is legit, not flake. Will investigate today. On May 17, 2013 8:32 AM, <commit-bot@chromium.org> ...
7 years, 7 months ago (2013-05-17 17:47:51 UTC) #24
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/13844021/125001
7 years, 7 months ago (2013-05-17 18:25:19 UTC) #25
commit-bot: I haz the power
Failed to apply patch for cc/trees/layer_tree_host_unittest_scroll.cc: While running patch -p1 --forward --force --no-backup-if-mismatch; patching file ...
7 years, 7 months ago (2013-05-18 00:14:39 UTC) #26
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/jamesr@chromium.org/13844021/149001
7 years, 7 months ago (2013-05-18 22:16:46 UTC) #27
commit-bot: I haz the power
7 years, 7 months ago (2013-05-20 04:34:40 UTC) #28
Message was sent while issue was closed.
Change committed as 201016

Powered by Google App Engine
This is Rietveld 408576698