xamarin/ios-samples

ARKit / iOS - App crashes in release mode using SceneView.Snapshot()

smazza94 opened this issue · 5 comments

I'm developing an AR application based on "Placing Objects" template, but trying to get a snapshot from the SceneView I got a crash in release mode (if I try in debug mode it's working perfectly).

I tried to debug using Device Log tool and I found the following Exception:

Unhandled managed exception: Unable to marshal the parameter #1 whose managed type is 'SceneKit.SCNSceneRenderer' to managed

Screenshot 2022-03-21 at 10 41 14

It seems that snapshot goes in conflict with RendererUpdateAtTime, but I can't find a way to fix it.

Anyone can help me?

Thanks for the feedback!

So that appears to be coming from xamarin_invoke_trampoline in trampolines-invoke.m.

Since you said it only happens in release mode, I wonder if the linker is removing that code, and we are unexpectedly needing it in this case.

As a debugging measure, try setting the linker to "Don't link" and re-running your test in Release mode.

It would also be helpful if you could produce a small sample project showing the crash.

I did the following change and the problem went away

instead of

[Export("renderer:updateAtTime:")]
public void RendererUpdateAtTime(SCNSceneRenderer renderer, double updateAtTime)

use

[Export("renderer:updateAtTime:")]
public void Update(ISCNSceneRenderer renderer, double timeInSeconds)

Maybe a conflict with the SCNSceneRenderer... any ideas?

Thanks anyway! @chamons

Oh I missed this on my first read:

image

Hey @rolfbjarne thoughts?

Looks like this is a problem from back in Classic Xamarin days, this is the api definition:

https://github.com/xamarin/xamarin-macios/blob/5740e372a0e3ddb019beaa16bbc6f22959da7a25/src/scenekit.cs#L3273-L3275

in other words: using ISCNSceneRender as the first parameter type is correct (and the fix).

I'll PR that fix shortly.