Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

SpritePacker: Cannot load Atlas [ATLASNAME] During Build/Enter Game. Please rebuild Sprite Atlas

Discussion in '2D' started by mh114, Feb 17, 2016.

  1. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    This bug is getting very annoying, so I chose to make a new thread about it. The old thread was (mostly) about a different issue.

    Of all things this bugs me the most (pun intended). I'm now in 5.3.2p3 and I get "Cannot load Atlas [ATLASNAME] During Build/Enter Game. Please rebuild Sprite Atlas." several times a day, always when I change build target and basically most of time I touch any of the sprites I have. It doesn't matter if you run the game, build it or just repack from SpritePacker: the error appears and one or more atlases break. After that point it will always complain about those atlases, spamming the same error hundreds of times when I start playmode in the editor.

    Workaround is to quit Unity, delete the AtlasCache folder and restart. These wasted minutes add up quickly.. :( This has been happening since 5.2 days at least, I think it was not in 5.1.x. I'm running Windows 10, I have not seen this on Mac (although I use it only for iOS work occasionally), so I'm assuming it's Windows-only problem.

    I tried to reproduce this with a clean project for 1.5 hours, and could not make it happen. I copied all my sprites and their settings, atlases are basically the same but no luck getting the error reproduced so I could not make a bug report. :(

    Anyone else getting this? Maybe we can narrow things down by searching for common things in the projects / systems this happens on.
     
    tanoshimi, Malkyne and Menion-Leah like this.
  2. TobyKaos

    TobyKaos

    Joined:
    Mar 4, 2015
    Posts:
    199
    Maybe you can increase cache space in editor pref?
     
  3. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    Nope, my cache only reaches about 50 megs before it craps out. Default is like 10 gigs. I did double it for fun but didn't help.
     
  4. Akta

    Akta

    Joined:
    Oct 15, 2010
    Posts:
    119
    Same problem here when I build to Android, never on iOS. Result is that I have random black sprites here and there..
     
  5. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    Yeah I forgot to mention: I switch between standalone and Android, happens on both. Have not seen it on Mac.
     
  6. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    @Venkify I'll send you PM with link to the editor log file. It was broken earlier yesterday, I switched platforms and gathered more logs in case there's something in there. It seems to occasionally spam the same error message dozens of times.

    Then I closed Unity, deleted the AtlasCache and restarted, trying to gather the reproduction steps. But of course I couldn't get it to error out! I tried switching between Android and standalone, doing some sprite changes but nothing. Usually when I'm working on sprites it will break out eventually and then one or two atlases will get broken somehow, and it will then complain about them until I clear the cache.. I can grab more logs when the error appears again, but I suspect there isn't anything new that isn't in the one I'll send you..
     
  7. bitbiome_llc

    bitbiome_llc

    Joined:
    Aug 3, 2015
    Posts:
    58
    Ran into this issue just this evening. I'd be testing a windows build and then switched to an Android build. The android build threw an error for each atlas. I blew away the atlas cache folders, packed, and the errors went away.

    Unity: 5.3.2p3
     
  8. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    Yeah it's most probably related to Android build target, either switching to or from it. The errors seem to appear after the packing is done while "Assigning cache references.." operation is in progress.
     
  9. KB73

    KB73

    Joined:
    Feb 7, 2013
    Posts:
    234
    We get this constantly on 5.3.4 even when not switching atlas. It is annoying, have to continuously delete the Atlas folder, repack the sprites..then it works for a while and breaks again. Have about 10 atlases, defaultSpritePackerPolicy, iOS platform for Editor under OSX
     
  10. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    Ok so it's not only on Windows then! I haven't seen it on OS X myself, but then again I only work there when I do my iOS builds, very occasionally. And yeah, I get it without switching platforms sometimes, but very often when doing the switch.

    @ecesis_llc , @KB73 , can you reproduce it on a small project? I've been unsuccessful. :(
     
  11. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,553
    Confirmed on OSX El Capitan Unity 5.3.4 while switching Android build too.. first I do ETC1 which is fine, but then switch to ETC2 and this happen. (and then continue to happen when switch to DXT, PVRTC)
     
    Last edited: Apr 11, 2016
  12. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,553
    For the time being I wrote this script that automatically delete your AtlasCache folder every time you finish the build. I hope it got fixed for real soon.

    Code (CSharp):
    1. #if UNITY_EDITOR
    2. using UnityEngine;
    3. using UnityEditor;
    4. using UnityEditor.Callbacks;
    5. using System.IO;
    6. using System.Collections;
    7.  
    8. public class PostBuildAtlasCacheClear : MonoBehaviour {
    9.  
    10.     [PostProcessBuild]
    11.     private static void DeleteAtlasCache(BuildTarget target, string pathToBuiltProject)
    12.     {
    13.         string projectPath = Application.dataPath; //Asset path
    14.         string atlasCachePath = Path.GetFullPath(Path.Combine(projectPath, Path.DirectorySeparatorChar + ".." + Path.DirectorySeparatorChar + "Library" + Path.DirectorySeparatorChar + "AtlasCache"));
    15.         Directory.Delete(atlasCachePath,true);
    16.         Debug.Log("Deleted atlas cache folder.");
    17.     }
    18. }
    19. #endif
     

    Attached Files:

    tosiabunio and mh114 like this.
  13. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    I hope so too, this the most annoying Unity bug I've ever encountered, plaguing me since last Fall, I think.

    Btw does it work for you if you delete the AtlasCache and won't restart Unity after that? I always restart after deleting it, then repack, which wastes even more time.. I think I tried without restart once but it didn't work, have to check again..
     
  14. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,553
    Yes it works without restarting. I build like six times in one session for all formats. I guess there's no problem since now they are all already live and no users has complained (yet)...
     
  15. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    Alright, have to try without a restart next time it happens. Shoulnd't take too long.

    Btw I did get this problem on my Mac a few days back, first time I saw this on OS X. I didn't even switch platforms, it's always set to iOS build target there.
     
  16. JasonB

    JasonB

    Joined:
    Dec 29, 2010
    Posts:
    77
    Just adding myself to the list; I find this irritating as well. Would like to see it fixed, but it's been a problem for so long I'm not sure anyone cares about it, really.
     
    zenGarden and mh114 like this.
  17. zenGarden

    zenGarden

    Joined:
    Mar 30, 2013
    Posts:
    4,538
    I agree this should be adressed.
     
  18. hadesfury

    hadesfury

    Joined:
    Jan 23, 2014
    Posts:
    51
    Does anyone post a bug report to unity ?

    I hoped that
    Code (CSharp):
    1. Packer.RebuildAtlasCacheIfNeeded(parBuildTarget, DOES_DISPLAY_PROGRESS_BAR);
    does the job .. but it does not !
     
    Last edited: May 24, 2016
  19. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    Still getting this. Has it been reported to the Unity Bug Tracker? I'd happily vote it up!
     
  20. Sphax84

    Sphax84

    Joined:
    Jun 23, 2015
    Posts:
    32
  21. tanoshimi

    tanoshimi

    Joined:
    May 21, 2013
    Posts:
    297
    The problem with that other thread is that it got off-topic when the OP placed the sprites in the /resources folder which meant that, when it did get addressed by @Aras, I'm not sure he observed that the problem was completely unrelated to that. It seems that many people have now experienced the problem, but not one has reported it as a bug which means it's unlikely to get fixed.

    Does anyone have a simple repro project that could be filed with a bug report? My project is huge. I can try to strip it down if nobody else has one. I'm not sure when the bug appears, because I'm not sure if you get it in a blank project.
     
  22. mh114

    mh114

    Joined:
    Nov 17, 2013
    Posts:
    292
    The thing is, this bug is quite difficult to reproduce consistently. I tried for a couple of hours to do a repro project, even copied all my sprites and set up the atlases pretty much like they were in my game, but couldn't reproduce the bug..
     
unityunity