Assertion failed on expression: Error on saving scene

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.

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

1 Like

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

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.

2 Likes

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

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:smile:eleteAsset(String)
Assertion failed on expression: 'gOnDemandAssets->empty() || GetOnDemandModeV2() != AssetDatabase::OnDemandMode::Off'
UnityEditor.AssetDatabase:StopAssetEditing()
UnityEditor.ProjectWindowUtil:smile:eleteAssets(List`1, Boolean)
UnityEditor.ProjectBrowser:smile:eleteSelectedAssets(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.

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. :slight_smile:

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.

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.

1 Like

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.

@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.

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: Imgur: The magic of the Internet

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.

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.

@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.

@jdrewsen Pinging this thread again in case you haven’t seen this yet, since I know you were asking for a repro earlier.

yup. I get it a ton also.

Interestingly, we haven’t noticed this issue in our project for a week or so. Very strange.

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.

@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.

1 Like