Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

(Case 1117939) (Bug) Unity 2018 broke the asset import and therefore our CI/CD setup reproducable

Discussion in 'Editor & General Support' started by MNNoxMortem, Jan 18, 2019.

  1. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    Hi!

    Wanted to see if anyone else encountered the same and hopefully found a workaround.

    Unity 2018 (Unity 2018.3.0f2, 2018.3.2f1) reproducable broke our asset import.
    • Delete /Library, /Obj (and whatever other temp folders you have)
    • Open the project (does not matter if via hub or command line)
    • Wait until import is done
    • Prefab state is incorrect
      • References to most ScriptableObject *.asset are null
      • This breaks many of our tests and obviously play mode as well
    • Project/*.asmdef/Test state is incorrect
      • No tests are detected - the window shows 0 tests (playmode & editor)
      • This causes running tests from the command line to always succeed. No tests found => no failed test.
    And this is our manual workaround, but this is not something I was able to integrate into our CI/CD workflow
    1. Search t: prefab
    2. Select All
    3. Reimport
    4. Search t:script
    5. Select All
    6. Reimport
    7. If tests show, continue. Otherwise go to 4.
    8. Run tests
    9. If tests fail because references to *.assets are null repeat 1. to 3. and go to 8. otherwise done.
     
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you provide steps to reproduce on a new/empty project? And the first step in the bug report is "provide a cloud space", can you elaborate? Does this reproduce locally?
     
  3. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @JeffDUnity3D I'd like to upload the large project and we usually get a password protected cloudspace to upload the project in such cases. The unity uploader takes forever with our project aand always crashes on zip compression or upload step. That is why I for this particular project I always request the cloud space and usually get one provided :)


    This reproduces on every of our teams developer machines locally.

    I might try to create a MRE - but not before mid februar. We are really under pressure at the moment and as much as I wished to help out earlier, there is not the time right now.
     
    Last edited: Jan 18, 2019
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Not your full project, a minimum project that reproduces the issue. Otherwise it will likely not be looked at any time soon.
     
  5. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    As said, I wished I could help you out earlier - but we simply do not have time for that at the moment.

    I opened the thread to see how many others have run into this, to see if this is a project specific issue or a bug affecting a wide range of users. We might try to strip it down in mid Februar.
     
  6. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Got it, so it's a lower priority for you, just checking.
     
    MNNoxMortem likes this.
  7. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Again, same suggestion, not your big project, but a MRE (I have no idea what that means, hopefully "minimally reproducible something"). And not the steps that YOU take to reproduce in your project, but the minimal steps that someone else would need to take in a new/empty project. This ALWAYS speeds up resolution.
     
    MNNoxMortem likes this.
  9. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    Example.
     
  10. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    Perfect! Yes, one of those would help.
     
  11. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    Was not able to reproduce it in a new project yet. Will have to invest more time slowly porting part by part of the other project to the reproduceable project to see when and how it starts to break :(

    Code (CSharp):
    1.  
    2. [MenuItem("Fix Assets")]
    3. public static void FixBrokenAssets()
    4. {
    5. var paths = AssetDatabase.GetAllAssetPaths().Where(p => !IgnoreAssets(p));
    6. var pathArray = paths as string[] ?? paths.ToArray();
    7. var scripts = pathArray.Where(IsScript);
    8. var scriptableObject = pathArray.Where(IsScriptableObject);
    9. var prefabs = pathArray.Where(IsPrefab);
    10. var asmdef = pathArray.Where(IsAsmdef);
    11. foreach (var path in scripts)
    12.     AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
    13. foreach (var path in scriptableObject)
    14.     AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
    15. foreach (var path in prefabs)
    16.     AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
    17. foreach (var path in asmdef)
    18.     AssetDatabase.ImportAsset(path, ImportAssetOptions.ForceUpdate);
    19. }
    20.  
    21. private static bool IgnoreAssets(string path) =>
    22.     string.IsNullOrEmpty(path) || path.StartsWith("Packages") || path.StartsWith("ProjectSettings");
    23.  
    24. private static bool IsScript(string path) => path.EndsWith(".cs");
    25. private static bool IsScriptableObject(string path) => path.EndsWith(".asset");
    26.  
    27. private static bool IsPrefab(string path) => path.EndsWith(".prefab");
    28.  
    29. private static bool IsAsmdef(string path) => path.EndsWith(".asmdef");
    30.  
    This obviously is a horrible solution and increases the time each CI configuration takes by one order of magnitude for us (except actual building a player obviously) but it at least it DOES fix the problem temporarily. I need to see if this fix is table or if batchmode exits before it is done - what I actually fear because I am pretty sure it does so before recompilation.

    Edit: Updated the order of imports as scripts and scriptable objects have to be reimported before prefabs using them to fix the prefabs and the asmdef has to be reimported to find the tests after the scripts have been reimported.

    Edit2: Added missing helper methods.
     
    Last edited: Jan 28, 2019
  12. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @JeffDUnity3D we got the mail, that the bug was reproduced (Case 1122461)
    and sent to the developers. Is there any known fixed in version yet? This still heavily hinders us in Unity 2018.3.12f1 which was just released and makes a reliable build impossible.

    In essence: Since months this bug breaks our CI/CD pipeline as the only way to reliable get a build which does not run into this bug is to manually reimport in the correct order (script, scriptableobjects, prefabs) and wait long enough until unity has stopped any processing between each step. Even the script above does not work reliably and I assume the reason is because there are likely a lot of timing issues (Unity does a lot of stuff when you reimport, e.g. recompilation starts to trigger and I assume unless it is completly done with all operations the bug persists)