Start a new topic

Unity UWP - Camera turns OFF when app is minimized and does not restart

 Hello

  • We are using the Unity Professionnal SDK 9.3
  • Unity version is 2020.3.2f1
  • Building for UWP, target devices are PC (Windows 10) and Windows Surface Pro 6, issue is reproductible on both devices
  • Happens on both sample app and our own app

Context:

We use Unity to build our app for UWP on Windows Surface Pro 6 and PC.
"Run in background" is checked in Player Settings.
"Default is Full Screen" is not checked in Player Settings.

When our app is in foreground, everything works fine.
If we open another application on top of our app, or use ALT+TAB, our app keeps running, the camera keeps filming, and the event "OnCameraFrameAvailable" is fired regularly.

Problem :

If the user minimizes the application (by pressing the minimize buttton on the top right corner of the screen of clicking on the app icon on the taskbar), the camera of the device stops (we can see that the light indicator on the device turns off), and we no longer receive new frames.

If the "Default is Full Screen" is checked in Player Settings, this also happens when we use ALT+TAB or open another application on top of our app.

We believe this is a limitation of UWP.
However, when the application is opened again (put in the foreground), the camera does not start again.

We noticed that the WikitudeCamera script uses the "OnApplicationPause" event that should call "Start/StopWikitudeNativeSDK", but the event "OnApplicationPause" is not called on PC and Windows Surface when minimizing the application.
Only the event "OnApplicationFocus" is called, but it is also called at times when the camera is still working properly so we cannot use this.

Also, we have not seen any information from Wikitude components properties or events that could tell us the camera is not accessible anymore.
For now, the only way we can tell is that we no longer receive frames from the "OnCameraFrameAvailable" event.

Question :
  • Have you already encountered this issue ? Is there any workaround to prevent the camera to stop, or a way to make it restart automatically if the app is on the forground again ?

  • We haven't found any easy way to find out if the app was minimized (e.g. an event) or if the camera was shut down on UWP. on PC/Surface Do you know of a solution ?

  • Can you confirme that currently, the only way to restart the WikitudeCamera is to destroy it and all the trackers and create them again ? Or can we disable / enable the GameObject in newer versions of the SDK ?

Please let me know if you need more information.
Thank you for your help,
Thales team.

Hello,


Regarding the 2nd point, we found a way to detect when the app is put to the background/minimized which result in the camera going off :

#if ENABLE_WINMD_SUPPORT
            CoreApplication.EnteredBackground += (sender, args) =>
                {
                    
                };
            
            CoreApplication.LeavingBackground += (sender, args) =>
                {
                    
                };
#endif

 We can now restart the camera when the application comes to the foreground again.


Questions 1 and 3 remain, thank you in advance


Thales team.

 

 

Hello,


Any update or comment on this issue ?


Regards

Login or Signup to post a comment