Commit 8bd17347 authored by Bill Orr's avatar Bill Orr Committed by Commit Bot

Fix some thread cleanup issues that can cause crashes or DCHECKs.

OpenVR and Oculus devices may be destroyed before the render loop is
created.  If this happens we may crash because we call render_loop_->IsRunning().

Next, if we don't call render_loop_->Stop(), the render_loop_'s bindings will be
destroyed on the main thread rather than the render loop thread.

BUG=868072

Cq-Include-Trybots: luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: Ibf12af3c38cfa8ed8edf1aebe431a3606476bba7
Reviewed-on: https://chromium-review.googlesource.com/1151952Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Commit-Queue: Bill Orr <billorr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#578455}
parent 27b66e58
......@@ -105,6 +105,11 @@ OculusDevice::OculusDevice()
OculusDevice::~OculusDevice() {
StopOvrSession();
// Wait for the render loop to stop before completing destruction. This will
// ensure that bindings are closed on the correct thread.
if (render_loop_ && render_loop_->IsRunning())
render_loop_->Stop();
device::GamepadDataFetcherManager::GetInstance()->RemoveSourceFactory(
device::GAMEPAD_SOURCE_OCULUS);
data_fetcher_ = nullptr;
......
......@@ -166,7 +166,7 @@ void OpenVRDevice::Shutdown() {
// Wait for the render loop to stop before completing destruction. This will
// ensure that the IVRSystem doesn't get shutdown until the render loop is no
// longer referencing it.
if (render_loop_->IsRunning())
if (render_loop_ && render_loop_->IsRunning())
render_loop_->Stop();
}
......
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