PolySpatial + Behavior Graph Compatibility

There seems to be a compatibility issue with the Behavior Graph UI in the Editor and PolySpatial. Both of these features are obviously very new (especially Behavior Graph), and their combination might not yet be very well tested.

When I’m testing my PolySpatial app in the Editor, things can break if I decide to open the Behavior Graph tab to spy on my NPC’s graph flow. It doesn’t happen every time, but about 50 percent of the time, opening that window and/or selecting the NPC gameobject from the hierarchy can trigger the following errors:

[Diagnostics] EXCEPTION InvalidOperationException in PolySpatialCore:
  at Unity.PolySpatial.Internals.AssetRepresentation.get_Resource () [0x0002d] in /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/AssetRepresentation.cs:39 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChangedAsset (Unity.PolySpatial.Internals.AssetRepresentation representation) [0x00050] in /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/LocalAssetManager.cs:1198 
  at Unity.PolySpatial.Internals.LocalAssetManager.FetchAssetChangesCallback (Unity.PolySpatial.Internals.ObjectDispatcherProxy+TypeDispatchData data) [0x00076] in /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/LocalAssetManager.cs:1144 
  at Unity.PolySpatial.Internals.LocalAssetManager.ProcessChanges () [0x00055] in /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/LocalAssetManager.cs:821 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.UpdateInternal () [0x000f8] in /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:271 
  at Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () [0x00015] in /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:209 
  at Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () [0x000e8] in /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/PolySpatialCore.cs:709 

InvalidOperationException: Trying to access unloaded resource! [55478d86-2984-7254-7ac2-a4f6f048f0a8:2100000 (has 1 polyspatial refs, is unity referenced): resource alive: False iid=63626 name=SimEnvironment_Carpet type=Material
Unity.PolySpatial.Internals.AssetRepresentation.get_Resource () (at /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/AssetRepresentation.cs:39)
Unity.PolySpatial.Internals.LocalAssetManager.ProcessChangedAsset (Unity.PolySpatial.Internals.AssetRepresentation representation) (at /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/LocalAssetManager.cs:1198)
Unity.PolySpatial.Internals.LocalAssetManager.FetchAssetChangesCallback (Unity.PolySpatial.Internals.ObjectDispatcherProxy+TypeDispatchData data) (at /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/LocalAssetManager.cs:1144)
Unity.PolySpatial.Internals.LocalAssetManager.ProcessChanges () (at /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/AssetManagement/LocalAssetManager.cs:821)
Unity.PolySpatial.Internals.PolySpatialUnitySimulation.UpdateInternal () (at /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:271)
Unity.PolySpatial.Internals.PolySpatialUnitySimulation.Update () (at /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/Trackers/PolySpatialUnitySimulation.cs:209)
Unity.PolySpatial.Internals.PolySpatialCore.PolySpatialAfterLateUpdate () (at /Users/bokken/build/output/unity/polyspatial/Packages/com.unity.polyspatial/Runtime/PolySpatialCore.cs:722)

The renderer completely gives out, rendering my XR simulated environment with a weird “depth only” presentation, and none of the XR simulated interactions with the mouse will work. The remedy is to stop playback restart, and thankfully this only seems to be affecting Editor playback.

These errors have appeared before in PolySpatial, but were previously “fixed”. I actually replied to this forum post recently, mistakenly thinking I had fixed my issue (my confusion lied with the fact it doesn’t happen 100% of the time).

https://discussions.unity.com/t/invalidoperationexception-trying-to-access-unloaded-resource-shader-graphs-maskingshader/333195/8

My current workaround is to just kind of not touch the Behavior Graph window during Editor playback until I really need it, at which case I’m knowingly preparing for the bug to happen.

Edit:
Unity 6000.0.31f1
Polyspatial: 2.1.2
Behavior Graph: 1.0.6

Hello @daveXR

Thanks for raising the issue, could you please open a bug report with the provided information? Customer QA will be able to run the necessary testing and assign the issue to the appropriate team.

Sorry for the inconvenience :bowing_man:

1 Like

That’s not great.

It looks like a PolySpatial bug, but I’m not sure. I suspect as you’re opening our graph there is some asset change for some reason (I wonder why) and they have a modification processor that detects a change in an asset and causes this, even though it’s not their asset.

That’s just my theory anyway, I could be wrong and it’ll need some investigation. As Morgan said, please submit a bug :slight_smile:

1 Like

Hi there, I just tried reproducing your issue with the sample scene on the Behavior package, PolySpatial installed, set to Reality Kit on the visionOS platform.

I pressed play several times and opened the behavior tree inspector from the scene and I couldn’t reproduce your error.

If you can, please provide us some precise steps to follow to try to reproduce this, or even better, a video showcasing the issue where we can see which windows you have opened within unity.

Or even best, a video with a project you can submit through the bug reporting portal that we can check.

1 Like

Hello! I can’t thank you enough for looking into this :raised_hands:

I’m going to see if I can put together a bare-bones example project and send that over. It might take me some time, but I’ll try to get it out ASAP!

2 Likes