Search Unity

Texture2D Memory usage increase when using Unity 5.2+

Discussion in '2D' started by TitanUnity, Nov 3, 2015.

  1. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Our team has encountered several problems related to Unity 5.2, several of which have been resolved. It was recommend I post here so the 2D team can investigate some remaining problems we're having:

    In 5.1.3p3 and 5.1.4, we have none of the following issues as soon as we upgrade to any of the released version in the 5.2 series we have these problems:

    1. The texture memory for many of our packed atlases doubles in size according to the profiler under Texture2d. Specifically, a packed 2048x2048 sheet that would previously consume 2mb of Texture2D memory now consumes 4mb when building using Unity 5.2.* I've tried clearing my atlas cache, rebuilding, double checking my compressions but the issue remains.

    2. The overall responsiveness of the game declines dramatically, button clicks are slow, interfaces feel less responsive and our game performs poorly.

    In this pic from 5.1.3p3, you can see SpriteAtlasTexture_Solid-4028x2048 consumes 2mb:


    Once we update to 5.2.*, all of our packed textures just increase in memory size. This can easily be reproduced by switching between the projects, and rebuilding. 5.2.* doubles the Texture2D memory usage over 5.1.3. You can see that our 2048x2048 solid sheets increase to 4mb with no other changes.


    In the example above the assets are using 'RGB Compressed ETC 4 bits' on Android:

    So if I'm understanding this right:
    2048x2084 = 4,194,304 pixels.
    4,194,304 pixels * 4 bits per pixel = 16,777,216 bits
    16,777,216 bits = roughly 2mb

    Should be 2mb, not 4mb? Still no explanation for this... any help here would be awesome!
     
    holliebuckets likes this.
  2. sandboxed

    sandboxed

    Unity Technologies

    Joined:
    Apr 6, 2015
    Posts:
    95
    >> SpriteAtlasTexture_Solid-4028x2048
    Typo? Did you mean SpriteAtlasTexture_Solid-2048x2048

    5.2 shipped ETC1 (4 bit) compression for atlases that contained alpha.
    Under the hood, the engine split the atlas into Solid, and Alpha textures and recombined them in the shader.

    From your case it seems that you were already using ETC1 compression for existing atlases, and with 5.2 this might be falsely picked up by the alpha splitting flow.

    Are you using the "Compress using ETC1 (split alpha channel)" under the android overrides?
    http://docs.unity3d.com/Manual/class-TextureImporterAndroid.html

    If not, then this is a bug.
     
  3. TobyKaos

    TobyKaos

    Joined:
    Mar 4, 2015
    Posts:
    214
    And for the slow down? I am creating a game with many UI (roughly 50 pages). I activate only those displayed and FPS is correct. But switch betwwen pages is very very slow on Android. Maybe it is the fact I desactivate the current page and activate the next (I only desac et activate the parent node of each page).
     
  4. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    180
    Thanks for the response, yes that was a typo, should be 2048x2048.

    I was NOT using the new 'Compress using ETC1 (split alpha channel)' option in the compression settings. In fact, this problem can be reproduced by simply updating to any 5.2.* Unity version. To be clear, the sheets I'm referring to are sold (no alpha), we use a packing tag to pack solids together together and compress them using 'RGB Compressed ETC 4 bits' in the android override settings. This works perfectly in the 5.1.3 and 5.1.4 versions.

    Sounds like a bug.
     
  5. sandboxed

    sandboxed

    Unity Technologies

    Joined:
    Apr 6, 2015
    Posts:
    95
    @TitanUnity It seems that the ETC1 alpha split code is picking up a false positive. Please file a bug and post the link here so that it can be taken care of. Sample project will be helpful if you can cook up one with single wave of a hand :)

    Meanwhile, we will start looking into it asap.


    @TobyKaos Some more info needed to understand the problem. It could be related to a wrong use of asset / importer settings. Can you send us a sample project with the problem?
     
  6. TobyKaos

    TobyKaos

    Joined:
    Mar 4, 2015
    Posts:
    214
    Hi @sandboxed I have speed up my menu page transition by using Bitmap font instead of Unity Dynamic fonts. As we have many texts with differents size, unity rebuild sometimes fontes atlas when I activate a new page.