Search Unity

Errors related to SerializeReference after upgrading from 2020.3 to 2021.3

Discussion in 'Editor & General Support' started by jake_card, May 11, 2022.

  1. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Hi Unity forums!

    I just upgraded my project's Unity version from 2020.3.7f1 to 2021.3.2f1. Now, whenever I open the project, I'm getting a couple hundred of each of the following errors:

    The serialized array of [SerializeReference] objects is missing entry for Refid X

    and

    Assertion failed on expression: 'm_WriteObjectAccumulator.empty()'

    Is this a thing people have seen before after an upgrade? I'd really like to use Unity 2021, but I haven't found anything in my searches about how to resolve this.
     
    ddagradi likes this.
  2. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Update: Just tried it with the newly-released 2021.3.3f1 update, same errors. Hoping someone from the Unity team can provide some guidance!
     
  3. AndrewSkow

    AndrewSkow

    Unity Technologies

    Joined:
    Nov 17, 2020
    Posts:
    91
    Hi! We don't have current bug reports exactly matching what you describe. However I suspect that your project might have field names that happen to conflict, at the serialization level, with the field names we use to record information about SerializeReference objects. The assert and error you indicate might mean that Unity is confused as it thought it found a SerializeReference reference, but then cannot match that to the association object information stored at the end of the object's serialized data.

    The file format has changed in 2021, so assets that might have worked before might hit this situation at upgrade time. For example previously "id" was used and now "rid" is used instead (but we maintain code to read the old format as well). The string "references" also has special meaning so might conflict if there is a field of that name.

    Does that seem like a possibility in any of the scripting objects in your project?
     
  4. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Thanks for the reply! We definitely have at least one serialized field named "id". Is there a way I can find all the serialized field names we should avoid? With that, I can do a project search and rename all our conflicting fields.
     
  5. AndrewSkow

    AndrewSkow

    Unity Technologies

    Joined:
    Nov 17, 2020
    Posts:
    91
    I would suggest looking at the YAML format for a MonoBehaviour and ScriptableObject that has at least one SerializeReference field, that is one way to see all the internal fields and the names that Unity uses. E.g inside a .unity or .asset file. There are the internal fields which don't change very much, and then there is the structure that only appears when SerializeReference is being serialized and which i think only involves "id", "rid" and "references" as possibly conflicting names. It is that second part that changed a bit for this version and seems to be causing you upgrade trouble.

    We do have some errors/warnings that try to catch conflicts with internal field names, but I'm not sure your case is being detected and warned about. Its possible that "id" was working ok before, despite being also used internally, but has now started to cause confusion for the code that is trying to upgrade the class to the new format. Please let us know how things go.
     
    jake_card likes this.
  6. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Thanks Andrew! I'll give that a shot soon and let you know how it goes.
     
  7. AndrewSkow

    AndrewSkow

    Unity Technologies

    Joined:
    Nov 17, 2020
    Posts:
    91
    BTW Jake_Card, i was curious if you ever pinpointed any further detail about the Serialization errors you hit. I've tried to see if i could reproduce those errors by creating objects in 2020 with "id" and "rid" fields. But those seem to load fine between 2020 and 2021 (with YAML format ScriptableObject assets). The closest we have seen to that error was with JSONUtility in the past, which was why I suggested it might be a possible conflict. Hopefully you have found a workaround, one way or another, but we are always on the lookout for compatibility or upgrade issues. Thanks
     
  8. jake_card

    jake_card

    Joined:
    Oct 2, 2014
    Posts:
    57
    Haven't had a chance to try another upgrade yet, I'll post back here if I have any updates!