VR Gamepads should be thread-safe |
|
Issue descriptionWe are "mostly" thread-safe currently - we write to a buffer on one thread, and read on another thread. The buffer is constant size, so no risk of crashes, but we could read partway through a write and end up with invalid pose data. The ideal fix would involve posting updated data to the gamepad polling thread, but that isn't yet exposed. Specifically, GvrGamepadDataFetcher::SetGamepadData is called on the UI thread, but GvrGamepadDataFetcher::GetGamepadData is called on the gamepad polling thread with no synchronization of gamepad_data_. We should fix gvr, cardboard, oculus, and openvr to follow the same pattern.
,
Jul 26
Another way is to use lockless mechanism, using OneWriterSeqLock for example.
,
Jul 26
Yes, we could add locking. For desktop though we have to host the APIs outside of the browser process, and GamepadDataFetchers need to live in the browser process - we can use an IPC mechanism like mojo for both desktop and android and get proper synchronization for free (at the potential expense of latency for input data). I'm starting with the mojo route for desktop, and will investigate if this is sufficient or adds too much latency. If it works without issue, I'd be tempted to use it for android as well.
,
Aug 3
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718 commit fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718 Author: Bill Orr <billorr@chromium.org> Date: Fri Aug 03 04:40:23 2018 Support running Oculus gamepads out of the browser process Third party code will be blocked in the browser process. We'll need to host VR input outside the browser process. To support that, we need some IPC mechanism to get gamepad data over to the browser process where the device/gamepad service is hosted. For now, we'll host OpenVR gamepad data in the same place we host the OculusRenderLoop. This is not the final shipping location, but adding an IPC mechanism moves us closer to the final architecture. BUG=795510, 860821 Cq-Include-Trybots: luci.chromium.try:win_optional_gpu_tests_rel Change-Id: Ib63489c36e3e08723d9e4f92327fb97aa77597a9 Reviewed-on: https://chromium-review.googlesource.com/1147742 Commit-Queue: Bill Orr <billorr@chromium.org> Reviewed-by: Daniel Cheng <dcheng@chromium.org> Reviewed-by: Klaus Weidner <klausw@chromium.org> Cr-Commit-Position: refs/heads/master@{#580452} [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/BUILD.gn [add] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/isolated_gamepad_data_fetcher.cc [add] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/isolated_gamepad_data_fetcher.h [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/oculus/oculus_device.cc [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/oculus/oculus_device.h [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/oculus/oculus_device_provider.cc [delete] https://crrev.com/fc68244099e90afbf6e2f49d36687d6bca7c28a8/device/vr/oculus/oculus_gamepad_data_fetcher.cc [delete] https://crrev.com/fc68244099e90afbf6e2f49d36687d6bca7c28a8/device/vr/oculus/oculus_gamepad_data_fetcher.h [add] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/oculus/oculus_gamepad_helper.cc [add] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/oculus/oculus_gamepad_helper.h [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/oculus/oculus_render_loop.cc [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/oculus/oculus_render_loop.h [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/public/mojom/BUILD.gn [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/public/mojom/README.md [modify] https://crrev.com/fbfc4209ea7c824fb2eb6c4b14a6117b3cf8a718/device/vr/public/mojom/isolated_xr_service.mojom
,
Aug 3
The following revision refers to this bug: https://chromium.googlesource.com/chromium/src.git/+/d0a84c3c241bc3d6c2967a281475b6d375d438eb commit d0a84c3c241bc3d6c2967a281475b6d375d438eb Author: Bill Orr <billorr@chromium.org> Date: Fri Aug 03 17:14:36 2018 Support running OpenVR gamepads out of the browser process Third party code will be blocked in the browser process. We'll need to host VR input outside the browser process. To support that, we need some IPC mechanism to get gamepad data over to the browser process where the device/gamepad service is hosted. For now, we'll host OpenVR gamepad data in the same place we host the OculusRenderLoop. This is not the final shipping location, but adding an IPC mechanism moves us closer to the final architecture. BUG=795510, 860821 Cq-Include-Trybots: luci.chromium.try:win_optional_gpu_tests_rel Change-Id: I8385d1c4222df9636259743366f64eafbb40fa3a Reviewed-on: https://chromium-review.googlesource.com/1153561 Commit-Queue: Bill Orr <billorr@chromium.org> Reviewed-by: Klaus Weidner <klausw@chromium.org> Cr-Commit-Position: refs/heads/master@{#580578} [modify] https://crrev.com/d0a84c3c241bc3d6c2967a281475b6d375d438eb/device/vr/BUILD.gn [modify] https://crrev.com/d0a84c3c241bc3d6c2967a281475b6d375d438eb/device/vr/openvr/openvr_device.cc [modify] https://crrev.com/d0a84c3c241bc3d6c2967a281475b6d375d438eb/device/vr/openvr/openvr_device.h [modify] https://crrev.com/d0a84c3c241bc3d6c2967a281475b6d375d438eb/device/vr/openvr/openvr_device_provider.cc [delete] https://crrev.com/4bbcb6d9a77ca05e2cb7ab2cb8dde5beb8b3ab25/device/vr/openvr/openvr_gamepad_data_fetcher.cc [delete] https://crrev.com/4bbcb6d9a77ca05e2cb7ab2cb8dde5beb8b3ab25/device/vr/openvr/openvr_gamepad_data_fetcher.h [add] https://crrev.com/d0a84c3c241bc3d6c2967a281475b6d375d438eb/device/vr/openvr/openvr_gamepad_helper.cc [add] https://crrev.com/d0a84c3c241bc3d6c2967a281475b6d375d438eb/device/vr/openvr/openvr_gamepad_helper.h [modify] https://crrev.com/d0a84c3c241bc3d6c2967a281475b6d375d438eb/device/vr/openvr/openvr_render_loop.cc [modify] https://crrev.com/d0a84c3c241bc3d6c2967a281475b6d375d438eb/device/vr/openvr/openvr_render_loop.h |
|
►
Sign in to add a comment |
|
Comment 1 by artyo...@gmail.com
, Jul 26