I'm currently building my first ARKit app using Xamarin.iOS and I've been stuck for a few days now on a very odd crash happening (seemingly) randomly.
I've made a custom hit testing method in which I check for some nulls, just in case
var frame = sceneView.Session.CurrentFrame; if (frame == null) return null; if (frame.Camera == null) return null; if (frame.Camera.TrackingState != ARTrackingState.Normal) return null; if (frame.Camera.TrackingStateReason != ARTrackingStateReason.None) return null; if (frame.Camera.Transform == null) return null; [some other code]
Every now and then, my app get a SIGSEGV while executing the frame.Camera null check.
The full stacktrace is attached to this post.
What I deduce from this line
Mistrain.iOS[713:919614] critical: at ARKit.ARFrame.get_Camera () [0x00003] in /Library/Frameworks/Xamarin.iOS.framework/Versions/126.96.36.199/src/Xamarin.iOS/ARKit/ARFrame.g.cs:153
is that somehow accessing the frame camera is causing the crash.
Has something like this happened to anyone else ?
The AR part is running on a PageRenderer (maybe that's useful).
Note : My code is based on the 'PlacingObjects' demo made by Larry O'Brien and Kevin Mullins available on xamarin official github.
I've been adapting and rearranging it but the architecture is basically the same.