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 First Build is larger than subsequent builds without changing anything

Discussion in 'Editor & General Support' started by AllanGameSmithing, Oct 5, 2023.

  1. AllanGameSmithing

    AllanGameSmithing

    Joined:
    Aug 10, 2022
    Posts:
    11
    Hey,

    Somehow, using Unity 2020.3.25f3 on Windows, building our game for any standalone platform results in unreliable build sizes. To give an example, the first time I build for Linux, the resulting folder is 3.5gb. If I literally just build again, without changing anything, the resulting folder is 2.9gb. It has been driving me crazy that I need to build twice for each platform to get a major reduction in build size, so I started investigating.

    At first I thought it was the Streaming Assets, but turns out this difference comes entirely from Textures. Here is what we see in the Editor log of the first build:

    upload_2023-10-5_19-43-54.png

    And, just building again, without changing anything:

    upload_2023-10-5_19-45-0.png

    And for reference, the same asset that I highlighted in the first screenshot, in the second build:

    upload_2023-10-5_19-45-47.png

    And the import settings for this specific asset:

    upload_2023-10-5_19-47-17.png

    We dont do anything special with any textures, like override import settings per platform, post process, process before build... anything, it is just a texture in the project, but somehow, it is yielding VERY different size results between two builds. And to be clear, this happens on all 3 Standalone platforms we use, Windows, Linux and Mac (we dont build for any other platforms). What this means is, I need to build twice for Windows, then switch platform, build twice for Linux, then switch platform and build twice for Mac... and discard the first build of each platform, to have the smallest build for each platform. This is obviously very time consuming, and I cannot find any rational explanation to understand what might be going on.

    Any ideas on what we could possibly do to sort this out? It's been driving me crazy for a long time lol
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    3,899
    Define "first". Certainly not the first time ever. Is this the case you make the first build after switching platforms? Or after opening the project? What about the third build?

    Do you build to the same folder, overwriting existing content? Or do you choose to build to a separate folder every time? Have you analyzed which of the files in the build actually differ in size?

    What happens if you delete the Library folder and then open the project and make 2+ builds. Still different sizes?

    Have you tried making release or master builds with no debugging infos? With Mono or Il2cpp?

    I'd certainly check for any editor scripts. That's always my first suspicion when something like this happens. You won't find any issue with the assets themselves I guess, more likely it's settings or dependencies.
     
  3. AllanGameSmithing

    AllanGameSmithing

    Joined:
    Aug 10, 2022
    Posts:
    11
    Its inconsistent, but first time after switching platforms. Second, third, tend to all work as intended, BUT, if I continue working, make more changes... then without switching platforms, it will go back to the big build. I couldnt find the pattern, making one line changes will not trigger big builds, longer work will...

    Always new folders, never ovewriting builds. Yes, its all textures, as per the build report, but not ALL textures... its not even "all compressed ones" from what I can say, I dont know what the pattern is.

    Have not made that test yet.

    Havent tried changing between Release and Master, they are all "Release", but seen it happen with both Mono and IL2CPP (though my normal workflow is only IL2CPP)

    That would be my first suspicion as well, but we don't have a whole lot of editor scripts. We only use 3 code plugins (odin, a movement script and a sound script), and our own editors are minimal, mostly decorating fields and a couple of simple windows to simplify a few common workflows (most built with Odin as well).

    Ill continue looking of course, for anything I might have missed, but even if we had scripts, even if one of the plugins was doing something I didnt catch... why would it happen (or not happen) only for the first build (first in a while or per platform)? Thats the mystery I can't really reason with... it feels like either some caching process, or like something is getting compressed for the build, but its too late, the build goes with the uncompressed file, and the compression stays for the next build...

    Ill also try to replicate in version 2020.3.48 (latest 2020 cycle) see if I can replicate the issue.
     
  4. AllanGameSmithing

    AllanGameSmithing

    Joined:
    Aug 10, 2022
    Posts:
    11
    After running a simple test trying to replicate the issue I was having, building 2 times for windows, 2 times for linux and 2 times for Mac on Unity 2020.3.48, I was not able to reproduce the issue. Resulting builds do have slightly different sizes in comparison to the builds in 2020.3.25 (a bit bigger than the "small" builds), building twice yielded the same size builds on all platforms, where Linux and Windows saw slightly larger builds than before, and Mac smaller than before. Apparently, seems like the issue was resolved by updating Unity, but will report otherwise if I notice the issue coming back later as I continue working.