cancel
Showing results for 
Search instead for 
Did you mean: 

OVRInput.SetControllerVibration Massive Unity CPU Spikes

sinfiery
Honored Guest
Hi,

I noticed massive CPU spikes everytime OVRInput.SetControllerVibration(.5f, .5f, OVRInput.Controller.RTouch) is called. Something like 30-40ms cpu spikes on the LateUpdate function. I tracked it down to  OVRHaptics.Process(); being called but when looking at the function, there doesn't appear to be any clear optimizations to make.

Anyone else experienced this problem? There's no way there should be massive CPU spikes every time the haptics are used on the Rift/Rift S. I must be missing something. 

3 REPLIES 3

sinfiery
Honored Guest
I tested out the deprecated OVRHaptics solution and there are no CPU spikes when you implement this. So clearly haptics can be executed without CPU spikes -- it's just a question of why this function is so awful for performance. 

Halfspacer
Adventurer
Something like 30-40ms cpu spikes on the LateUpdate function.
OVRInput.SetControllerVibration executes on the frame, so your issue is likely caused by you calling it in an Update loop which Sets the controller vibrations every frame. You only need to set it once on the frame it's supposed to execute on, and it will vibrate for 2 seconds or until you set Amplitude to 0. 
https://developer.oculus.com/documentation/unity/latest/concepts/unity-haptics/?locale=en_US

sinfiery
Honored Guest
Definitely tried testing to see if multiple calls were being made -- it is only being called one time per input -- in numerous scripts and numerous situations. That one call alone causes the massive CPU spike. 

I did try only calling "OVRInput.SetControllerVibration(0, 0, OVRInput.Controller.LTouch);" and it only caused a 15ms spike. It appears calling vibrations for two controllers at once, regardless of what frequency/amplitude is called, causes the 30-40ms spike.


Edit -- I commented out the call to Process() in LateUpdate on the OVRHaptics script and the problem is gone. The haptics still work -- not as good, but they still work. I'm really apprehensive to put this "fix" into any sort of final build though.