Commit d7e58ca4 authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

[Windows Host] Fixing a crash related to touch injection

This crash is an odd one as we only have an optimized stack trace and limited
info since it is from a mini dump.  From best I can tell, this crash is due
to a race condition in the start-up path for the desktop process.  In the dump,
I see the other capturers all being initialized on the other threads so this
is very early on.  It occurs because the start and inject methods related to
Touch are run on different threads.  I looked into sorting that out but it is
a bigger refactor than I would like to do at the moment (there are several
classes and three threads to sort out).

This fix ensures that the InputInjectorWin instance always has a valid
TouchInjectorWin object to call into, even if the touch class has not
been initialized yet (it is likely deferred due to the time and the fact
that we need to load a library from disk).

BUG=869990

Change-Id: Ic408c534e8ee71f4aa9e712f5ffb415ff97222c6
Reviewed-on: https://chromium-review.googlesource.com/1159168Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Commit-Queue: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579932}
parent 36f6d05e
......@@ -297,8 +297,8 @@ InputInjectorWin::Core::Core(
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner)
: main_task_runner_(main_task_runner),
ui_task_runner_(ui_task_runner),
clipboard_(Clipboard::Create()) {
}
clipboard_(Clipboard::Create()),
touch_injector_(new TouchInjectorWin()) {}
void InputInjectorWin::Core::InjectClipboardEvent(const ClipboardEvent& event) {
if (!ui_task_runner_->BelongsToCurrentThread()) {
......@@ -361,7 +361,6 @@ void InputInjectorWin::Core::Start(
}
clipboard_->Start(std::move(client_clipboard));
touch_injector_.reset(new TouchInjectorWin());
touch_injector_->Init();
}
......
......@@ -155,15 +155,19 @@ DWORD TouchInjectorWinDelegate::InjectTouchInput(
return inject_touch_input_func_(count, contacts);
}
TouchInjectorWin::TouchInjectorWin()
: delegate_(TouchInjectorWinDelegate::Create()) {}
TouchInjectorWin::TouchInjectorWin() = default;
TouchInjectorWin::~TouchInjectorWin() {}
TouchInjectorWin::~TouchInjectorWin() = default;
// Note that TouchInjectorWinDelegate::Create() is not called in this method
// so that a mock delegate can be injected in tests and set expectations on the
// mock and return value of this method.
bool TouchInjectorWin::Init() {
if (!delegate_)
delegate_ = TouchInjectorWinDelegate::Create();
// If initializing the delegate failed above, then the platform likely doesn't
// support touch (or the libraries failed to load for some reason).
if (!delegate_)
return false;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment