arfoundation-samples icon indicating copy to clipboard operation
arfoundation-samples copied to clipboard

Persistent crashes on iOS when unloading scene

Open nilsk123 opened this issue 7 years ago • 36 comments

I'm seeing persistent crashes when unloading an AR foundation scene on iOS, even using all the latest software.

When I unload a scene, sometimes it works the first couple of times and then crashes, other times it will crash on first try.

Error in XCode is UnityGfxDeviceWorker (31): EXC_BAD_ACCESS (code=1, address=0xdc56d9600)

Crash log: https://pastebin.com/DUGSPDyS

Software fingerprint:

Unity 2018.3.4f1 iOS 12.1.2 iPhone SE

AR Foundation 1.0.0-preview.22 ARCore XR Plugin 1.0.0-preview.24 ARKit XR Plugin 1.0.0-preview.23

nilsk123 avatar Feb 04 '19 07:02 nilsk123

Hi @nilsk123 , could you provide the symbolicated crash log instead?

See here how to do it: https://developer.apple.cosm/library/archive/technotes/tn2151/_index.html

The easiest way is to get it from XCode via the Devices & Simulators list.

  1. In Xcode > Window > Devices & Simulators , select a connected iPhone/iPad/etc top left.
  2. View Device Logs
  3. All Logs

More: https://stackoverflow.com/a/25927122

henriqueranj avatar Feb 04 '19 17:02 henriqueranj

Hi @nilsk123 , could you provide the symbolicated crash log instead?

See here how to do it: https://developer.apple.cosm/library/archive/technotes/tn2151/_index.html

The easiest way is to get it from XCode via the Devices & Simulators list.

  1. In Xcode > Window > Devices & Simulators , select a connected iPhone/iPad/etc top left.
  2. View Device Logs
  3. All Logs

More: https://stackoverflow.com/a/25927122

Here it is:

https://pastebin.com/6ZxiP4G1

nilsk123 avatar Feb 05 '19 08:02 nilsk123

Getting a similar issue with crashing when unloading an AR scene.

https://pastebin.com/LHyrxVs3

ztkevinsy avatar Feb 08 '19 09:02 ztkevinsy

Same here

Tostifrosti avatar Feb 18 '19 09:02 Tostifrosti

Unity 2018.3.6 same issue

7891liang avatar Feb 25 '19 10:02 7891liang

Can we expect this issue to be fixed? Is there any workaround atm? -> Scenes with ar foundation / Arkit loaded crash when unloaded with the SceneManager.

Inspyro avatar May 22 '19 16:05 Inspyro

I had problems with a ARKit image tracking scene crashing in my app. I rebuilt the scene using ARFoundation image tracking and I have no more crashes.

dorkbot avatar May 22 '19 18:05 dorkbot

@dorkbot For us it also happens with ARFoundation (but not on every unload)

Inspyro avatar May 22 '19 19:05 Inspyro

this hasn't been fixed in the latest versions as far as I can tell (haven't tried the 2.* versions as I don't want to update to unity beta's)

We work around it by just never unloading the AR scene, we disable the gameobjects and keep everything in memory when AR isn't used.

nilsk123 avatar May 23 '19 21:05 nilsk123

haven't tried the 2.* versions as I don't want to update to unity beta's

ARFoundation 2.1 is compatible with Unity 2019.1 (released) and 2019.2 (beta) ARFoundation 1.5 is the exact same package compatible with 2018.3/4

We were not able to reproduce the issue in 1.5/2.1. Are you able to update to 1.5?

tdmowrer avatar May 23 '19 23:05 tdmowrer

haven't tried the 2.* versions as I don't want to update to unity beta's

ARFoundation 2.1 is compatible with Unity 2019.1 (released) and 2019.2 (beta) ARFoundation 1.5 is the exact same package compatible with 2018.3/4

We were not able to reproduce the issue in 1.5/2.1. Are you able to update to 1.5?

It is compatible? Then I have probably misunderstood the docs on this. I will try using the very latest of all plugins (arfoundation, arkit, arcore) and report back here

nilsk123 avatar May 24 '19 07:05 nilsk123

haven't tried the 2.* versions as I don't want to update to unity beta's

ARFoundation 2.1 is compatible with Unity 2019.1 (released) and 2019.2 (beta) ARFoundation 1.5 is the exact same package compatible with 2018.3/4

We were not able to reproduce the issue in 1.5/2.1. Are you able to update to 1.5?

Docs say:

Requirements

This version of AR Foundation is compatible with the following versions of the Unity Editor:

2019.2a8 and later

nilsk123 avatar May 24 '19 07:05 nilsk123

That's an error in the docs (fixing soon).

ARFoundation 2.1 is compatible with Unity 2019.1 (released) and 2019.2 (beta) ARFoundation 1.5 is the exact same package compatible with 2018.3/4

Is correct.

tdmowrer avatar May 28 '19 23:05 tdmowrer

I have a well reproducible crash (UnityGfxDeviceWorker / EXC_BAD_ACCESS) using Unity 2019.2.0f1 and ARFoundation 2.1.1 on iOS 12.3. It happens when you do this (around 50% of time):

arSession.enabled = false; 
arCamera.gameObject.SetActive(false);  // <-- comment this out to prevent crash

If you are not deactivating the arCamera, things seem to work fine. I suspect the pointer to the AR texture is freed by the camera deactivation but ar foundation still is writing / tries to write into it. This would be a thread synchronization problem inside the arkit/arfoundation interface.

I have not yet tried disabling the camera in the next frame...

kaij avatar Aug 23 '19 12:08 kaij

We have temporarily worked around this by disabling multithreaded rendering. Same scenario as above, reset arsession and disable camera gameobject

nilsk123 avatar Aug 23 '19 17:08 nilsk123

I'm having this issue too, 2019.2.0f1 and ARFoundation 3.0.0 preview 2

NumaNumaNuma avatar Sep 25 '19 07:09 NumaNumaNuma

We still see this problem sporadicaly too, even without multithreaded rendering. Never in test environments ofcourse, only in production =P

My gut feeling is that it has something to do with the fact we use ScreenCapture.CaptureScreenshotAsTexture() around the same time we reset an AR session, but i'm not entirely sure

nilsk123 avatar Sep 25 '19 08:09 nilsk123

for me it's about 90% of the time when ending an AR session. @tdmowrer Is this being looked at? Or fixed in a newer version of Unity? :) If you're unable to reproduce it then do you have any ideas what we might be doing wrong? Thanks!

NumaNumaNuma avatar Sep 25 '19 08:09 NumaNumaNuma

I'm getting the same thing when disabling the ARHumanBodyManager, I'm creating a new issue for it. #308

NumaNumaNuma avatar Sep 26 '19 07:09 NumaNumaNuma

I have a well reproducible crash (UnityGfxDeviceWorker / EXC_BAD_ACCESS) using Unity 2019.2.0f1 and ARFoundation 2.1.1 on iOS 12.3. It happens when you do this (around 50% of time):

arSession.enabled = false; 
arCamera.gameObject.SetActive(false);  // <-- comment this out to prevent crash

If you are not deactivating the arCamera, things seem to work fine. I suspect the pointer to the AR texture is freed by the camera deactivation but ar foundation still is writing / tries to write into it. This would be a thread synchronization problem inside the arkit/arfoundation interface.

I have not yet tried disabling the camera in the next frame...

I am unable to reproduce this. One possible difference is my device is running iOS 13. Have you ever seen the issue in iOS 13 or only in iOS 12.x?

tdmowrer avatar Oct 05 '19 21:10 tdmowrer