Unity Freezing on Nested TrueSyncBehaviour Instantiation

Hello! During my experimentation with TrueSync, I ran into a few issues with instantiating TrueSyncBehaviours (TSB) that would result in looping or Unity freeze/crash. I managed to reproduce one of these issues simplistically to share here and meanwhile I'll check into reproducing some of the other scenarios.

Double nested TSB instantiation appears to crash Unity (5.4.0f3). Specifically, having the TrueSyncManager (TSM) object instantiate a Primary TSB object, which instantiates a Secondary TSB object, works, but when the Secondary TSB object instantiates a Tertiary TSB object, Unity freezes. Setup looks like this:

Unity Scene:
TrueSyncManager { PlayerPrefabs Size = 1, Element 0 = PrimaryObject }

Prefabs:
PrimaryObject { PrimaryObjectScript Prefab = SecondaryObject }
SecondaryObject { SecondaryObjectScript Prefab = TertiaryObject }
TertiaryObject { TertiaryObjectScript }

Scripts:
using UnityEngine;
using TrueSync;

public class PrimaryObjectScript : TrueSyncBehaviour
{
    public GameObject prefab;

    public override void OnSyncedStart()
    {
        Debug.Log("PrimaryInstantiator (" + GetInstanceID() + ") .OnSyncedStart()");
        TrueSyncManager.SyncedInstantiate(prefab, TSVector.zero, TSQuaternion.identity);
    }
}

using UnityEngine;
using TrueSync;

public class SecondaryObjectScript : TrueSyncBehaviour
{
    public GameObject prefab;

    public override void OnSyncedStart()
    {
        Debug.Log("SecondaryInstantiator (" + GetInstanceID() + ") .OnSyncedStart()");
        TrueSyncManager.SyncedInstantiate(prefab, TSVector.zero, TSQuaternion.identity);
    }
}

using UnityEngine;
using TrueSync;

public class TertiaryObjectScript : TrueSyncBehaviour
{

    public override void OnSyncedStart()
    {
        Debug.Log("TertiaryObject ("+GetInstanceID()+") Created.");
    }
}
There are definitely ways to avoid such nested instantiation and perhaps that sort of functionality is unintended. At the very least, I am bringing up this issue in hopes to increase stability of the TrueSync package. I also experienced some issues with "general behaviours" attached to the TSM or as free objects in the scene and I'll try to reproduce those and comment further in this discussion. Thanks!

Comments

  • Note: the issue still occurs if I remove the PrimaryObject prefab from TSM and add a PrimaryObjectScript to the TSM. It also occurs if I make a separate object in the scene with a PrimaryObjectScript attached.

    Occasionally, when the freezing occurs, I get a chance to seen some objects spawned on the scene hierarchy and it appears that there is some looping occurring:
    SecondaryObject(Clone)
    TertiaryObject(Clone)
    SecondaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    SecondaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    SecondaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    SecondaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    TertiaryObject(Clone)
    .
    .
    .
  • Hi @Mukikaizoku, thanks for your report, it seems a loop instantiation like you noticed.