Parent of build directory used to determine total build size

Issue #9 open
Justin Mariner created an issue

Unity Optimizer seems to be looking at the parent directory of the most recent build directory to determine the total build size.

Here’s a snippet of what UnityOptimizerBuildLogExtender.cs logs into Editor.log:

UnityOptimizerBuildLogExtender.OnPostprocessBuild report name : New Report
UnityOptimizerBuildLogExtender.OnPostprocessBuild build date : 08/29/2023 09:22:42
UnityOptimizerBuildLogExtender.OnPostprocessBuild platform WebGL
UnityOptimizerBuildLogExtender.OnPostprocessBuild build path : D:/Files/Documents/test-build
UnityOptimizerBuildLogExtender.OnPostprocessBuild files length : 217
UnityOptimizerBuildLogExtender.OnPostprocessBuild compression : None

This shows the build directory of D:/Files/Documents/test-build, which is what I chose in Unity when starting the build.

Here’s a screenshot of Unity Optimizer and file explorer’s properties of the parent directory, showing a match in size:

A workaround that I’ve found is to manually append a / to the end of the build path in the log file (after closing Unity), like so:

UnityOptimizerBuildLogExtender.OnPostprocessBuild build path : D:/Files/Documents/test-build/
                                                                                            ^

Applying this change and re-selecting the project in Unity Optimizer then gives the correct build size.

I can see that UnityOptimizerBuildLogExtender.cs logs the report.summary.outputPath, so maybe checking if that path ends in a /, and appending one if not, would be a safe fix. This was tested in Unity 2019.3.2, so I’m unsure if that property was updated to include a trailing slash in later versions.

Comments (3)

  1. flarive repo owner

    Hi,

    Thanks for the improvement !

    I will try to add it in a next release.

    Are you sure your webgl build size is 16Go ?
    It seems enormous to me.

    May be it’s the whole sources of your project that are 16Go, not the build, no ?

  2. Justin Mariner reporter

    That's my point, the bug is that it's showing the size of the parent folder of the build directory. In this case my build folder is in my Documents folder, which totals to 16GB as shown in the file explorer popup in the screenshot. The build folder itself is only ~130MB, and if I apply the fix of adding the trailing slash manually, it correctly shows the 130MB build size.

    Thanks for the quick response though! While this is simple enough to work around, it's also simple enough to fix so nobody else has the same issue.

  3. Log in to comment