Asset fileID set to 0

Hey there! We’ve started getting InvalidKeyExceptions in the editor lately, despite the key existing.

We’d also been getting null refs on InitializeAsync, which we fixed by deleting some files in our groups that had “Missing Path” in the path field.

I’d occasionally noticed the same file in multiple groups. The only fix for this appears to be deleting the asset from the groups and re-adding it.

We’ve traced our InvalidKeyExceptions issues to the fileID for m_MainAsset/m_TargetAsset being 0. It appears fine in the inspector, but you can see it occurring in the group’s .asset file.

I’m not sure how this is happening, but on making changes to our addressable groups I’ve noticed that fileIDs were being set from valid references to 0, or from 0 to a valid reference, seemingly at random.

I can only assume that we’ve got some corrupt data, and I suspect it might be related to committing groups separately (leading to the same asset in two groups), but I don’t really understand what’s going on. For now we’re just being super careful about what we commit, but there’s clearly something horrible going n here.

Can you explain why this might happen, and what we can do to avoid it?

Ta!

1 Like

More info - in the debug inspector those assets are null (as you’d expect). I don’t know how this system works really, but I’d assume they should never be null? Unless they’re grabbed from the GUID?

Anyone? I imagine this bug is quite rare or we’d see more reports, but it’s quite a bad one, especially for less-programmery types who expect this stuff to just work. The standard error messages are really quite esoteric.

Thanks for flagging! I’ll kick this over to the team. Which version of Addressables are you using?

Also, if you haven’t yet, please go ahead a file a bug report for us: Unity QA: Building quality with passion

This is also happening to us - mostly when adding a new item to a addressables group - I’ve seen it on the latest version of addressables, and also the recommended version for our current Unity version (1.13.0 & 1.8.4 respectively)

Is there a bug I can keep an eye on for this?

I’ll flag this up for you!

I’ve seen this a few times since, it’s really quite dangerous!

My two leads right now are:

Assets removed from the project are still listed in the addressable groups (and this seems to block building only in some cases).
Upgrading the Addressables package.

After speaking with the team, looks like filing a bug report is your best course of action. This will allow us to dig a bit deeper into this: Unity QA: Building quality with passion

I have also seen fileid of several assets being set to 0 when adding or removing unrelated assets from groups.

This also been happening in our projects. Randomly the reference to assets group assets disappears.
The m_MainAsset and m_TargetAsset file id is set to 0. Have you guys manage to replicate this issue?

@TreyK-47

Let me check with the team on the status of this one.

I’ve been looking into this and I verified that this happens after opening the addressables groups menu.
The creation of the UI eventually calls AssetPath on each AddressableAssetEntry. Consequently, AssetPath calls SetCachedPath and this method sets m_MainAsset and m_TargetAsset to null. Corrupting the following serializations. As it is, these fields have no real purpose to be serialized but maybe I’m missing something.

1 Like

Any updates?

Nothing new to update. Have any of you submitted a bug report on what you’re experiencing yet? If not, please do so. This will let us dig a bit deeper into what might be going on.

We also investigate this on our side and reached the same conclusion, at the moment those fields have no real purpose being serialized, to “fix” this, you can just remove the serialization.

We have the same problem. Any news?

Our team has been having this issue for a while, where commits to the Default Asset Group will include seemingly spurious changes to the fileID of other assets in the group, setting them to zero, like this:


Later in development, another team member will have a commit that undoes those changes automatically (in the same way we do not understand the first commit)

We don’t understand how to create a repro case yet. This is the information we have:

  • Unity Editor 2019.4.16f1 (Windows 10 and Mac 10.15.6)
  • Addressables 1.16.15
  • Platform: iOS
  • Asset Serialization Mode: Force Text
  • Example affected group: Default Asset Group (Pack Separately)
  • Example commit above was created by a user that does not open any Addressables windows (as in Unity Editor menu: Window>Asset Management>Addressables>*)
1 Like

If you just drag and drop the asset to the addressable asset group, m_MainAsset in AddressableAssetEntry seems to stay at 0.
Perhaps, when the label is changed afterwards, the “MainAsset” in the following code is referenced and the value is placed in m_MainAsset.

File: Library\PackageCache\com.unity.addressables@1.16.7\Editor\Settings\AddressableAssetEntry.cs
325: [SerializeField]
326: private UnityEngine.Object m_MainAsset;
327: /// <summary>
328: /// The main asset object for this entry.
329: /// </summary>
330: public UnityEngine.Object MainAsset
331: {
332: get
333: {
334: if (m_MainAsset == null)
335: {
336: AddressableAssetEntry e = this;
337: while (string.IsNullOrEmpty(e.AssetPath))
338: {
339: if (e.ParentEntry == null)
340: return null;
341: e = e.ParentEntry;
342: }
343:
344: m_MainAsset = AssetDatabase.LoadMainAssetAtPath(e.AssetPath);
345: }
346:
347: return m_MainAsset;
348: }
349: }

I have created and used an editor script that registers the assets to the addressable asset group in bulk.

    private static void SetAssetToAddressableAssetGroup(string path)
    {
        AddressableAssetSettings settings = AddressableAssetSettingsDefaultObject.Settings;
        AddressableAssetGroup g = settings.FindGroup("GroupName");
        string guid = AssetDatabase.AssetPathToGUID(path);
        AddressableAssetEntry entry = settings.CreateOrMoveEntry(guid, g);
        entry.SetLabel("LabelName", true);

        // call getter.
        Debug.Log(entry.MainAsset);
        Debug.Log(entry.TargetAsset);

        g.SetDirty(AddressableAssetSettings.ModificationEvent.EntryMoved, entry, true);
    }

I don’t know if this is directly related to the original problem, but it seems that the m_MainAsset and m_TargetAsset fields were removed from the Serialize Field of Group Asset in Addressables v1.17.17.

1 Like