Skip to content

Commit

Permalink
Bug 1510622 - Initilize OpenVR controller haptic thread when the firs…
Browse files Browse the repository at this point in the history
…t time to do vibration. r=kip

Differential Revision: https://phabricator.services.mozilla.com/D46227

--HG--
extra : moz-landing-system : lando
  • Loading branch information
daoshengmu committed Sep 18, 2019
1 parent b776b14 commit 480100a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gfx/vr/service/OpenVRSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,9 +314,6 @@ bool OpenVRSession::Initialize(mozilla::gfx::VRSystemState& aSystemState) {
return false;
}

NS_DispatchToMainThread(NS_NewRunnableFunction(
"OpenVRSession::StartHapticThread", [this]() { StartHapticThread(); }));

// Succeeded
return true;
}
Expand Down Expand Up @@ -2174,6 +2171,13 @@ void OpenVRSession::VibrateHaptic(uint32_t aControllerIdx,
uint32_t aHapticIndex, float aIntensity,
float aDuration) {
MutexAutoLock lock(mControllerHapticStateMutex);

// Initilize the haptic thread when the first time to do vibration.
if (!mHapticThread) {
NS_DispatchToMainThread(NS_NewRunnableFunction(
"OpenVRSession::StartHapticThread", [this]() { StartHapticThread(); }));
}

if (aHapticIndex >= kNumOpenVRHaptics ||
aControllerIdx >= kVRControllerMaxCount) {
return;
Expand Down

0 comments on commit 480100a

Please sign in to comment.