jonlab / NewAtlantis

http://www.newatlantis.world/
9 stars 6 forks source link

Asset Bundle loading exception #19

Closed jonlab closed 8 years ago

jonlab commented 8 years ago

Asset : FLOOR - sachaamm

You are trying to load data from a www stream which had the following error when downloading. Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle. UnityEngine.WWW:get_assetBundle() NAObject:Process() (at Assets/NewAtlantis/Core/Scripts/Main/NAObject.cs:84)

benchang02 commented 8 years ago

Does this happen with other bundles or just this one? And is it after loading another bundle or does it happen when it's the only one loaded?

(does bundle export usually generate unique names to avoid filename clashes? I see some stuff in the docs about this, but it also looks there are different ways of making bundles)

On December 5, 2015 10:17:51 AM EST, Jonathan Tanant notifications@github.com wrote:

Asset : FLOOR - sachaamm

You are trying to load data from a www stream which had the following error when downloading. Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle. UnityEngine.WWW:get_assetBundle() NAObject:Process() (at

Assets/NewAtlantis/Core/Scripts/Main/NAObject.cs:84)


Reply to this email directly or view it on GitHub: https://github.com/jonlab/NewAtlantis/issues/19

Sent from my Android device with K-9 Mail. Please excuse my brevity.

jonlab commented 8 years ago

I did more tests, and it seems that we have the issue when 2 different Asset bundles were exported from the same asset and imported in the platform (so we have technically 2 .unity3d files containing the same Assets). I should be able to unload the Asset bundle with bundle.Unload(false) , but for some reasons it does not work and we still have the same exception.

jonlab commented 8 years ago

There seems to be something strange with the Unity asset bundle cache and the asset bundle Unload() : when I load the asset bundle direcly with www = new WWW (url); the Unload() works and there is no exception when the same asset bundle is loaded again. But when I load the asset bundle using the cache with www = WWW.LoadFromCacheOrDownload(url, 1);, then the Unload() does not seem to work and we have the exception at the next load. Fix would be to manually manage an asset bundle cache.

benchang02 commented 8 years ago

Is that something that could happen often, or is it an edge case?

For instance, say I have a sound file of a radio broadcast, I attach it to a 3D model of a bicycle, and export that as an asset bundle. You take the same sound file, attach it to a refrigerator, and export a second asset bundle. Would that trigger the naming exception? Or is it smart enough to know the sound file is the same and not try to load it again?

On 12/6/15 4:51 AM, Jonathan Tanant wrote:

I did more tests, and it seems that we have the issue when 2 different Asset bundles were exported from the same asset and imported in the platform (so we have technically 2 .unity3d files containing the same Assets). I should be able to unload the Asset bundle with bundle.Unload(false) , but for some reasons it does not work and we still have the same exception.

— Reply to this email directly or view it on GitHub https://github.com/jonlab/NewAtlantis/issues/19#issuecomment-162292692.

Benjamin Chang Associate Professor, Department of the Arts Director, Games and Simulation Arts and Sciences Rensselaer Polytechnic Institute 110 8th Street, Troy, NY 12180 changb3@rpi.edu 518.276.2366

jonlab commented 8 years ago

Well, this happens when one user exports the same prefab as an asset bundle and imports it twice in the platform, so, this could happen pretty often. I think that the best is to manage the cache manually as there seems to be a bad side effect with the integrated WWW cache with asset bundles.

benchang02 commented 8 years ago

I don't know the bundle management system too well ... are we using the 4.x method or the 5.x method?

On December 7, 2015 3:14:12 AM EST, Jonathan Tanant notifications@github.com wrote:

Well, this happens when one user exports the same prefab as an asset bundle and imports it twice in the platform, so, this could happen pretty often. I think that the best is to manage the cache manually as there seems to be a bad side effect with the integrated WWW cache with asset bundles.


Reply to this email directly or view it on GitHub: https://github.com/jonlab/NewAtlantis/issues/19#issuecomment-162445052

Sent from my Android device with K-9 Mail. Please excuse my brevity.

jonlab commented 8 years ago

the 4.x method for now, with a call to BuildPipeline.BuildAssetBundle() in an editor script.

jonlab commented 8 years ago

I narrowed down the issue with a simple test case, and it turns out that caching with several WWW downloading in parallel is not supported, the Cannot load cached AssetBundle. A file of the same name is already loaded from another AssetBundle. exception occurs. Workaround could be to load the asset bundles one after the others. I am working on that.

jonlab commented 8 years ago

Ok, this is fixed. We now have only one WWW download the Asset Bundles at a time and it works with the cache and with duplicate Asset Bundles.