Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Resolved Assertion failed on expression: 'gOnDemandAssets->empty()

Discussion in '2020.1 Beta' started by transat, Feb 29, 2020.

  1. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I'm not sure where to post this as I'm not given much context but I've been getting multiples of this error lately in 2020.1.0a2x...

    Code (CSharp):
    1. Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    Any ideas?
     
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    We don't have anything logged for this. It would be very helpful if you could submit a bug report with a reproduction project.
     
  3. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    I see this a lot too.. learned to ignore it.
     
    cosydark_unity likes this.
  4. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    204
    Can you provide a way for us to reproduce this. Steps to repro, a small project that repros or if possible the actual project that repros?
     
  5. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    Hey @transat , we've figured out why the issue is happening.

    There must be a .meta file in your project which has no GUID.

    Here's a little powershell snippet to run and it'll tell you which file has that missing GUID:
    Code (JavaScript):
    1. gci -Recurse | Where{ $_.extension -eq ".meta" } | Where-Object { !( $_ | Select-String "guid:" -quiet) }
    While we get our fix out, can you add a new GUID yourself manually? (Or delete that .meta file and it'll be recreated).

    We'll handle this on our end and get it backported as well.
     
    MLipscomb, radiantboy and transat like this.
  6. transat

    transat

    Joined:
    May 5, 2018
    Posts:
    779
    I haven't been getting the error in a while as I restarted my project from scratch but good job on finding the culprit!
     
    radiantboy likes this.
  7. radiantboy

    radiantboy

    Joined:
    Nov 21, 2012
    Posts:
    1,633
    I still get it constantly, thanks for the snippet, I didnt know it was safe to wipe a meta file tho?
     
    Unity_Javier likes this.
  8. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    .meta files are created by the Unity Editor. The general assumption is that the Editor should only be modifying those files, and that the output is correct ;).

    Of course, in practice, that doesn't seem to be the case, and we need to guard against that.

    Deleting the .meta file will recreate it when calling Refresh and assign it a valid GUID.

    In this case, when the GUID is not there, an uninitialized GUID gets put into the database and then a number of systems don't expect that (as its a pretty fundamental thing to rely on correct .meta files, and also ensuring this assumption is correct helps to simplify the code we have), and so some Asserts will get triggered.

    I'll add an error message with some steps to follow, since sometimes you might not want to delete your entire .meta file and just add the line:

    guid: [some guid value]

    into it
     
    radiantboy and LeonhardP like this.
  9. Pixel2015

    Pixel2015

    Joined:
    Mar 10, 2016
    Posts:
    35
    Just updated to 2019.4 LTS and now getting spammed with these. Did you already fix it?
     
  10. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    Hey, the fix is on its way to our main branch, and it will be backported to 2019.4 shortly after.

    Can you check which .meta files you have with no guid inside of them? You can do so by running this command on powershell:


    gci -Recurse | Where{ $_.extension -eq ".meta" } | Where-Object { !( $_ | Select-String "guid:" -quiet) }
     
    Pixel2015 and LeonhardP like this.
  11. Pixel2015

    Pixel2015

    Joined:
    Mar 10, 2016
    Posts:
    35
    Thanks I solved it by removing one of my packages, very specific scenario where I am developing a package inside an Unity assets folder where this package has autoupdate feature which triggered and updated itself but through a package manager. So it was both inside PackageCache and Assets folder.

    Once I cleared one of them the error went away.
     
  12. bastianLstrube

    bastianLstrube

    Joined:
    Feb 15, 2014
    Posts:
    9
    Hello!

    Found this thread and wanted to help out after getting this error:
    Code (CSharp):
    1. Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    and:
    Code (CSharp):
    1. An infinite import loop has been detected. The following Assets were imported multiple times, but no changes to them have been detected. Please check if any custom code is trying to import them:
    2. Assets/Models/Landscape/piece_bananaHill_plainNoisy.fbx
    3. Assets/Models/Landscape/piece_BananaHill_NoisyCurve.fbx
    4. Assets/Models/Landscape/piece_BananaHill_PlainNoisy.fbx
    5. Assets/Models/Landscape/piece_bananaHill_plainNoisy.fbx
    6. ...
    7. * Removed a lot of repeating lines *
    8. ...
    9. Assets/Models/Landscape/piece_BananaHill_NoisyCurve.fbx
    10. Assets/Models/Landscape/piece_ban<message truncated>
    I got this when I exported new fbx with upper case letters.
    I have since deleted all the fbx's but unity is still throwing errors and refuse to import new fbxs.

    The project view of the folder has an interesting visual bug shown in the image attached.
    It shows a whole lot of seemingly mesh files in the folder without a container. None of the fbx files are in the folder.

    I am on linux and using Unity 2019.3.13f1.
     

    Attached Files:

  13. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    Hi @bastianLstrube

    Sorry for taking a while to reply!

    We actually have a bug on this: https://issuetracker.unity3d.com/is...e-named-assets-causes-infinite-import-looping and the fix for it should land soon.

    The issue here is that we don't gracefully handle two files having the same name in the same folder, and that causes a lot of problems. This primarily a problem on Linux since its a case sensitive file system (while Windows and OSX currently are not). We have a number of optimizations that use this assumption, and so they break down when there are case sensitive files. I know since Windows 10 and WSL it is possible to flag folders as case sensitive, but at least to my knowledge this is not a common practice in Windows.

    In the meantime, I would recommend keeping this in mind and staying away from having multiple files named the same in the same folder, just with different cases (i.e. myFile.png & myFILE.png).
     
    sniffle63 likes this.
  14. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Hello!

    I just ran the PowerShell command you suggested to try and fix the error in our project
    upload_2020-6-18_23-58-12.png

    But after running your command in our projects directory, it returns no files upload_2020-6-19_0-2-3.png

    version 2019.4.1f1

    Any ideas on what we can do?
     
    Last edited: Jun 19, 2020
  15. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    Hey, perhaps you can run this script on your project: https://gist.github.com/Unity-Javier/f772a9b0a8077f642e15ca71983f237f

    What this does is, it looks through your file system for all files in your project, then compares it to what AssetDatabase.GetAllAssetPaths gets, ignores .meta files, and then outputs the paths that are not inside AssetDatabase.GetAllAssetPaths.

    I'll leave the code here too, in for future reference:

    Code (CSharp):
    1. using System.Collections.Generic;
    2. using System.IO;
    3. using System.Linq;
    4. using UnityEditor;
    5. using UnityEngine;
    6.  
    7. public class FindProblematicAsset
    8. {
    9.     [MenuItem("AssetDatabase/ZeroGUID")]
    10.     public static void GetZeroGUID()
    11.     {
    12.         var allFiles = Directory.EnumerateFiles("Assets", "*").ToArray();
    13.         var allAssets = new HashSet<string>(AssetDatabase.GetAllAssetPaths());
    14.  
    15.         for(int i = 0; i < allFiles.Length; ++i)
    16.         {
    17.             //Make sure we have forward slashes only
    18.             var curFile = allFiles[i].Replace(@"\", "/");
    19.  
    20.             //Ignore .meta files as they're not part of AssetDatabase.GetAllAssetPaths();
    21.             if (!curFile.EndsWith(".meta") && !allAssets.Contains(curFile))
    22.             {
    23.                 Debug.Log($"File path is in project, but not found inside AssetDatabase: {curFile}");
    24.             }
    25.         }
    26.     }
    27. }
    Here it should find an asset with a zero GUID, and then you could perhaps inspect its corresponding .meta file for issues, or reimport the asset to see if that solves the problem, or just dirty the asset and get trigger another import of it. That's my guess for now at least :)
     
    FlightOfOne and sniffle63 like this.
  16. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365


    Thank you so much for the fast reply!

    Unfortunately the only file it found was
    upload_2020-6-19_10-26-42.png

    Which was strange to find in my asset folder, but alas was not the problem.

    The reason we are trying to fix it is because we had updated to 2019 and now when we load our assetBundles into the game the lighting isn't the same as what is shown in the editor and we were assuming the missing GUID's might of been making the asset bundles not load/build correctly.

    (The lighting is broken loading the 2018 asset bundles into the 2019 client as well as loading the 2019 build of the assets into a 2019 client, but only in a built version of the game, it looks fine playing the game in editor, and was perfectly fine on 2018)
     
  17. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    Ok, so just trying to understand this.

    Are you saying you baked a lightmap and put it inside of an AssetBundle in Unity 2018, and then on Unity 2019 you load that assetbundle to get the light out and its broken? Or are you seeing some null references between objects?

    Since the powershell script I shared didn't point out any files that were malformed, then it looks like there are multiple ways that we can get into that state where we have a GUID that's invalid (i.e. its all zeros) and then this Assert eventually gets triggered as that invalid guid gets added to the AssetDatabase.

    I'm still not 100% sure I understand how to get into this state. Is it just making an AssetBundle with lightdata in it, in a previous version of Unity, and then opening it in a new version and loading the lighting data from it in 2019.3?
     
  18. Lostlogic

    Lostlogic

    Joined:
    Sep 6, 2009
    Posts:
    693
    I'm getting this error as well (Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off') in 2019.4.0f1. Should I expect it there? Any way to fix? The powershell script didn't find any issues.
     
  19. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365


    We resolved the lighting problem by just re-updating the project from 2018 to 2019 and re-updating the asset bundle from 2018 to 2019.

    We are still constantly getting the gOnDemandAssets->empty() || GetOnDemandModeV2() error.

    Every time I compile or change scenes or really do any action in the editor it will cause 1-4 copies of the error, but only on the project that holds the assets that we build out and stream into the other project. On the project that holds the game logic, we do not get the error.



    I'll happily help you track down the cause of the error if it seems our project is in a different state then what you are normally experiencing this issue from.
     
    Last edited: Jun 28, 2020
  20. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    So, the way we found the other problem was because someone had submitted their project through FogBugz, and we debugged it through. It didn't take long to find the issue since we could trigger it every time we changed an asset, otherwise we'll just end up shooting in the dark.

    The easiest thing for us could be that you submit a bug with your project + library and then we can debug through it to find what is triggering the assertion, since it doesn't seem like its the same issue as the other users have had.
     
  21. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    @Lostlogic if the powershell script didn't find any .meta files without GUIDs, and the code snippet I put above doesn't return anything interesting, then submitting a bug with your project would be the easiest for us to debug through and try to find what the issue is.
     
  22. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    Unfortunately, it is an NDA project :/

    Maybe I can get a test scene to reproduce it, but it's not likely. The project has 100+ gigs of assets in it that we split into different bundles to load into the game.
     
  23. andrewdbanks

    andrewdbanks

    Joined:
    Feb 4, 2014
    Posts:
    27
    Hi, I've got a similar project that I'm running into these issues on Linux with, and it doesn't misbehave in Windows. I ran what I believe to be the Linux equivalent of the command you posted, @Unity_Javier , in my project directory.

    Code (CSharp):
    1. grep -RL --include=\*.meta "guid:" ./*
    I don't appear to have any files without GUIDs. I've got three errors in my console log with the same error. One might infer that I've got three files missing GUIDs somewhere in my project given that I've got three of these errors, so perhaps there's another grep command I could run to track them down? Maybe the GUID isn't missing, but maybe it's all zeroes, or negative, or some other error string? I'm running Unity 2019.3.14f1. And for the record, importing assets into this environment took 12 hours after I removed two directories that were definitely causing case-sensitive issues on Linux and holding up the import process altogether. In other words, I'm not surprised that I'm seeing more asset-database-related issues after that import. Everything else about running this project on Linux seems to be terribly slow too, and I suspect that it's all related.
     
  24. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    Besides the Powershell script, there's the code snippet I shared earlier: https://forum.unity.com/threads/ass...on-gondemandassets-empty.837835/#post-5999264

    Perhaps that could help?
     
  25. Timbecile76

    Timbecile76

    Joined:
    Jul 8, 2009
    Posts:
    248
    @Unity_Javier - I've been getting this problem also, and now it seems like it won't let me bake a navmesh because of it. I tried running the PS script as well as the Unity Script but it reports no issues. Do you have any other recommendations to fix it?

    My project is pretty huge, so I think sending it over to you guys might be impractical.
     
    sniffle63 likes this.
  26. magg

    magg

    Joined:
    Sep 29, 2013
    Posts:
    74
  27. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    The last known tip I have is to delete the file SourceAssetDB file inside the Library folder, but that will cause a full project reimport.

    I'm kind shooting in the dark here, but I can tell you that someone else reported the issue that we originally fixed and with their project we found the NULL GUID problem in around ~20 minutes, so its a lot faster and more precise for us to see what the issue is when the project is supplied. The fix should also be present in the latest 2019.4 build as well, but just a HEADS UP, it will cause a full project reimport since the SourceAssetDB would have some NULL GUIDs in it, which was causing the Assert to come up in the first place.

    @Timbecile76 I want to help, and I'd be happy to get a massive project and pinpoint the issue. We can DM if you'd prefer to share it some other way than over Fogbugz (although that is preferred for various internal tracking reasons) and we can get this issue looked at very soon (i.e. within a week or 1.5 weeks from now).
     
    LeonhardP likes this.
  28. KingCeryn

    KingCeryn

    Joined:
    Feb 8, 2018
    Posts:
    158
    Mind explaining how to run that powershell script? We needed to delete the Library folder to refresh the project, and now we're getting this with every save, every change, every single thing we do. Really getting to us, cant find any assets that would cause this randomly.

    EDIT: ran it and deleted the two files it caused, but we get there error now on EVERY SINGLE ACTION. dragging an object into a prefab. changing a name. saving. anything.

    We're starting to get a little demoralized. Can't find anything that would be causing this...

    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    UnityEditorInternal.InternalEditorUtility:projectWindowDrag(HierarchyProperty, Boolean)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
    Last edited: Sep 24, 2020
  29. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    Hey @TaylorCaudle
    If the powershell script identified some files, and that didn't fix the entire issue, you could try to find the SourceAssetDB file in your Library folder and delete it. It'll cause the project to be reimported.

    If it still happens after that, can you zip up the project and send it to us (in a bug)? That way we can really try to target why its happening to your project.
     
  30. KingCeryn

    KingCeryn

    Joined:
    Feb 8, 2018
    Posts:
    158
    I deleted the Source DB file, but nothing changed. Currently deleted the Library folder again, and reimporting, but if that doesn't fix I'm not sure i can upload the project, its 60gb
     
  31. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    I hope that the problem goes away with reimporting the project, but it would be worthwhile for us to still have a look through the project in a "corrupted" state, to figure out why it got there.

    The last time someone submitted their project we were able to figure out the issue in about 20 minutes.

    60GB is fine from our end, but if there are other issues that prevent you from uploading it, then we can try and work through those.

    As you can see from all the replies to this thread, it is a recurring issue and it looks like we can get there multiple ways, not just having an invalid GUID in a .meta file.
     
  32. KingCeryn

    KingCeryn

    Joined:
    Feb 8, 2018
    Posts:
    158


    Nope, its still there no reimport. How would I go about sending the project? Zipping it up?
     
  33. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    If you make a bug, and zip the project up we can grab it from FogBugz!

    How to make a bug report

    Once you submit the bug, post the case number here and we'll get to it right away!

    (if that fails, I'll DM you with what we can do otherwise)
     
  34. KingCeryn

    KingCeryn

    Joined:
    Feb 8, 2018
    Posts:
    158
    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    UnityEditor.ProjectBrowser: DeleteSelectedAssets(Boolean)


    IT's giving me a variation of the error with every action now, i dont know if that relevant.Are you sure its related to GUI?

    This was generated when deleting a file
     
  35. Unity_Javier

    Unity_Javier

    Unity Technologies

    Joined:
    Mar 7, 2018
    Posts:
    190
    That's just the managed callstack.

    If you want to see more, you can set it up to give you the full stack trace, so you can also see where in the C++ code this assert is coming from.

    You can do so via:
    upload_2020-9-24_16-5-59.png

    And then the callstacks will have a lot more information with them :)
     

    Attached Files:

  36. KingCeryn

    KingCeryn

    Joined:
    Feb 8, 2018
    Posts:
    158
    Okay, managed to fix it- we ROLLED THE DICE, and upgrade from 2019.4.1 to 2019.4.11

    That upgrade managed to kick out the SPECIFIC meta file that was causing this. either deleting it or the update itself fixed it. Thank you for this, we would NEVER have figured this out on our own!
     
    Last edited: Sep 25, 2020
    Unity_Javier likes this.
  37. n-gist

    n-gist

    Joined:
    Mar 7, 2016
    Posts:
    41
    Ran into this issue, got lone "Assertion failed on expression: 'sceneRanges.empty()'" error on play in Editor
    Scripts from topic show nothing, deleting Library doesn't helps.
    Windows, 2020.2.0b13

    Discovered some things influencing it.
    1. Happens only when Auto Generate for lightmapping is off. No errors if it is on.
    2. Disabling 'Enter Play Mode Options' removes error.
    3. Enabling 'Enter Play Mode Options' returns error back, but only starting from second hit of Play button. Something dependent on static fields?
    So, it happens only when 'Enter Play Mode Options' is on and Auto Generate for lighting is off, in our case
     
  38. GameDeveloper1111

    GameDeveloper1111

    Joined:
    Jul 24, 2020
    Posts:
    100
    I needed to add `SearchOption.AllDirectories` in `Directory.EnumerateFiles("Assets", "*", SearchOption.AllDirectories)` to get the script to search deep.

    It found no corrupt meta files, however. Neither did the powershell command. Also deleting SourceAssetDB didn't work for me.

    My case:

    2020.2.0f1 HDRP template with `Enter Play Mode Options` enabled:

    upload_2020-12-24_7-45-24.png

    upload_2020-12-24_7-45-50.png

    upload_2020-12-24_7-46-16.png

    Some other settings I changed in the template:
    - Architecture from 32 to 64 bit:
    - .NET from 2.0 to 4.x
    - Vsync off:
    - High Quality as default

    I'm on Windows 10.

    The reason for enabling Enter Play Mode Options is to prepare to use DOTS, since DOTS-based projects enter play mode far faster with Enter Play Mode Options enabled.

    # Edit:

    I think you and I are in the wrong thread:

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

    !=

    Assertion failed on expression: 'gOnDemandAssets->empty()

    Though maybe there's a connection.
     
    Last edited: Dec 24, 2020
  39. n-gist

    n-gist

    Joined:
    Mar 7, 2016
    Posts:
    41
    It seems so. I made a bug report some time ago, maybe it will be fixed after the holidays.
     
  40. FireGZ

    FireGZ

    Joined:
    Jan 21, 2021
    Posts:
    1
    I got a different problem for me it says these 2 Assertion failed on expression: '!path.empty()' and Assertion failed on expression: 'createdDirectory' Please help
     
  41. Roboserg

    Roboserg

    Joined:
    Jun 3, 2018
    Posts:
    83
    I still have
    Assertion failed on expression: 'sceneRanges.empty()'
    on Unity 2020.2, wasn't it fixed 2 years ago?
     
  42. gewl

    gewl

    Joined:
    May 19, 2016
    Posts:
    95
    I'm on Unity 2019.4.20f1, URP 7.5.2, been getting the gForceReimports->empty() error for a couple months now. Neither the PowerShell command nor the editor script turn up any problematic assets. Are there any other available fixes for this?
     
  43. GambitMonkey

    GambitMonkey

    Joined:
    Apr 5, 2016
    Posts:
    65
    I am also getting the Assertion failed on expression: 'sceneRanges.empty()' on Unity 2021.1.2f1

    Did anyone ever figure out what could be causing this?
     
  44. vildauget

    vildauget

    Joined:
    Mar 10, 2014
    Posts:
    121
    Been struggling with the Assertion failed on expression: 'sceneRanges.empty()' after importing my project into the HDRP Demo scene, and as suggested above, it has to do with the Enter Playmode options. Adding "Reload Scene" tick-box fixed the error message for me, and doesn't take long at all to reload, so might be worth a try.

    upload_2021-4-11_16-29-58.png
     
  45. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    These problems are likely instances of this known issue:

    https://issuetracker.unity3d.com/product/unity/issues/guid/1184204/

    A fix is currently being reviewed.
     
    Unity_Javier likes this.
  46. jf3000

    jf3000

    Joined:
    Dec 31, 2013
    Posts:
    166
    Its interesting after all this time since 2018 and Unity still hasn't figured out what is causing this annoying issue.
     
  47. Lorrak

    Lorrak

    Joined:
    Sep 17, 2019
    Posts:
    50
    Code (CSharp):
    1. Assertion failed on expression: 'deduplicatedCount > 0'
    2. UnityEditor.EditorApplication:Internal_CallGlobalEventHandler ()
    3.  
    is it somehow related? i got 4x this error after using Recorder api.. maybe taking screenshots did something or that I duplicated some images but outside Unity, in macos Finder..

    2021.3.29f1


    edit.
    deleted the 4 .meta files from (image duplicates) that didnt help, but once I deleted the whole folder's meta file it looks like it helped

    edit.
    well it not helped
    Code (CSharp):
    1. Game scripts or other custom code contains OnMouse_ event handlers.
    2. Presence of such handlers might impact performance on handheld devices.
    3. UnityEditor.EditorApplication:Internal_CallGlobalEventHandler ()
    4.  
    5. Assertion failed on expression: 'deduplicatedCount > 0'
    6. UnityEditor.EditorApplication:Internal_CallGlobalEventHandler ()
    7.  
     
    Last edited: Oct 18, 2023