Magic Leap 2 Video Upload Issue: Uploads Stop when Device Enters Sleep Mode

Hello Community,

I hope you are all doing well. I'm currently grappling with a challenge related to video uploads on the Magic Leap 2, specifically when the device enters sleep mode. Your guidance would be greatly appreciated.

Issue Description:

While wearing my Magic Leap 2 glasses and navigating through different screens, video uploads to Google Cloud Storage (GCS) progress smoothly. However, once I put the glasses down on the table, the device enters sleep mode and becomes unresponsive. This also places the network adapter into sleep mode, interrupting the video upload process.

I suspect the sleep mode could be due to some interaction between the glasses lens and the device, but I need clarification on this.

My primary questions are:

  1. How can I continue the video upload when the application is running in the background, and the device is placed on the table?
  2. How can I permanently disable the device's sleep mode, if possible?
  3. Does Magic Leap 2 offer a service that operates in the background to continue video uploads?

Technical Details:

  • Unity Editor version: 2022-2.0f1
  • ML2 OS version: Version 1.3.0-dev1, Build B3E.230427.10-R.023, Android API Level 29
  • MLSDK version: 1.7.0
  • Host OS: Windows 11

At present, I do have any specific error messages from the logs related to this issue:

2023/07/13 20:12:46.522 9791 9916 Debug UploadTask Resetting chunk size to 262144
2023/07/13 20:12:46.522 9791 9916 Error StorageUtil error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
2023/07/13 20:12:47.703 9791 9916 Warn ExponenentialBackoff network unavailable, sleeping.
2023/07/13 20:12:47.704 9791 9916 Error StorageUtil error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
2023/07/13 20:12:48.710 9791 9916 Warn ExponenentialBackoff network unavailable, sleeping.
2023/07/13 20:12:48.710 9791 9916 Error StorageUtil error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
2023/07/13 20:12:49.790 9791 9916 Warn ExponenentialBackoff network unavailable, sleeping.
2023/07/13 20:12:49.790 9791 9916 Error StorageUtil error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
2023/07/13 20:12:50.997 9791 9916 Warn ExponenentialBackoff network unavailable, sleeping.
2023/07/13 20:12:50.998 9791 9916 Error StorageUtil error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
2023/07/13 20:12:52.097 9791 9916 Warn ExponenentialBackoff network unavailable, sleeping.
2023/07/13 20:12:52.097 9791 9916 Error StorageUtil error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.

I eagerly look forward to your insights and suggestions before weekend, which will greatly assist me in resolving this issue and continuing my development work.

Best regards,

  1. How can I continue the video upload when the application is running in the background, and the device is placed on the table?

You should consider running a foreground service that operates while not he foreground app by implementing a foreground service for your application. Foreground services  |  Android Developers

  1. How can I permanently disable the device's sleep mode, if possible?

You can go into settings and disable this mode.

  1. Does Magic Leap 2 offer a service that operates in the background to continue video uploads?

Assuming you aren't asking to operate while in sleep, then the foreground service referenced in point 1 would allow your app to continue work while no the foreground app. A common example for this is when you are sitting at Home Menu or Settings but your app is in the background.

I appreciate the quick response from @mrushton , and I'm grateful for the advice provided. However, I'm still in need of some guidance. I understand the recommendation to use an Android foreground service to continue video uploads when my application is running in the background and the device is on the table. But I am currently developing my application using Unity with C#.

I have a few questions to better understand the process:

  1. How can I integrate an Android foreground service into my Unity app developed in C#?
  2. Are there any specific plugins or packages that can assist with implementing Android foreground services within a Unity environment?
  3. Can you provide a code snippet or guide that illustrates how this can be done?

In addition to these, I have a question regarding the device's sleep mode. mrushton mentioned I could disable this mode in the settings. However, I'm not sure which setting needs to be adjusted:

  1. Could you please specify which setting I need to change to disable the sleep mode?

Thank you again for your support. I'm looking forward to your responses, which will help me progress with my development work.

  1. How can I integrate an Android foreground service into my Unity app developed in C#?
  2. Are there any specific plugins or packages that can assist with implementing Android foreground services within a Unity environment?
  3. Can you provide a code snippet or guide that illustrates how this can be done?

In general getting comfortable Building a Plugin for accessing Android will get you a lot of mileage in Unity, I typically would recommend a resource like this to get started:

I haven't checked the asset store for a plugin that can possibly abstract all of this but should be able to find plenty of open source examples like this that do the above:

With that said this is an advanced concept for Unity development so might take a little time.

As for the sleep setting its currently under Settings -> Battery -> Sleep Mode

I explored the recommended settings you suggested, but couldn't find the "Sleep Mode" setting under "Settings -> Battery". Instead, I located a "Controller Standby" mode which was originally enabled.

This mode allows the controller to transition into a power-saving standby state when it's not in use.

To investigate further, I've temporarily disabled this mode. In addition, there's another option within the

Battery settings called "Compute Pack Standby". Similar to the controller standby, this mode puts the Compute Pack into a power-saving standby state when idle.

However, I was unable to find any option specifically related to a 'save mode

Interesting, I am unfamiliar with the verbiage of this reference "save mode" but putting this on @etucker 's radar if we can make it more clear.

I believe you are on an OS version that only has Doze mode (standby) a not Sleep Mode (s2idle), I suspect the issues you were having were with doze and not sleep since it isn't an option and disabling standby should help resolve that issue temporarily while you investigate if you want to handle for it.

In this case Standby is the Android concept people know as Doze mode Optimize for Doze and App Standby  |  App quality  |  Android Developers

@etucker Can you please assist in this?

Hi @usman.bashir, Sleep Mode is available starting with 1.3.0-dev2. I see you're on 1.3.0-dev1 so you'll need to update. You can find it in the Settings App by selecting Battery > Compute Pack Standby > Sleep Mode.

You can disable both Power Saver and Compute Pack Standby settings under Battery for performance optimization.