Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Prefab modifications are constantly changing serialized data order and cause version control noise

Discussion in 'Prefabs' started by Xarbrough, Aug 5, 2019.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    738
    I believe I have already seen this issue as a bug report somewhere, but cannot find it anymore. Please let me know if this is being worked on or if anyone has any ideas what to do against this:

    PrefabModificationsRandomOrder.jpg

    We are on Unity 2019 and at some point in the past a dozen of our prefabs have started changing every time the project is saved even though nobody has touched these assets. The values itself do not seem to change, but the order in which these modifications are saved to disk. This is causing a really big annoyance for us because we are working in a team and team members are constantly confused why these assets show up as changed and cause merge conflicts, when they shouldn't.

    Unity is notorious for setting files dirty even though nothing has changed, this is a well-known problem and other software such as PlasticSCM actually patches some of this up by ignoring files which have their timestamp changed, but not their content. However, in this case with prefabs, the contents change their order which causes a lot of noise in our version control system.

    Again, I believe this is a known bug, but please let me know what the status is, as I cannot find it in the issuetracker. Thank you!
     
    phobos2077, Peter77, fherbst and 2 others like this.
  2. mcarriere

    mcarriere

    Joined:
    Sep 14, 2012
    Posts:
    79
    I was just complaining about this / confirming with some other folks! We're seeing this two across multiple 2019 projects. Super annoying. We have hundreds of prefabs in our projects and this can take a long time if you want to be able to verify that no changes were made. When we see this manifest, its just taking the data we have and reordering it in the prefab, no actual changes are being made.
     
  3. Elliott-Mitchell

    Elliott-Mitchell

    Joined:
    Oct 8, 2015
    Posts:
    58
    By chance, do you have auto-save enabled for prefabs?
     
  4. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    738
    No, at least not on my machine. Maybe some of our developers have it on, but the changes already happen when these specific prefabs are loaded into memory (either because a scene was openen which contains them or if they have been selected in the inspector during the editor session), and then the project is saved.
     
  5. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    738
    SpinningDonut.gif
    The problem is getting worse every week. We've now found cases were the affected prefabs are being reimported whenever anything changes in the project and can even become stuck in an import loop. I've reported an issue with reproduction case, but I'm still waiting for a reply. I believe it's rather difficult to reproduce for QA. The issue does not happen when one works on a single user machine, it requires at least two different users/computers to cause the serialization to randomly change. I assume it's mainly because the asset import is not deterministic and therefore, whenever one of my team mates opens their project, Unity imports the prefabs differently, but for unknown reasons this also changes the actual prefab files on disk. To reproduce this, one must setup a multi-user environment with version control. I've explained it in the bug report, so let's see what they say.
     
  6. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    544
    Ferdowsur, Xarbrough and mcarriere like this.
  7. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    738
    Thanks, that's great news! :) Is there a different issue id I can track or how will we know when the fix has landed?
     
  8. mcarriere

    mcarriere

    Joined:
    Sep 14, 2012
    Posts:
    79
    Thanks for the update @SteenLund! (I'd also love a public issue ID for this one.)
     
  9. marcin-matczak

    marcin-matczak

    Joined:
    Sep 5, 2018
    Posts:
    5
    I confirm it happening on 2019.1.14f1 and 2018.3.6f1. It also happens in the serialized scene file in the prefab modification list. This is very annoying and slows our work down. Instead simply committing all the changes I've made I have to go through list of changes and stage chunks of real changes one by one. Please fix this.
     
  10. SeductiveMango

    SeductiveMango

    Joined:
    Jun 3, 2019
    Posts:
    1
    Happening on 2019.1.5f1. Making it neigh impossible to work on entire prefabs since it just constantly is updating.
     
  11. mcarriere

    mcarriere

    Joined:
    Sep 14, 2012
    Posts:
    79
    @SteenLund Any updates or versions we can be looking forward to for this fix?
     
  12. Vince-Chimp

    Vince-Chimp

    Joined:
    May 28, 2018
    Posts:
    14
    I'd also be interested in a bug reference to track this. @SteenLund
     
  13. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,076
  14. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    78
    Happening in 2019.2.1f1 as well :\
     
  15. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    92
    Same here, exactly same behavior, ordering of modifications changes.
    In example below it's moved 50 lines up for no particular reason.

    It's big issue for us, because we use nested prefabs heavily and this change triggers reimport of all dependent prefabs, which can take minutes. Worse this happens when prefab is clicked in project, because it opens it in inspector and then it saves it right away.

    Naive approach to fixing this seems like sorting modifications by property path.

    upload_2019-10-21_16-45-34.png
     
    Jes28 likes this.
  16. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    113
    This issue has a been fixed for 2020.1 and backports are in progress.
     
    phobos2077, Peter77, OndrejP and 2 others like this.
  17. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    92
    Great news! Thank you!
     
  18. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    78
    Has the fix been backported to 2019.2 yet? If so, what version? :)
     
  19. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    113
    This fix has been verified in the following versions:
    2019.3.0f1
    2019.2.14f1
    2018.4.14f1
     
    hnngaf likes this.
  20. Wikzo-DK

    Wikzo-DK

    Joined:
    Sep 6, 2012
    Posts:
    78
    Great! Looking forward to trying it soon :)
     
    Mads-Nyholm likes this.
  21. Aides

    Aides

    Joined:
    Sep 10, 2012
    Posts:
    9
    @Mads-Nyholm has the fix already landed? I am still experiencing this issue in 2019.3.0f6.
    Namely shifted property blocks as described by @OndrejP and arbitrary changes of floating point values.

    I'd have to verify again but I think it happens even when working locally on one machine. I save a scene/prefab, commit to version control, reopen the scene, save again (without doing any changes) and have changes in version control.
     
  22. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    113
    Can you post a screenshot of the diffs you are getting?
     
  23. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    544
    If the scene gets dirty by simply opening the scene it means you have a script that makes changes to th scene during load. This could easily explain the differences you seen in version control.

    I have seen plugins that would destroy and recreate objects during load of a scene, causing blocks of changes in the scene file. If this is happening to you there is nothing we can do about this, you will have to figure out which plugin/script that does this and contact the author.
     
  24. Aides

    Aides

    Joined:
    Sep 10, 2012
    Posts:
    9
    @SteenLund thanks for the heads-up, that might very well be the case. I will check if there is any script doing modifications and open a new post in case the problem still persists, referencing this one.
     
  25. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    92
    I'm still getting some noise when using AssetDatabase.ForceReserializeAssets compared to opening prefab in PrefabStage and saving.

    When using AssetDatabase.ForceReserializeAssets, I get the change on screenshot below.
    When I open prefab in PrefabStage and save it, the change goes away.

    This is very annoying. I use AssetDatabase.ForceReserializeAssets after Unity upgrade or script change (e.g. new field). The reason for this is I want to make clear distinction in VCS between intended design changes and structural changes.

    When I'm checking commits by other team members and most changes are structural changes unrelated to the work they did, the process gets slow and annoying.

    upload_2020-6-2_6-50-19.png
     
  26. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    92
    I've made a project with easy repro:
    (Case 1252436) AssetDatabase.ForceReserializeAssets causes VCS clutter
     
    Peter77 likes this.
  27. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    544
    @OndrejP

    Thanks we will take a look.
     
    OndrejP likes this.
  28. OndrejP

    OndrejP

    Joined:
    Jul 19, 2017
    Posts:
    92
    Peter77 likes this.
unityunity