blackboard.OnAfterDeserialize import order

NodeCanvas Forums Support blackboard.OnAfterDeserialize import order

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #14296
    toro_rosso
    Participant

    hello,

    we’ve encountered a nasty bug that only occured on our build machine. it caused a blackboard variable that contained a prefab (GameObject) to be null when loading the game.

    the problem is that the Blackboard._objectReferences inside OnAfterDeserialize might not be resolved by unity in time. if this happens, the resulting _blackboard will miss the reference, and the value will never be available.

    is this something that could be improved? maybe delay the blackboard deserialization, or solve unresolved gameobject later

    thanks

    #14311
    Gavalakis
    Keymaster

    Hello,

    Hmm. Can you please open up Blackboard.cs file and (temporarily), completely replace the OnBeforeSerialize and OnAfterDeserialize with simply this code:

    Also, what version of Unity does this happen? Is the Blackboard a prefab as well?

    Let me know.
    Thank you!

    Join us on Discord: https://discord.gg/97q2Rjh

    #14318
    toro_rosso
    Participant

    hi,

    we use 2018.3.4f1. we are upgrading to 2019.1.2f1 this week.

    I dont think your code will help in our case. clearly, when OnAfterDeserialize is called, other object reference *might* not have been loaded yet.

    the blackboard (i suspect it happens for graphs as well) is in a prefab, yes. the null object reference is somewhere else in Assets.

    we are thinking of moving this serialization further in the initialization process, in Awake maybe. we dont know if it’s possible yet.

    #14342
    Gavalakis
    Keymaster

    Hello again,

    Did you give the code changes a test in the end? The original code makes some “checks” that might result in the issue you are facing and removing those checks (thus simply using the code posted above) might resolve that. I unforunately can not reproduce this issue on my end yet (even with the original code). Does it happen for you always on some specific references or is it completely random?

    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

    #15019
    d1ke
    Participant

    Hello! I struggle the same problem. Did you manage to fix it? I use pretty old v 2.92 NodeCanvas version and Unity 2019.3.13f1. It is not just easy to update it to v3 due to custom changes in NodeCanvas code, but seems it is the last option.

    Problem in this code:

    Sometimes reference.GetType() returns UnityObject type despite in insepector there is linked correct MonoBehaviour-derived object. That happens sometimes with different references in different nodes (tasks) to different objects. Most of the time it happens after doing git pull where comes some changes to graph whic contains node with that reference.

    I have tried to delay graph deserealization to Awake/OnEnable stage (move it from threaded OnAfterDeserialize). But it seems quite hard to do.

    #15038
    Gavalakis
    Keymaster

    Hello,

    Do you mean the same problem like the OP when building the project? Are there any steps to reproduce this?

    Please let me know. Meanwhile, I will take a look at this as well just in case I missed something. The checks can probably be removed so that the instance = reference is called in either case. I will have to ensure that this does not create any issues though.

    Thank you.

    Join us on Discord: https://discord.gg/97q2Rjh

    #15073
    d1ke
    Participant

    Hello,

    Thank you for the reply.

    Yes, it looks like the same problem. But in our case in happens not during the build. It seems to happen when we do git pull where some graph was changed. Then I focus unity and it reimports this graph. After that some tasks rarely loose their references to UnityObjects. I can save this broken graph, then revert it in git client and references would restore.

    After some debugging we found that sometimes reference.GetType() returns UnityObject instead of concrete MonoBehaviour type. And that leads to broken reference which is fixed by reverting the graph asset.

    I didn’t manage to create a test project where it reproduces =( I don’t see how this issue can be related to our code, we do not influence serialization/deserialization stage.

    Now I’m going to update to 3.0.8 and see if problem will be reproduced.

    #15075
    Gavalakis
    Keymaster

    Thank you for the follow up and extra information.
    Please try to completely remove the check and instead call instance = reference without the if check.
    I’ve run some tests and it does not really affect anything up to now, but please do make a backup in case you decide make that change.

    Let me know.
    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.