Search Unity

Assertion failed on expression: Error on saving scene

Discussion in 'Editor & General Support' started by Hawk0077, Feb 23, 2020.

  1. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    I am not sure of the cause or even if its a problem but when I save my project I get this error in the console. Does anyone know what it is and how to solve it? If its a problem.

    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'

    Many thanks.
     
  2. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    103
    Hi,
    I also have the same problem, I was hoping that with the last update it would solve, but it is still there and I don't know how to solve it, I also tried to delete the library folder and re-import the whole project, but I have not solved
     
    Hawk0077 likes this.
  3. Hawk0077

    Hawk0077

    Joined:
    Nov 6, 2017
    Posts:
    788
    Same here, 2019,3,3 didnt fix it as I hoped. But its only when I save and things do seem to save as far as I can tell
     
  4. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    Same error.
    My project in 2019.3.3 was in Asset import pipeline V1. I needed the Entities package which told me that it needs pipeline V2 (surprisingly). So I updated my project. It took hours to reimport everything and while it's working, this error is thrown anytime:
    when saving, when entering/exiting playmode, when compiling a script. It's really annoying and there is nothing in the log that helps to pin point what the issue is
    Having quite a big problem make things worse
    I did not have a single issue before enabling Import asset pipeline V2.
     
    Monil and Hawk0077 like this.
  5. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    103
    Hi,
    I tried to eliminate Burst, Mathematics, Entities, Collections and Jobs packages, delete the library and re-import the whole project, and after hours... the problem persists.

    Unity please make a stable version

     
  6. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    I'm running into this as well. It appears to have broken our ability to run Edit Mode unit tests in the Test Runner, because hitting Run All will cause the asset database to refresh and print this error, which Test Runner interprets as an exception and cancels the tests.

    Here are some example stacks from our editor logs:



    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    UnityEditor.AssetDatabase:SaveAssets()



    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    UnityEditor.AssetDatabase:Refresh(ImportAssetOptions)
    UnityEditor.AssetDatabase:Refresh()
    Packages.Rider.Editor.RiderScriptEditor:SyncAll() (at Library\PackageCache\com.unity.ide.rider@1.1.4\Rider\Editor\RiderScriptEditor.cs:235)
    UnityEditor.CodeEditorProjectSync:SyncEditorProject()
    UnityEditor.PlayerSettings:SetScriptingDefineSymbolsForGroupInternal(BuildTargetGroup, String)
    UnityEditor.PlayerSettings:SetScriptingDefineSymbolsForGroup(BuildTargetGroup, String)



    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    (Filename: C:\buildslave\unity\build\Modules/AssetDatabase/Editor/V2/V1Compatibility.cpp Line: 2841)



    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    UnityEditor.AssetDatabase:CreateFolder(String, String)



    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    UnityEditor.AssetDatabase:CreateAsset(Object, String)



    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    UnityEditor.AssetDatabase:DeleteAsset(String)



    Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
    UnityEditor.AssetDatabase:StopAssetEditing()
    UnityEditor.ProjectWindowUtil:DeleteAssets(List`1, Boolean)
    UnityEditor.ProjectBrowser:DeleteSelectedAssets(Boolean)
    UnityEditor.ProjectBrowser:HandleCommandEventsForTreeView()
    UnityEditor.ProjectBrowser:OnGUI()


    As you can see, it seems to get triggered whenever the asset database does... basically anything.


    Edit: By printing out
    UnityEditor.Experimental.AssetDatabaseExperimental.ActiveOnDemandMode, I have confirmed that the active mode is indeed Off.

    This value is settable, and setting it to either Background or Lazy does seem to make the error go away. I'm unsure which one I should set it to, though, and whether those changes will get checked in anywhere or if I will have to write a tool that constantly sets them whenever someone opens the project.
     
    Last edited: Apr 3, 2020
  7. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    Update -- it appears that manually setting ActiveOnDemandMode does fix the exception from being constantly thrown, but it replaces it with a new error:

    Tried select unknown importer for id '-1' '00000000000000000000000000000000'


    However, since this is an error and not an exception, it does not prevent unit tests from running, so I'm inclined to see this as an improvement. :)
     
  8. Monil

    Monil

    Joined:
    Apr 24, 2012
    Posts:
    103
    I eliminated the Library / ShaderCache folder eliminated ShaderCache.db eliminated CTS - Complete Terrain Shader, restarted unity, reimported CTS, recompiled all the shaders of the project and now the problem does not occur again.
     
  9. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    204
    If anyone can give me a copy of their failing project (incl. Library folder etc).. I could try to repro here and figure out what is wrong. Also please specify what version of unity you are using.

    Also.. ActiveOnDemandMode is experimental and is definitely not recommended to change. Will very likely give you other weird unexpected behaviours.
     
    Hawk0077 likes this.
  10. Necka_

    Necka_

    Joined:
    Jan 22, 2018
    Posts:
    488
    I switched back to Pipeline V1.
    The error (Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off') speaks about "OnDemandModeV2" but I didn't see/touch any settings regarding this.
     
  11. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    204
    @Necka_ ok. That error will only ever show up when using the V2 pipeline. Anyway, if you ever get your project in that failing state again I would love to get a copy of it if possible, since I haven't been able to reproduce on any of my local projects.
     
  12. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    I discovered that modifying the ActiveOnDemandMode broke things worse -- the editor would freeze when I tried to load into any halfway to complex scene, so that was a no-go.

    Here are some other errors that pop up when I load the project, which might be helpful: https://imgur.com/kqx8os7
     
  13. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    Interestingly, this does appear to be entirely related to the Library state. I made a shallow clone of our project, deleted all the assets from it, and restored them filetype by filetype. At no point did I ever get the exception to trigger.

    However, if we take our pre-existing repository clones, delete the Library folder, and let it re-import everything, we end up in the degraded state.

    There are no obvious differences between the Library folders in both projects -- everything's about the same size in Windows explorer -- but clearly something different has happened to cause this divergent behavior.

    Edit: I then tried copying the Library from the "good" project into the "bad" project, and it made the exception stop appearing. I captured a diff of the two Library folders before swapping them out, so next I'm going to go file-by-file and try to isolate which file in the Library is causing this issue to occur.
     
    Last edited: Apr 8, 2020
  14. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    Aha! I have isolated it down to the SourceAssetDB file. If I copy in the 'good' SourceAssetDB, everything works fine. If I copy in the 'bad' one, it throws errors constantly.

    Interestingly, the 'good' one is almost twice the size of the 'bad' one, which might make it hard to diff. Still, if you're interested I can share the two DB files with you.
     
  15. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    @jdrewsen I have isolated the issue down to as min a repro as I could and uploaded it through the Bug Reporter. You can find the ticket here: https://fogbugz.unity3d.com/default.asp?1238301_sgnj0slmocf7l9f9

    This issue is likely to prevent our studio from adopting 2019.3 until it is solved. I imagine getting a true fix might take some time, but if you're able to share any learnings or possible workarounds, I would be happy to test them out ASAP.
     
  16. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    @jdrewsen Pinging this thread again in case you haven't seen this yet, since I know you were asking for a repro earlier.
     
  17. SickaGames1

    SickaGames1

    Joined:
    Jan 15, 2018
    Posts:
    1,270
    yup. I get it a ton also.
     
  18. jonagill_rr

    jonagill_rr

    Joined:
    Jun 21, 2017
    Posts:
    54
    Interestingly, we haven't noticed this issue in our project for a week or so. Very strange.
     
  19. Nortivad

    Nortivad

    Joined:
    Aug 22, 2019
    Posts:
    2
    Don´t know if this could help, but I start getting this error after i accidentaly press Ctrl-S while testing. After that it seems to double interact with the library, or something like that.
     
  20. jdrewsen

    jdrewsen

    Unity Technologies

    Joined:
    Mar 28, 2011
    Posts:
    204
    @jonagill_rr we have seen your issue in projects that have malformed .meta file where for some reason the top line in that file doesn't contain a guid field. We have improved handling of this 2019.4.4f1 and forward.
     
    jonagill_rr likes this.
  21. KingCeryn

    KingCeryn

    Joined:
    Feb 8, 2018
    Posts:
    158
    Okay, I 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!

    Per another thread: the error is caused by a .META file that has no GUID, usually a custom editor image thing from a package, etc. Updating the version kicked out an error with the specific file, so try that if its an option