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

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…

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

Any ideas?

We don’t have anything logged for this. It would be very helpful if you could submit a bug report with a reproduction project.

I see this a lot too… learned to ignore it.

1 Like

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?

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:

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.

3 Likes

I haven’t been getting the error in a while as I restarted my project from scratch but good job on finding the culprit!

1 Like

I still get it constantly, thanks for the snippet, I didnt know it was safe to wipe a meta file tho?

1 Like

.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

2 Likes

Just updated to 2019.4 LTS and now getting spammed with these. Did you already fix it?

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) }
2 Likes

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.

Hello!

Found this thread and wanted to help out after getting this error:

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

and:

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:
Assets/Models/Landscape/piece_bananaHill_plainNoisy.fbx
Assets/Models/Landscape/piece_BananaHill_NoisyCurve.fbx
Assets/Models/Landscape/piece_BananaHill_PlainNoisy.fbx
Assets/Models/Landscape/piece_bananaHill_plainNoisy.fbx
...
* Removed a lot of repeating lines *
...
Assets/Models/Landscape/piece_BananaHill_NoisyCurve.fbx
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.

Hi @bastianLstrube

Sorry for taking a while to reply!

We actually have a bug on this: Unity Issue Tracker - [Linux] Having same case-insensitive 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).

1 Like

Hello!

I just ran the PowerShell command you suggested to try and fix the error in our project

But after running your command in our projects directory, it returns no files

version 2019.4.1f1

Any ideas on what we can do?

Hey, perhaps you can run this script on your project: FindProblematicAsset.cs · GitHub

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:

using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEditor;
using UnityEngine;

public class FindProblematicAsset
{
    [MenuItem("AssetDatabase/ZeroGUID")]
    public static void GetZeroGUID()
    {
        var allFiles = Directory.EnumerateFiles("Assets", "*").ToArray();
        var allAssets = new HashSet<string>(AssetDatabase.GetAllAssetPaths());

        for(int i = 0; i < allFiles.Length; ++i)
        {
            //Make sure we have forward slashes only
            var curFile = allFiles[i].Replace(@"\", "/");

            //Ignore .meta files as they're not part of AssetDatabase.GetAllAssetPaths();
            if (!curFile.EndsWith(".meta") && !allAssets.Contains(curFile))
            {
                Debug.Log($"File path is in project, but not found inside AssetDatabase: {curFile}");
            }
        }
    }
}

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

2 Likes

Thank you so much for the fast reply!

Unfortunately the only file it found was
6000434--646022--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)

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?

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.

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.

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.