CoherenceMonoBridge: : The instantiation of the prefab 'Wildlife_Agent_Base (Coherence.Toolkit.CoherenceSync)' failed: System.NullReferenceException

Bug Description

(coherence) CoherenceMonoBridge: : The instantiation of the prefab 'Wildlife_Agent_Base (Coherence.Toolkit.CoherenceSync)' failed: System.NullReferenceException

3350 at (wrapper managed-to-native) UnityEngine.Component.get_gameObject(UnityEngine.Component)

3351 at Coherence.Toolkit.CoherenceMonoBridge.InstantiateNetworkedEntity (Coherence.Toolkit.CoherenceSync syncPrefab, Coherence.Toolkit.CoherenceMonoBridge+SpawnInfo info, Coherence.Entity.SerializeEntityID entityID, Coherence.Entity.EntityUpdate entityUpdate, System.String newName) [0x00051] in /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/CoherenceMonoBridge.cs:836 , stacktrace: UnityEngine.Debug:LogError (object,UnityEngine.Object)

3352Coherence.Log.UnityLogger:BuildAndPrintLog (Coherence.Log.LogLevel,string,System.Text.StringBuilder,System.ValueTuple`2<string, object>[]) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Log/UnityLogger.cs:120)

3353Coherence.Log.Logger:Log (Coherence.Log.LogLevel,string,System.ValueTuple`2<string, object>[]) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Log/Logger.cs:110)

3354Coherence.Log.Logger:Error (string,System.ValueTuple`2<string, object>[]) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Log/Logger.cs:78)

3355Coherence.Log.UnityLogger:Error (string,System.ValueTuple`2<string, object>[]) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Log/UnityLogger.cs:66)

3356Coherence.Toolkit.CoherenceMonoBridge:InstantiateNetworkedEntity (Coherence.Toolkit.CoherenceSync,Coherence.Toolkit.CoherenceMonoBridge/SpawnInfo,Coherence.Entity.SerializeEntityID,Coherence.Entity.EntityUpdate,string) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/CoherenceMonoBridge.cs:900)

3357Coherence.Toolkit.CoherenceMonoBridge/<>c__DisplayClass113_0:<CreateNetworkedEntity>b__0 (Coherence.Toolkit.CoherenceSync) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/CoherenceMonoBridge.cs:825)

3358Coherence.Toolkit.PrefabLoader`1<Coherence.Toolkit.AddressablesLoader>:ProcessEvents (Coherence.Toolkit.CoherenceSync,System.Action`1<Coherence.Toolkit.CoherenceSync>) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/PrefabLoader.cs:42)

3359Coherence.Toolkit.AddressablesLoader/<>c__DisplayClass1_0:<Load>b__0 (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>) (at /builds/bossians/production/wild-skies/Library/PackageCache/io.coherence.sdk@0.9.1/Coherence.Toolkit/PrefabLoader.cs:84)

3360DelegateList`1<UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>>:Invoke (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<UnityEngine.GameObject>) (at /builds/bossians/production/wild-skies/Library/PackageCache/com.unity.addressables@1.20.0/Runtime/ResourceManager/Util/DelegateList.cs:69)

3361UnityEngine.AsyncOperation:InvokeCompletionEvent () (at /home/bokken/buildslave/unity/build/Runtime/Export/Scripting/AsyncOperation.cs:21)

Collapse

Expected behaviour

Screenshots

If applicable, add screenshots to help explain the problem.

How to reproduce

Sometimes

Steps:

  1. Start 4 clients
  2. client 0 creates a room
  3. 3 other clients join
  4. Test different sort of conditions (e.g. max players +1, owner disconnects)

intermittently seeing above error and not sure why

Environment

SDK: v0.9.1
Engine: ?
Unity: 2022.1.8f
OS/Platform: Linux/Docker - clients run in batchmode nographics

2 Likes

Hi @Kirsten_Miller thanks for posting. We just released 0.9.2. I don’t know if that will resolve this, but it’s a good starting point.

Following up on this. I believe you discussed with some of my colleagues and this was the outcome?

It seemed to be an intermittent error and removing the prefab as having the addressables box ticked and updating the prefabMapper to make it not be loaded as an addressable seems to fix the issue.

Hey,

Yes doing both those steps resolved the issue.

We were wondering does coherence not support having a prefab with addressabkes box ticked but then loading it not via addresssables? Because we found the coherence prefabMapper seemed to automatically update to load via addressables when the box was ticked

1 Like

You can, but is not advisable.

If you bundle a prefab through Addressables, but you also reference it directly in your build (either via a scene or resources dependency, or as a dependency of an object that is always loaded (like PrefabMapper)), then your asset will be duplicated in disk, but it will also be duplicated in memory.

You can check asset duplication for your particular project with Addressables Analyze tool.

1 Like