Search Unity

App crashes after suspending and using camera

Discussion in 'iOS and tvOS' started by nlacroixAOD, Apr 6, 2021.

  1. nlacroixAOD

    nlacroixAOD

    Joined:
    Jul 20, 2018
    Posts:
    20
    We seem to be having an issue where our app (using Unity 2019.4.21f1) is crashing while suspended after using the camera and seems to happen on both iOS and Android

    Basically repro steps are the following:
    1. Start game and play for a bit
    2. Suspend the app (not closing or using the power button just minimizing and returning to home screen)
    3. Open the device's camera app and take a picture (app will not crash until a picture is taken)
    4. Right after taking a picture the app crashes in the background with a very general error about a memory issue:
      Message from debugger: Terminated due to memory issue
    This issue was reported by both iOS and Android users and was reproduced on iPhone XR, iPhone SE and Pixel 3XL.

    As a side note, I've just tried a random soundboard app on Pixel 3XL that was made with Unity (had the watermarked splash) and it appears to crash as well after taking a picture.
     
  2. Elektros_Stulpas

    Elektros_Stulpas

    Unity Technologies

    Joined:
    Aug 7, 2019
    Posts:
    4
    Hey, I tried reproducing the issue you described using a random project that uses a camera, but it didn't crash. Could you please submit a bug report with a minimal repro project to showcase the issue, so we could investigate it further?
     
  3. nlacroixAOD

    nlacroixAOD

    Joined:
    Jul 20, 2018
    Posts:
    20
    @Elektros_Stulpas The crashing wasn't due to our project using the camera itself, it was crashing due to using the system/devices camera while leaving our app in the background. I believe this may just be due to our apps background 'footprint' in general. We have a very large application (making it impossible to provide a proper repro project) which I believe is just getting shut down to free up memory. From my testing it'll crash on any device I've tried as soon the device's camera app takes a photo. I assume any other large/heavy application would also be shut down when left in the background and using the device camera, or even when there's just a lot going on in the background and then doing something else heavy like using the camera.

    With how much goes into device camera's these days I'm assuming that its a bit of a resource hog and needs to process/store quite a bit and in doing so shuts down our app so it can take up more. I was able to stop the crash from happening if I restarted the Pixel 3XL (thereby clearing all system/background processes that may have been running) and that seemed to temporarily resolve it. I'm not sure if there is much that could be done about this aside from just trying to keep our app smaller/lighter or possibly incorporating some camera functionality into our app so users don't need to leave it for photos.
     
  4. Elektros_Stulpas

    Elektros_Stulpas

    Unity Technologies

    Joined:
    Aug 7, 2019
    Posts:
    4
    That would make sense and yes, if the OS kills the app due to it needing more resources for other tasks, I don't think we could do much about it. If at some point for some reason it starts to look more like a bug from our side, please feel free to report a bug and we'll have a look at it.