New issue
Advanced search Search tips

Issue 687992 link

Starred by 3 users

Issue metadata

Status: Verified
Owner:
Closed: Mar 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 1
Type: Bug
Proj-XR



Sign in to add a comment

Make gamepad's use of GVR controller threadsafe

Project Member Reported by mthiesse@chromium.org, Feb 2 2017

Issue description

More context is in  issue 674594 .

The GVR library is not thread safe, and we're required to use it on VR Shell's GL thread (see vr_shell_gl.cc), so the gamepad API must also use it on that thread.
 

Comment 1 by klausw@chromium.org, Mar 20 2017

Cc: klausw@chromium.org
Labels: -Pri-2 M-59 Pri-1
Raising priority since this is actively breaking things:

- open https://webvr.info/samples/XX-vr-controllers.html

- click trackpad

Expected: background color changes due to "click" event
Actual: this click doesn't get delivered

Even worse, this remains broken after exiting this sample and going to a different one that doesn't actively use the gamepad API.

Looks like the core issue is that we're calling controller_state_.Update(*controller_api_) twice, once from gvr_gamepad_data_fetcher.cc and once from vr_shell/vr_controller.cc. Even though these are distinct state objects, seems that this resets the shared backing state used for detecting and reporting transient events for button up/down and touch up/down. That's documented but it wasn't obvious how it affected us:

https://developers.google.com/vr/android/ndk/reference/group/controller#group___controller_1gab8a6264c78567795ee8327a175d565bf

Comment 3 by klausw@chromium.org, Mar 21 2017

Owner: klausw@chromium.org
Status: Started (was: Available)
Project Member

Comment 4 by bugdroid1@chromium.org, Mar 23 2017

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

commit dee8e0a41990efbaec2435faff764baee5b894d9
Author: klausw <klausw@chromium.org>
Date: Thu Mar 23 07:45:11 2017

Refactor GVR controller gamepad API integration

The GVR device code had its own gvr_api instance and controller
state in the UI thread, this was causing conflicts with using
the same APIs from the GL thread in vr_shell_gl. Symptoms included
not getting window click events for touchpad clicks after a WebVR
application used the gamepad API to read a GVR controller, this
broke transient event handling such as button up/down detection.

Instead, poll controllers only once from within VrShellGl, and post
the data to VrShell which acts as a GvrGamepadDataProvider. That
also handles registering/unregistering the gamepad device factory
as needed.

This only works while presenting, but that restriction already existed,
the controller was not functional in magic window mode.

BUG= 687992 

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

[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/chrome/browser/android/vr_shell/vr_controller.cc
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/chrome/browser/android/vr_shell/vr_controller.h
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/chrome/browser/android/vr_shell/vr_shell.cc
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/chrome/browser/android/vr_shell/vr_shell.h
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/chrome/browser/android/vr_shell/vr_shell_delegate.cc
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/chrome/browser/android/vr_shell/vr_shell_gl.cc
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/chrome/browser/android/vr_shell/vr_shell_gl.h
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/device/gamepad/gamepad_provider.cc
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/device/vr/BUILD.gn
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/device/vr/android/gvr/gvr_gamepad_data_fetcher.cc
[modify] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/device/vr/android/gvr/gvr_gamepad_data_fetcher.h
[add] https://crrev.com/dee8e0a41990efbaec2435faff764baee5b894d9/device/vr/android/gvr/gvr_gamepad_data_provider.h

Comment 5 by klausw@chromium.org, Mar 24 2017

Status: Verified (was: Started)
Fixed as of today's 59.0.3050.0 Canary release.
Components: -IO>Gamepad Blink>GamepadAPI
Components: Blink>WebXR

Sign in to add a comment