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.
  2. Dismiss Notice

Bug (IN-50800) HUGE performance degradation caused by one of 2D Features package

Discussion in '2D' started by KAW0, Aug 9, 2023.

  1. KAW0

    KAW0

    Joined:
    Jan 1, 2017
    Posts:
    15
    To reproduce:
    1) Create empty 2D project.
    2) Ensure that com.unity.2d.aseprite@1.0.0 is installed in project
    3) Add and use this script (this may take a while):

    Code (CSharp):
    1.  
    2. using System.IO;
    3. using UnityEditor;
    4. using UnityEngine;
    5.  
    6. public class PNGGeneratorEditor
    7. {
    8.     [MenuItem("Tools/Generate PNGs")]
    9.     static void GeneratePNGs()
    10.     {
    11.         int totalFiles = 5500;
    12.         string savePath = Path.Combine(Application.dataPath, "GeneratedPNGs");
    13.         if (!Directory.Exists(savePath))
    14.         {
    15.             Directory.CreateDirectory(savePath);
    16.         }
    17.  
    18.         for (int i = 0; i < totalFiles; i++)
    19.         {
    20.             Texture2D texture = new Texture2D(256, 256, TextureFormat.RGBA32, false);
    21.  
    22.  
    23.             for (int x = 0; x < texture.width; x++)
    24.             {
    25.                 for (int y = 0; y < texture.height; y++)
    26.                 {
    27.                     Color color = new Color(Random.value, Random.value, Random.value);
    28.                     texture.SetPixel(x, y, color);
    29.                 }
    30.             }
    31.  
    32.             texture.Apply();
    33.  
    34.  
    35.             byte[] bytes = texture.EncodeToPNG();
    36.             string fileName = $"image_{i}.png";
    37.             File.WriteAllBytes(Path.Combine(savePath, fileName), bytes);
    38.  
    39.             Object.DestroyImmediate(texture);
    40.         }
    41.  
    42.         AssetDatabase.Refresh();
    43.  
    44.     }
    45. }
    46.  
    4) Go to Task Manager to see huge CPU usage while Editor is idle (it's depends but for me it is one whole core) While profiler will not show any abnormality.
    5) Delete com.unity.2d.aseprite package from project.
    6) Notice that CPU usage is back to normal.
    Tested on Unity 2022.3.6f1 but can i belive that all versions that use com.unity.2d.aseprite@1.0.0 are affected.
    5500 PNG files are a lot, but certainly many projects have more
    Notice that even this is issue with aseprite importer project not need contain such a file to be affected.

    This is especially problematic because com.unity.2d.aseprite is part of the 2D Features meta package.
    So it affects many users who don't even use this file format.
    I don't understand why such a specific package is automatically installed.
     
    Last edited: Aug 21, 2023
  2. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    876
    Thank you for highlighting this issue and sending us a bug report. I'll take a look.
     
    KAW0 and karliss_coldwild like this.
  3. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    876
    Aseprite Importer 1.0.1 is now released with a fix to this issue. If you have the time, please upgrade to this version and give it a spin to see if we resolved your issue.
    Thanks again for letting us know.
     
    DevDunk, DavidTeo and MelvMay like this.
  4. KAW0

    KAW0

    Joined:
    Jan 1, 2017
    Posts:
    15
    It's much better, but I still see a minor impact on CPU usage on idle compared to not installing the package
     
  5. FaithlessOne

    FaithlessOne

    Joined:
    Jun 19, 2017
    Posts:
    260
    I also came across this bug when upgrading from Unity 2022.2 to 2022.3 and also created a bug report. It is good to hear that it is fixed now.

    But what I really don't understand why Unity putting so much optional packes forcefully into our projects. You have to opt-out, because they are installed by default. I learned that more packages means more troubles in our projects. And this one caused by the Aseprite Importer is a prime example. Really bad practice by Unity.
     
  6. Ted_Wikman

    Ted_Wikman

    Unity Technologies

    Joined:
    Oct 7, 2019
    Posts:
    876
    Thanks for testing the new version out and reporting back. Our QA team could not see any real impact on CPU usage with the new patch, but if this is not the case for you, do let us know either in the previous bug report or by filing a new one. We are always interested in making the tools as good as possible.

    The default package setup you get in the 2D Template/3D Template is a set of packages we believe will benefit the largest group of developers. It is always unfortunate when bugs sneak into the setup which causes issues for the developers, and we try our best to keep the bug count low and respond to any bug tickets as fast as we can. That said, I would argue that the package setup we provide gives the users a better start with new projects than if we were to reduce the number of packages included.