Giter VIP home page Giter VIP logo

buildreportinspector's Introduction

Build Report Inspector for Unity

This package contains an Editor script which implements an inspector for the BuildReport class added in Unity 18.1.
The BuildReport class lets you access information about your last build, and helps you profile the time spent building your project and the builds disk size footprint. This information may help you improving your build times and build sizes.
This script allows you to inspect this information graphically in the Editor UI, making it more easily accessible than the script APIs would.

Disclaimer

This package is provided as-is, with no support from Unity Technologies. We plan to add a built-in and supported UI for the BuildReport feature in a future version of Unity, but until then, this package serves as a demonstration on how you can access the BuildReport information today.

In particular, this package gets the information it can from the BuildReport Scripting API (https://docs.unity3d.com/ScriptReference/Build.Reporting.BuildReport.html).

Usage

Add the BuildReportInspector.cs editor script to an Editor folder in your project to install it.
Alternatively, install it from Unity Editor's Package Manager window (check "Show preview packages" in the "Advanced" menu to have "Build Report Inspector" displayed in the list of available packages).
Once installed, BuildReport objects can be viewed in the inspector.

You can obtain a BuildReport object as the return value of the BuildPlayer API (https://docs.unity3d.com/ScriptReference/BuildPipeline.BuildPlayer.html) when making a build, or by selecting a file containing BuildReport data.
Unity's default build setup will write such a file to Library/LastBuild.buildreport (this may change in the future) when making a build. This script adds a convenient menu shortcut (Window/Open Last Build Report), to copy that file to the Assets folder and select it, so you can inspect it using the Build Report Inspector.

Once open in the inspector, you can chose what data to view using the popup menu at the top of the window. The Build Report Inspector can show the following data:

Build steps

The different steps involved in making you build, how long they took, and what messages were printed during those steps (if any).

Source assets

A list of all assets which are used in the build, and how much they contribute to your build size

SourceAssets

Output files

A list of all files written by the build

OutputFiles

Stripping

For platforms which support engine code stripping, a list of all engine modules added to the build, and what caused them to be included in the build.

Stripping

Scenes using Assets

[Available from Unity 2020.1.0a6]
When BuildOptions.DetailedBuildReport is passed to BuildPipeline.BuildPlayer, a list describing which scenes are using each asset of the build, is provided in the BuildReport.

Mobile

[Available from Unity 2019.3]
The BuildReport API is not very good at reporting data from mobile builds. For this reason, starting at Unity 2019.3, mobile appendix was added to the BuildReportInspector. The mobile appendix expands the BuildReportInspector UI by adding mobile-specific entries, such as architectures inside the build, app store download sizes and the list of files inside the application bundle (.apk, .obb, .aab for Android and .ipa for iOS/tvOS).

Android

The mobile appendix is generated automatically for Android builds, right after Unity exports the application bundle.

iOS

Because Unity does not export .ipa bundles directly, they need to be generated manually by the user. When an iOS build report is opened in Unity, the BuildReportInspector UI will display a prompt to open an .ipa bundle for more detailed information about the build, as shown in the image below.

To generate a development .ipa bundle:

  1. Open the Xcode project exported by Unity.
  2. In the menu bar, go to Product > Archive.
  3. Once Xcode finishes archiving, click Distribute App.
  4. Select Development distribution method, go to next step.
  5. Select desired App Thinning and Bitcode options, go to next step.
  6. Set valid signing credentials and click Next.
  7. Once Xcode finishes distributing, click Export and select where to save the distributed files.

Once these steps are complete, an .ipa bundle will be inside the directory, saved in step 7.
This process can also be automated using the xcodebuild command line tool.
After the .ipa bundle is provided, the iOS-specific information is added to the BuildReportInspector UI automatically.

buildreportinspector's People

Contributors

irunn3r avatar kernalpanik avatar mindwrapper avatar ryanc-unity avatar sambonfire avatar todi1856 avatar vaidas-unity avatar wilfrid-unity avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

buildreportinspector's Issues

[Android] Build Report Inspector generates "apkanalyzer failed to estimate the apk size. Output: Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8" exception on Build when using Java Environment Variable

Transferred from Jira (UUM-19493) because this ticket is a bug in the BuildReportInspector.

How to reproduce:

  1. Go to “Edit the system environment variables” > “Environment Variables…” > “New”
  2. Add “JAVA_TOOL_OPTIONS“ as a Variable name and “-Dfile.encoding=UTF-8“ as a Variable value
  3. Create a new Unity project
  4. Go to “Package Manager“ > “Add package from git URL“ and add “com.unity.build-report-inspector“ URL
  5. Build for Android
  6. After the Build is complete observe the Console

Expected result: There are no exceptions
Actual result: “System.Exception: apkanalyzer failed to estimate the apk size. Output: Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8“ exception appears

Reproducible with: 0.2.2-preview, 0.3.0-preview (2020.3.42f1, 2021.3.14f1, 2022.1.23f1, 2022.2.0b16, 2023.1.0a20)

Not reproducible on: iOS, Standalone Player (Windows 11)

Note: After setting Environment Variable a Unity Hub / PC restart may be needed

Full exception message:
System.Exception: apkanalyzer failed to estimate the apk size. Output:
18131288
Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
at Unity.BuildReportInspector.Mobile.AndroidUtilities.GetApkDownloadSize (System.String applicationPath) [0x001e5] in Project Path\Library\PackageCache\[email protected]\Editor\Mobile\AndroidUtilities.cs:253
at Unity.BuildReportInspector.Mobile.AndroidUtilities.GetArchitectureInfo (System.String applicationPath) [0x000f3] in Project Path\Library\PackageCache\[email protected]\Editor\Mobile\AndroidUtilities.cs:128
at Unity.BuildReportInspector.Mobile.MobileAppendix..ctor (System.String applicationPath) [0x000d8] in Project Path\Library\PackageCache\[email protected]\Editor\Mobile\MobileAppendix.cs:90
at Unity.BuildReportInspector.Mobile.MobileHelper.GenerateMobileAppendix (System.String applicationPath, System.String guid) [0x0001e] in Project Path\Library\PackageCache\[email protected]\Editor\Mobile\MobileHelper.cs:77
UnityEngine.Debug:LogError (object)
Unity.BuildReportInspector.Mobile.MobileHelper:GenerateMobileAppendix (string,string) (at Library/PackageCache/[email protected]/Editor/Mobile/MobileHelper.cs:83)
Unity.BuildReportInspector.Mobile.MobileHelper:GenerateAndroidAppendix (string,string) (at Library/PackageCache/[email protected]/Editor/Mobile/MobileHelper.cs:27)
Unity.BuildReportInspector.Mobile.PostBuildSetup:BuildPostProcess (UnityEditor.BuildTarget,string) (at Library/PackageCache/[email protected]/Editor/Mobile/PostBuildSetup.cs:44)
UnityEngine.GUIUtility:ProcessEvent (int,intptr,bool&)

Details:

Notes from Julius Miknevicius:
Build Report Inspector package tries to parse the whole apkanalyzer output as long
https://github.com/Unity-Technologies/BuildReportInspector/blob/master/com.unity.build-report-inspector/Editor/Mobile/AndroidUtilities.cs#L247

however when JAVA_TOOL_OPTIONS environment variable is specified, the output of apkanalyzer is:

Picked up JAVA_TOOL_OPTIONS: -Dfile.encoding=UTF-8
20964989 

20964989 is the size of the apk, which is what build report inspector wants.

So it seems the fix would be to improve the parsing code to strip off that possible extra junk in the output (or find a way to invoke the tool so that it doesn't add that unexpected noise in its output)

Decouple parsing and formatting from OnGUI code for CI purposes

In our company we make builds using batch mode but it's really difficult that when a build fails, see a problem because you need to search in a +1000 lines of editor.log file.

Using "BuildReport" class we can at least log that information with "Debug.Log" API at the end of the log so we can have all this information in the same place at once.

I saw this package and I see that it parses and builds that information transversing the steps recursively and setting the appropiate depths.

My problem is that it's coupled in a unique class that also uses OnGUI API.

Can you refactor it so I can use your parsing logic but not the OnGUI logic?

Thanks.

Size of texture assets not reported correctly when sorting by Importer Type

Just looked at a build report and the reported size of all texture assets is enormous and obviously incorrect.

image
See the Total Size and then compare with the size reported for textures in the above picture.

I hope this can be helpful to someone, as this package is quite handy. I'm using version 0.2.2 with Unity 2019.3.7f1 running on MacOS.

Build report object naming issue

When opening the last build report the build report object always has the name "New Report" which doesn't match the asset name causing the inspector to prompt you to fix the object name.

I've already fixed this issue and created a pull request for the fix.

SourceAssets tab does not actually show all assets.

SourceAssets tab does not actually show all assets.

E.g.: When you a make a build with hundreds of textures the source assets only show about 30 of them and then the list gets truncated.

Tested on Unity 2019.2.11f1 and Build Report Inspector version 0.1.0

Expose Settings for Build Report Inspector to allow custom date formatting

BuildReportInspector hard-codes build report output path but more importantly it hard-codes the filename date formatting in a way I find unacceptable: using Unity Build Reporter as a Package Manager package my only option currently is manually renaming every file after Build Report Inspector creates it.

This is the hard-coding in question

var assetPath = buildReportDir + "/Build_" + date.ToString("yyyy-dd-MMM-HH-mm-ss") + ".buildreport";

Resulting in a filename like "Build-2020-15-kesä-15-59-06" on my computer, which is neither what I prefer but more importantly does not sort chronologically for quick and legible browsing and organizing (Project Assets view is sorted alphabetically and hard-coded format does not sort the entries in any chronological order which is relevant when making comparisons of the builds as chronological series).

I'd much prefer if you expose a Settings UI for customizing the defalt filename date formatting when outputting .buildreport files, but failing that you could just hardcode it in ISO 8601 "YYYY-MM-DD-hh-mm-ss" as described in https://en.wikipedia.org/wiki/ISO_8601

Editor freezes when trying to open a large report file

Hello,

Lately we are having trouble with build times, and we're trying to use this tool to evaluate what the issue is.
However, our build log file is over 1 GB. We tried to open it with the BuildReportInspector, but it just freezes de editor on each click.

Is there any way we can split the log file or something else along these lines?

Is it dead?

Still in preview, not ready for production. 11 months no feature commits.
Rip?

"Assembly has reference to non-existent assembly 'UnityEngine.TestRunner'" compiler error

Commit id: 84cbe0e
Open BuildReportInspector/TestProject with Unity and observe two compilation errors in console:

Assembly has reference to non-existent assembly 'UnityEngine.TestRunner' (Packages/com.unity.build-report-inspector/Tests/Editor/Mobile/Unity.BuildReportInspector.Editor.Tests.Mobile.asmdef)
Assembly has reference to non-existent assembly 'UnityEngine.TestRunner' (Packages/com.unity.build-report-inspector/Tests/Editor/Unity.BuildReportInspector.Editor.Tests.asmdef)

Does not reproduce on master branch commit 3039f04 adding package to empty Unity project.

Reproduced with Unity 2018.4.6f1.
Not reproduced with Unity 2019.3.0f6.

Source assets tab is laggy

With this tab opening onto a page that is drawing thousands of included assets it's unusable in my project.
Editing the script to land on the collapsed importer type view makes it vaguely usable, but it seems this isn't very scalable.
This should use a list view functionality where it's only actually displaying the few visible elements.

Don't place Mobile appendix in the Assets folder

After mobile builds, I get a large folder of build information in my assets folder this has a few consequences:

  • Requires an asset database refresh after build.
  • Extends project import time (a small amount, but import times are a 'death by 1000 cuts' situation)
  • Requires .gitignore, etc.

It seems these would make much more sense to be placed in the Library/.

Crash When Accessing SourceAssets Tab When Using Sprite Atlases With DXT5|BC3 Compression

Steps to reproduce:

  1. create a sprite atlas and override the compression to use DXT5|BC3 mode;
  2. build the project;
  3. access the last build report, open the SourceAssets tab, notice the crash (see stack trace below).

In my project, the asset that causes the crash is:
buildTimeAssetPath: 'Built-in Texture2D: sactx-0-256x128-DXT5|BC3-ui-sprite-atlas-fff07956'

Stack trace:
ArgumentException: Illegal characters in path.
System.IO.Path.GetFileName (System.String path) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Unity.BuildReportInspector.BuildReportInspector.ShowAssets (System.Collections.Generic.IEnumerable`1[T] assets, System.Single& vPos, System.String fileFilter, System.String typeFilter) (at E:/Temp/unity/BuildReportInspector-master/com.unity.build-report-inspector/Editor/BuildReportInspector.cs:470)
Unity.BuildReportInspector.BuildReportInspector.DisplayAssetsView (System.Single vPos) (at E:/Temp/unity/BuildReportInspector-master/com.unity.build-report-inspector/Editor/BuildReportInspector.cs:606)
Unity.BuildReportInspector.BuildReportInspector.OnAssetsGUI () (at E:/Temp/unity/BuildReportInspector-master/com.unity.build-report-inspector/Editor/BuildReportInspector.cs:597)
Unity.BuildReportInspector.BuildReportInspector.OnInspectorGUI () (at E:/Temp/unity/BuildReportInspector-master/com.unity.build-report-inspector/Editor/BuildReportInspector.cs:213)
UnityEditor.UIElements.InspectorElement+<>c__DisplayClass59_0.b__0 () (at :0)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.