Crash after enabling game object with skinned mesh renderer

We are experiencing a crash in simulator and on device when enabling a game object with a skinned mesh renderer. The object needs to be disabled in Start for the issue to occur.

I have reported a bug IN-56706 with a small repro project, but I’m keeping this topic open for visibility, in case anyone else experience a similar problem.

I have attached a snippet from the stack trace and the error that we are getting.

#5 0x0000000100f0ee1c in PolySpatialRealityKit.SetEntitySkinnedRenderInfo2(_:_:) at /Users/bokken/build/output/unity/quantum/Packages/com.unity.polyspatial.visionos/Source~/PolySpatialRealityKit/PolySpatialExtra/PolySpatialRealityKitOverrides.swift:226

PolySpatialRealityKit/PolySpatialRealityKitOverrides.swift:226: Fatal error: Unexpectedly found nil while unwrapping an Optional value

Hi,

Looked into this and was able to repro the issue. I’ve made a fix for this issue and some testing that should safeguard against this in the future. They should hopefully land soon and be available on next release.

In the meantime, it looks like the skinned mesh renderer/game object must be enabled briefly at the start for skeleton set-up to happen before you can disable it. Further re-enabling should be fine.

Using the attached example, I was able to avoid the crash:

    _gameObject.SetActive(true);
    yield return null;
    _gameObject.SetActive(false);
    yield return new WaitForSeconds(5);
    _gameObject.SetActive(true);

Sorry for the inconvenience!

Thanks for the quick response!