New issue
Advanced search Search tips

Issue 770547 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Mac
Pri: 2
Type: Bug-Regression

Blocking:
issue 671916



Sign in to add a comment

[MacViewsBrowser] Broken WebViewInteractiveTests/WebViewInteractiveTest.EditCommands/0

Reported by yama...@yandex-team.ru, Oct 1 2017

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.113 YaBrowser/17.9.0.2083 Yowser/2.5 Safari/537.36

Steps to reproduce the problem:
1.  Run  WebViewInteractiveTests/WebViewInteractiveTest.EditCommands/0 on MacViewsBrowse

What is the expected behavior?

What went wrong?
After "GetLastKeyboardEvent API from InputRouter" refactoring:
https://chromium-review.googlesource.com/c/chromium/src/+/577950
NSEvent lost NSWindow, and it can not be more handled by UnhandledKeyboardEventHandler.

So, on MacViewsBrowser, system hotkeys (cmd +C and other) no more works in webview (https://developer.chrome.com/apps/tags/webview)

Did this work before? Yes 

Chrome version: 60.0.3112.113  Channel: n/a
OS Version: OS X 10.12.4
Flash Version: Shockwave Flash 27.0 r0
 
Components: -UI Internals>Views>Desktop
Labels: Proj-MacViews
Blocking: 671916
Cc: tapted@chromium.org dtapu...@chromium.org
Status: Started (was: Unconfirmed)
Confirmed EditCommands/0 was working in

https://uberchromegw.corp.google.com/i/chromium.fyi/builders/Chromium%20Mac%2010.10%20MacViews/builds/26830

and regressed in

https://uberchromegw.corp.google.com/i/chromium.fyi/builders/Chromium%20Mac%2010.10%20MacViews/builds/26831

along with a few others. Failures went from 48 to 51:

+WebViewInteractiveTests/WebViewFocusInteractiveTest.FocusAndVisibility/1
+WebViewInteractiveTests/WebViewInteractiveTest.EditCommands/0
+WebViewInteractiveTests/WebViewInteractiveTest.TextSelection/1


Owner: tapted@chromium.org
confirmed that on the Cocoa build, when EditCommands/0 runs, it's throwing out the event each time and recreating it in -[CommandDispatcher redispatchKeyEvent] using the fullscreen transition fallback path. Stack is

5   libui_base.dylib                    0x00000001251d43b6 -[CommandDispatcher redispatchKeyEvent:] + 854
6   interactive_ui_tests                0x0000000110a5401d -[ChromeEventProcessingWindow redispatchKeyEvent:] + 61
7   interactive_ui_tests                0x000000011098dba0 NativeAppWindowCocoa::HandleKeyboardEvent(content::NativeWebKeyboardEvent const&) + 96
8   interactive_ui_tests                0x0000000108cd6bff extensions::AppWindow::HandleKeyboardEvent(content::WebContents*, content::NativeWebKeyboardEvent const&) + 159
9   interactive_ui_tests                0x000000010e8d75ca guest_view::GuestViewBase::HandleKeyboardEvent(content::WebContents*, content::NativeWebKeyboardEvent const&) + 122
10  interactive_ui_tests                0x0000000108e9fb7e extensions::WebViewGuest::HandleKeyboardEvent(content::WebContents*, content::NativeWebKeyboardEvent const&) + 78
11  libcontent.dylib                    0x000000012e641c37 content::WebContentsImpl::HandleKeyboardEvent(content::NativeWebKeyboardEvent const&) + 199
12  libcontent.dylib                    0x000000012e1900d5 content::RenderWidgetHostImpl::OnKeyboardEventAck(content::EventWithLatencyInfo<content::NativeWebKeyboardEvent> const&, content::InputEventAckState) + 373
13  libcontent.dylib                    0x000000012def4931 content::InputRouterImpl::KeyboardEventHandled(content::EventWithLatencyInfo<content::NativeWebKeyboardEvent> const&, content::InputEventAckSource, ui::LatencyInfo const&, content::InputEventAckState, base::Optional<ui::DidOverscrollParams> const&, base::Optional<cc::TouchAction> const&) + 545
+

(on mac_views_browser, the stack never gets to CommandDispatcher since that path relies on looking up the CommandDispather from the event window).


For guest views, the NSEvent is null when the event is sent (both Cocoa and mac_views_browser)

6   libcontent.dylib                    0x000000012aee5d43 content::InputRouterImpl::SendKeyboardEvent(content::EventWithLatencyInfo<content::NativeWebKeyboardEvent> const&) + 67
7   libcontent.dylib                    0x000000012b178573 content::RenderWidgetHostImpl::ForwardKeyboardEventWithCommands(content::NativeWebKeyboardEvent const&, ui::LatencyInfo const&, std::__1::vector<content::EditCommand, std::__1::allocator<content::EditCommand> > const*, bool*) + 1539
8   libcontent.dylib                    0x000000012b177f61 content::RenderWidgetHostImpl::ForwardKeyboardEventWithLatencyInfo(content::NativeWebKeyboardEvent const&, ui::LatencyInfo const&) + 49
9   libcontent.dylib                    0x000000012b177ee2 content::RenderWidgetHostImpl::ForwardKeyboardEvent(content::NativeWebKeyboardEvent const&) + 130
10  libcontent.dylib                    0x000000012a93e6b2 content::RenderWidgetHostViewGuest::OnHandleInputEvent(content::RenderWidgetHostImpl*, int, blink::WebInputEvent const*) + 1234
11  libcontent.dylib                    0x000000012a941643 void IPC::DispatchToMethodImpl<content::RenderWidgetHostViewGuest, void (content::RenderWidgetHostViewGuest::*)(content::RenderWidgetHostImpl*, int, blink::WebInputEvent const*), content::RenderWidgetHostImpl, std::__1::tuple<int, blink::WebInputEvent const*>, 0ul, 1ul>(content::RenderWidgetHostViewGuest*, void (content::RenderWidgetHostViewGuest::*)(content::RenderWidgetHostImpl*, int, blink::WebInputEvent const*), content::RenderWidgetHostImpl*, std::__1::tuple<int, blink::WebInputEvent const*>&&, std::__1::integer_sequence<unsigned long, 0ul, 1ul>) + 211
12  libcontent.dylib                    0x000000012a941560 std::__1::enable_if<(sizeof...(int, blink::WebInputEvent const*)) == (std::tuple_size<std::__1::decay<std::__1::tuple<int, blink::WebInputEvent const*> >::type>::value), void>::type IPC::DispatchToMethod<content::RenderWidgetHostViewGuest, content::RenderWidgetHostImpl, int, blink::WebInputEvent const*, std::__1::tuple<int, blink::WebInputEvent const*> >(content::RenderWidgetHostViewGuest*, void (content::RenderWidgetHostViewGuest::*)(content::RenderWidgetHostImpl*, int, blink::WebInputEvent const*), content::RenderWidgetHostImpl*, std::__1::tuple<int, blink::WebInputEvent const*>&&) + 112
13  libcontent.dylib                    0x000000012a93e16c bool IPC::MessageT<BrowserPluginHostMsg_HandleInputEvent_Meta, std::__1::tuple<int, blink::WebInputEvent const*>, void>::Dispatch<content::RenderWidgetHostViewGuest, content::RenderWidgetHostViewGuest, content::RenderWidgetHostImpl, void (content::RenderWidgetHostViewGuest::*)(content::RenderWidgetHostImpl*, int, blink::WebInputEvent const*)>(IPC::Message const*, content::RenderWidgetHostViewGuest*, content::RenderWidgetHostViewGuest*, content::RenderWidgetHostImpl*, void (content::RenderWidgetHostViewGuest::*)(content::RenderWidgetHostImpl*, int, blink::WebInputEvent const*)) + 524
14  libcontent.dylib                    0x000000012a93df2c content::RenderWidgetHostViewGuest::OnMessageReceivedFromEmbedder(IPC::Message const&, content::RenderWidgetHostImpl*) + 124
15  libcontent.dylib                    0x000000012a211689 content::BrowserPluginGuest::OnMessageReceivedFromEmbedder(IPC::Message const&) + 153
16  libcontent.dylib                    0x000000012a22367f content::BrowserPluginMessageFilter::ForwardMessageToGuest(IPC::Message const&) + 687
17  libcontent.dylib                    0x000000012a2233ae content::BrowserPluginMessageFilter::OnMessageReceived(IPC::Message const&) + 62
18  libcontent.dylib                    0x00000001289aee4c content::BrowserMessageFilter::Internal::DispatchMessage(IPC::Message const&) + 108


That is, for regular WebContents, a non-null NSEvent is able to survive the SendKeyboardEvent -> KeyboardEventHandled round trip. But for guest views, the event is already null by the time it gets to SendKeyboardEvent. I guess because it bounces off a blink::WebInputEvent.

Passing GetNativeView() to the NativeWebKeyboardEvent constructor in RenderWidgetHostViewGuest::OnHandleInputEvent() allows the NSWindow to be included, and I've confirmed that stops the event getting discarded and recreated in -[CommandDispatcher redispatchKeyEvent] for Cocoa guest views.

Change that does that is here: https://chromium-review.googlesource.com/#/c/chromium/src/+/700174
Project Member

Comment 5 by bugdroid1@chromium.org, Oct 5 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/f8a0c12d86a0c33342a669dc93406204e01a99bc

commit f8a0c12d86a0c33342a669dc93406204e01a99bc
Author: Trent Apted <tapted@chromium.org>
Date: Thu Oct 05 00:03:29 2017

Include the NSWindow on events synthesized from blink::WebInputEvent for guest views

RenderWidgetHostViewGuest started generating synthetic keyboard NSEvents
from blink::WebInputEvent in r489154. These events didn't include an
NSWindow which meant that a fallback path was triggered in
-[CommandDispatcher redispatchKeyEvent] which caused a second NSEvent to
be synthesized, to add the NSWindow back on.

This "worked" for Cocoa (NativeAppWindowCocoa), but not for views-
backed guest views, causing WebViewInteractiveTest.EditCommands/0 to
regress and WebViewInteractiveTest.TextSelection/1 to time out.

Fix those by passing GetNativeView() to the NativeWebKeyboardEvent
constructor in RenderWidgetHostViewGuest::OnHandleInputEvent(). This
also avoids triggering the fallback path in CommandDispatcher, so only
one synthetic NSEvent is created.

Bug:  770547 
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_site_isolation
Change-Id: I50ded74f7563f755dd6d735750437bbbafff39e2
Reviewed-on: https://chromium-review.googlesource.com/700174
Reviewed-by: Dave Tapuska <dtapuska@chromium.org>
Reviewed-by: Avi Drissman <avi@chromium.org>
Commit-Queue: Avi Drissman <avi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#506575}
[modify] https://crrev.com/f8a0c12d86a0c33342a669dc93406204e01a99bc/content/browser/frame_host/render_widget_host_view_guest.cc
[modify] https://crrev.com/f8a0c12d86a0c33342a669dc93406204e01a99bc/content/browser/renderer_host/native_web_keyboard_event_android.cc
[modify] https://crrev.com/f8a0c12d86a0c33342a669dc93406204e01a99bc/content/browser/renderer_host/native_web_keyboard_event_aura.cc
[modify] https://crrev.com/f8a0c12d86a0c33342a669dc93406204e01a99bc/content/browser/renderer_host/native_web_keyboard_event_mac.mm
[modify] https://crrev.com/f8a0c12d86a0c33342a669dc93406204e01a99bc/content/public/browser/native_web_keyboard_event.h

Status: Fixed (was: Started)
EditCommands/0 cycled green in https://uberchromegw.corp.google.com/i/chromium.fyi/builders/Chromium%20Mac%2010.10%20MacViews/builds/27783

The others that appeared in #c3 are also passing, but they also were not failing in the cycle beforehand.

Overall, interactive_ui_tests is down to 35 failures (down from 48 before #c3).

Sign in to add a comment