Jump to content

[Unity] Using android Wake Lock to keep the main thread running when the screens are off after the user removed the headset


Romain

Recommended Posts

Hello,

I'm working with a Vive Focus 3 and for one of my projects I need to keep the Update running while the screens are off when a user remove the headset. To be precise I need to keep the update running from when the user presence switch to false and the Wave WVR_Event OnRenderingToBePaused is called until the activation of the sleep mode after the duration that we can set in the headset advanced settings.

My understanding was that using android wake lock and acquiring the wake lock before the screens turn off would keep the main thread running while the screens are off but in practice the Update still stops to run even if I’m acquiring the wake lock at the start of the app and never release it. I acquire the Wake Lock using Unity AndroidJavaClass and I added the wake lock permissions in the android manifest. To be sure I correctly acquired the wake lock I also used adb dumpsys on the power service and everything seems alright, I see the wake lock on my app.

Has anybody already achieved to do this successfully? Does the headset itself prevent you to do that and it’s impossible to keep the Update running when the user is not present or am I missing something?

For example, if the main thread continue to run, should I still received event like OnRenderingToBePaused ? It sometimes feels like Wave SDK is forcing to pause everything.

Thanks!

Link to comment
Share on other sites

  • 1 month later...
  • 1 month later...
  • 3 months later...

Hi @JulienActiveMe,

Sorry, I just saw your message. Yes I managed to catch OnRenderingToBePaused event, you can using SystemEvent.Listen() from Wave.Essence.Events namespace.

Here is an example:

private void Start()
{
  // Add the listener
  SystemEvent.Listen(WVR_EventType.WVR_EventType_RenderingToBePaused, OnRenderingToBePaused);
}

private void OnDestroy()
{
  // Remove the listener when object is destroyed
  SystemEvent.Remove(WVR_EventType.WVR_EventType_RenderingToBePaused, OnRenderingToBePaused);
}

private void OnRenderingToBePaused(WVR_Event_t systemEvent)
{
  // Function triggered when the event is listened
}

 

Edited by Romain
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...