Closed ronjunevaldoz closed 2 years ago
AssetStorage
is a custom KTX asset manager. In order to work with libGDX APIs - including various asset loaders - it has to extend AssetManager
. AssetManagerWrapper
is basically an extension of AssetManager
that overrides every method and delegates all calls to AssetStorage
. However, since the APIs of the AssetStorage
and AssetManager
are slightly different, not every method can be easily implemented. getDependencies
is unfortunately one of those methods. If you're getting a warning like that, it means that some loaders might not work correctly with the AssetStorage
.
That being said, I have an idea how to approach this to support a couple extra AssetManager
methods, albeit in an inefficient way. It comes down to the fact that AssetManager
uses strings (paths) to uniquely identify the assets, while AssetStorage
uses a combination of a string and asset class. To support loaders like that, I can iterate over every path/type pair and check if the path matches a single asset within the storage. It will be less efficient, but at the very least more asset loaders will be compatible.
@ronjunevaldoz I've added a path-to-identifier map in AssetStorage
. Storing this info might have some slight effect on the performance, but it allows to support a bunch of extra AssetManager
methods, and is way more efficient and less error-prone than trying to iterate over all loaded asses.
A snapshot release should be available shortly. Would you mind changing the KTX version to 1.11.0-SNAPSHOT
and checking if asset loading works correctly for you? You will likely still see some warnings, but the loading itself should be unaffected. Please verify if the loaded assets work as expected.
@czyzby hi, I just updated the version to 1.11.0-SNAPSHOT
. Assets are loading perfectly and I'm seeing this warning.
[AssetStorage] Warning: AssetManagerWrapper.getDependencies might throw an exception if multiple assets with the same path are loaded with different types.
@ronjunevaldoz That's expected, unfortunately. AssetManager
assumes that assets are uniquely identified by the file path, but that isn't always the case with AssetStorage
where you can load multiple assets as different types (e.g., an image both as a Texture
and a Pixmap
). It should work as is, but I think it's worth warning the users that in the rare case a dependency or an asset is loaded multiple times with different setup, it might cause a runtime exception. Now that I think about it, I'll extend the warning log with the asset path, and add the possibility to silence the warnings for production builds.
@ronjunevaldoz These changes are now available in the latest stable release: 1.11.0-b3
. If you encounter any other problems with asset loading, please let me know.
What is causing this warning? I am using the ktx-async
[AssetStorage] Not supported AssetManagerWrapper.getDependencies called by AssetLoader.