Starting with Addressables 1.16.1 GetDownloadSizeAsync() doesn’t work for scene assets when running with the fast mode build script (the “Use Asset Database” option). When attempting to use it, it fails with an InvalidKeyException reporting that the key cannot be found. GetDownloadSizeAsync() still works as expected for the “Simulate Groups” and “Use Existing Build” play mode options. Also, LoadSceneAsync() still works as expected in all build modes.
I did some digging into the Addressables source code, and I believe the source of the problem is in AddressableAssetSettingsLocator.GatherEntryLocations(). Specifically the problem is in the following code starting at line 163:
if (e.IsScene)
{
if (type == typeof(SceneInstance))
locations.Add(new ResourceLocationBase(e.address, e.AssetPath, typeof(SceneProvider).FullName, typeof(SceneInstance)));
}
When attempting to directly load the scene, then type will be SceneInstance and so the location will be added correctly. However, when doing GetDownloadSizeAsync(), then type is object and so the type check fails. I believe this should instead be using IsAssignableFrom() for the type check, since that better covers cases like this where a base class is provided instead of a concrete type. IsAssignableFrom() seems to be used in the other instances of type checking logic in the same function, so it seems like this one case is incorrect.
I’m also going to file a direct bug report, but I wanted to get this posted on the forums for visibility to other Addressables users, and to provide the additional information that I found while debugging the problem.