Support Forum

Raycast graph - ScanAsync - crash on iOS only

Hi,
We are working on a Unity mobile game. We target Android and iOS.
The game is working fine on Android but we have a crash on iOS.
We are using a raycast graph.
The crash happens here:

foreach (Progress progress in AstarPath.active.ScanAsync())
{
    Debug.Log("Scanning... " + progress.description + " - " + (progress.progress * 100).ToString("0") + "%");
    yield return null;
}

If we remove this part, the game doesn’t crash but obviously the graph is not present.
If we keep this part, the game crashes and produces these logs:

In Unity Editor (remote debug):

<i>Autoconnected Player</i> Scanning... Scanning graph 1 of 1 -  - 10%
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:Log(LogType, Object)
UnityEngine.Debug:Log(Object)
OurCompanyEngine.<InitGame>d__37:MoveNext()
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

On MacOS console:

No useful logs appart from this one:

Sending event: com.apple.stability.crash {"appVersion":"0.1","bundleID":"com.ourcompany.ourgame","exceptionCodes":"KERN_PROTECTION_FAILURE at 0x000000016dddfff0","incidentID":"F3DBD937-5635-43A6-950B-D62C85617A13","logwritten":0,"process":"OurGame","terminationReasonExceptionCode":"0xa","terminationReasonNamespace":"SIGNAL"}

Our setup:

  • Unity: 2020.3.17f1
  • A* Pathfinding Project PRO BETA: 4.3.47
  • Burst 1.6.0
  • Mathematics: 1.2.1
  • Scripting backend: IL2CPP
  • API compat level: .NET 4.x
  • No optimization enabled for A* Pathfinding
  • The file link.xml from A* Pathfinding is present in /Assets/.
  • Development build + script debugging + wait for managed debugger
  • XCode 12.4 + bitcode enabled = false + development provisioning profile
  • Test device: iPhone 8 iOS 14.6

Do you have idea what could be the reason of the crash? Or any idea how to enable more logs to further investigate?

Thanks,
Geoffrey.

Hi

Are you sure there are no other logs? This one doesn’t leave much to go on.
Can you enable burst’s safety checks?

In the meantime i’ve just tested with PRO STABLE 4.2.15 and there is no issue.
So maybe a problem with Burst?
I keep u posted with Burst safety checks enabled.

1 Like

Hey @aron_granberg
Sorry for the late reply, I’ve managed to obtain more logs. Have a look at the screenshot.
So basically, the setup is the same except Xcode which is now in v13.
I build the Unity project and run it straight on my device in Xcode in debug mode.
When the game is starting, the scanning graph step fails at 10% and Xcode shows me the error you can see on the screenshot.


Let me know if you need more info!
Thanks
G.

Hi

That looks very odd. As you can see, the list was resized only a few lines above the line where it crashed. And then it only indexes into safe indices, so it shouldn’t be possible for it to crash (unless I have a very odd race condition I suppose).
Since you have the debugger open, can you check what the variable i is set to when it crashes, and also if you can show the length and allocation of the linkedCellMinMax list?

Hey @aron_granberg, here’s the situation:
In XCode, i can’t debug properly .cs files so i have to use VSCode remote debugging.
But for some technical reasons, VSCode can’t see my iPhone when using remote debugging… I’m still investigating.

Also, I don’t know if this info can help but it appears that ResetLinkedVoxelSpans() is only called on iOS: it is not called on Android or in the Editor (my breakpoints in the method are never reached on these 2 platforms). Just want to highlight the fact that maybe this method shouldn’t be called at startup?

Hi @aron_granberg

It’s very hard for us to debug because the package is in a scoped registry (we can’t modify your scripts) and the debugger doesn’t give us any values of the different involved variables (i, etc.).

However we ran an interesting test: we have tested your sample scene RaycastExample2 (which is set on “Scan on awake”) without making any modification and it crashes at the same stage when running on an iOS device.

Burst safety checks is ON.
We’re still using the PRO BETA (Burst).

Does it help?

We are still trying to debug and provide you additional info.

Hi

That’s an interesting data point.
Do you think you could run the same thing with burst disabled on ios? If it runs fine, then it’s probably a bug in the burst compiler for ios and should be reported to unity.

Do you mean to run the beta with burst disabled? Ok, I will try tomorrow morning.
Last time, I’ve tested the non beta version (so without burst) and it was working on iOS.
Keep u posted.

1 Like

Hey @aron_granberg

I made several tests, here is the full recap.

Environment:

  • Unity 2020.3.19f1
  • Empty 3D project using the example scene RaycastExample2 from your package (see screenshots)
  • A*Path beta PRO latest
  • i have just added 2 buttons in the scene to scan the graphs at runtime in ASYNC or in SYNC mode.
  • Built using Unity Cloud Build (w/ Xcode 12.4) and tests on iPhone 8 iOS 14.6
  • Burst AOT iOS compilation and optimization are enabled
  • If Burst is disabled => everything works fine
  • If using Burst 1.6.0-pre.2 => everything works fine
  • If using Burst 1.6.0 => build crashes when scanning the graph at runtime: scan on awake, AstarPath.active.Scan() or AstarPath.active.ScanAsync()

In parallel, i’m retesting our (more complex) project with Burst 1.6.0-pre.2 to see if it works. I keep you posted.

I confirm that our project is now working fine with Burst 1.6.0-pre.2…
=> So the problem occurs only when using Burst 1.6.0 on iOS.
What do you suggest:

  • Should we stay on 1.6.0-pre.2?
  • Are you planning to support Burst 1.6.0 or should we open a ticket to Unity Support? (in other words: do you think the problem is on Burst/Unity side or A*Path side? :slight_smile: )

Hi

That sounds very much like a regression in burst 1.6.0. I think Unity would appreciate it a lot if you could send them a bug report with your scene. I can probably not do much on my end, I’m afraid.
I’d recommend staying on 1.6.0-pre.2 until Unity has patched it.

I can’t really share my project because it’s using our A*Path licence, right?
Do you have an idea how i can share the project with Unity guys without having our licence in nature?
Thanks.

You can of course share it with the Unity staff. I mean, they own the asset store. They’ve got access to everything anyway, should they wish to.

Hey @aron_granberg
Unity have just released Burst 1.6.1 which apparently fixes the issue :slight_smile:
Just tested OK on iOS.
Thanks.

1 Like

Awesome! Great to hear!