List operations (rearrange, add, remove, deep copy) can take minutes depending on List data child content

Issue #616 resolved
Juhana Lehtiniemi created an issue
  1. In my project, certain things take up to minutes to perform, like reorganizing Lists with Odin components. It seems to be related to certain data being in the items. My class structures are rather, complex. There is recursion, but it’s limited to 16 in Odin’s preferences.
  2. -Open the provided project
    -Open SampleScene and choose “GameObject”
    -Click on “test (Game)” in field “Game editor”
    -Unfold “Events”
    -Click on FoldoutGroup called “Open this foldout to… (etc)”
    -Unfold “Actions”-list
    -Rearrange the items in the Actions list
    -> This should take way too long until the new order settles
    -If you remove the action item called “Script” and add empty actions to the list, it’s quick - it seems to be related to the contents of the “Script” item. Inside the “Script” → Details → Set constant variables -contents - this is the one that makes everything slower. The more data it contains, the slower it gets.

The thing I don’t get why this data affects simple reorganizing the parent “Actions”-List.

Another thing related to this - I’m currently using CustomAddFunction and CustomRemoveFunction in Actions-list. These functions simply do actions.Add(new GameEventAction()) but if I don’t use custom functions, these operations also take a really long time. So something extra happens in the default add function of Odin Inspector and the more content the “Script” container has in the “Set constant variables”-List, the slower the adding and removing is as well. 3. I’m attaching a profiler screen capture of the time of rearranging the List that takes way too long. Hopefully it helps somehow 4. 2019.3.0b9 5. 2.1.8 6. No 7. Windows 10 Pro 1909

ATTACHMENT: I’m delivering the project privately via download link because I don’t have permission to share the code publicly. I apogolize for the trouble.

Comments (4)

  1. Juhana Lehtiniemi

    I don’t know if this info helps, but I found out that this is totally fixed if I change the Editor serialization format to Binary. It’s really really slow on both JSON and Nodes (one rearrange operation can take 10 minutes)

  2. Tor Esa Vestergaard

    Sorry for not getting back to you on this any sooner. This seems like a more general issue with how much data is stored in the given type. If switching to binary helped, that is great and somewhat expected; binary is far, far, far faster than the other formats (sometimes hundreds or even thousands of times faster) - the issue is because of Unity’s practice of serializing the full object state every single frame. There are clever ways around this, but they all require custom implementations where you don’t serialize the data the normal way, but just inspect it, and then have custom buttons/logic for loading and saving the data. That way Odin can inspect practically arbitrary amounts of data (millions of entries, easily), since serialization isn’t a bottleneck.

    As such, I'm going to mark this issue resolved for now. It's just an unfortunate fact of life when inspectors are done in the default "everything magically works" way, given how Unity has designed their whole system.

  3. Log in to comment