New issue
Advanced search Search tips

Issue 695011 link

Starred by 2 users

Issue metadata

Status: Assigned
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Android
Pri: 3
Type: Feature

Blocking:
issue 695006



Sign in to add a comment

Eliminate ContentViewCore.java's direct access to GamepadList.java

Project Member Reported by blundell@chromium.org, Feb 22 2017

Issue description

ContentViewCore.java has numerous synchronous callouts to GamepadList.java, which is in //device/gamepad. One thing it does is pass in a Context. It also gives input events to GamepadList to decide whether to eat or not. These dependencies need to be eliminated before the Gamepad Mojo interfaces can be switched to being hosted by the Device Service, as they effectively mean that part of the Gamepad implementation resides in //content on Android.
 
Components: Blink>GamepadAPI
Labels: -Pri-2 Pri-3
Labels: -Type-Bug OS-All Type-Feature
Owner: mattreynolds@chromium.org
Status: Started (was: Available)
I think we can remove this dependency if we make GamepadDataFetcher an async mojo interface.  ContentViewCore would have its own GamepadDataFetcher implementation that only depends on the public interface.


ContentViewCore uses five GamepadList methods:

isGamepadAPIActive

Returns true if the Gamepad API is active. The API is paused when there are no active gamepad consumers. The event initially comes from GamepadService, which then asks the GamepadProvider to call PauseHint on all its GamepadDataFetchers on the polling thread. With a GamepadDataFetcher mojo interface, ContentViewCore could implement its own GamepadDataFetcher to receive the PauseHint event directly instead of through JNI.

dispatchKeyEvent and onGenericMotionEvent

These methods handle gamepad button and axis events. ContentViewCore's GamepadDataFetcher should update its gamepad state and store the state in a shared memory buffer. The buffer should use the mojo Gamepad struct type instead of GamepadDevice. GamepadProvider would poll this buffer instead of calling fetcher->GetGamepadData synchronously.

onAttachedToWindow and onDetachedFromWindow

These are called when the ContentViewCore is attached to/detached from a window, initializing/clearing the GamepadDevice buffers and (un)registering the InputDevice listener. Neither requires communicating with the GamepadService.

There's also the issue of GamepadMappings.java. Currently, the GamepadDataFetcher is responsible for choosing the appropriate mapping. If the fetcher is now a client interface to the device service, it would make more sense for the mapping to be handled internally. To make this possible, the fetcher would also include the VID/PID pair when reporting the gamepad state to the provider, and the provider would be responsible for choosing the mapping function.
Labels: -OS-All OS-Android
Cc: bajones@chromium.org
The proposed design seems promising to me, I'm not qualified to comment on it in detail. I think bajones@ is likely the right person? 
Cc: reillyg@chromium.org
Discussed this with reillyg@, he suggested that we not add another mojo interface between gamepad events and the renderer. Instead, we should try to find a way to get the button and axis events independently of the ContentView. Currently we rely on ContentView for its View callbacks, but it might be possible to get the gamepad events from another source.

Comment 7 by scheib@chromium.org, May 31 2017

Status: Available (was: Started)
Components: Internals>Services>Device
Status: Assigned (was: Available)

Sign in to add a comment