Skip to content

Conversation

timt-unity3d
Copy link
Collaborator

@timt-unity3d timt-unity3d commented Jul 8, 2025

This PR adds support for reading Addressables build reports and adding them to the Analyzer sqlite database. This provides data that is only available at build time and can be useful when cross-referenced with built asset bundles.

It does a fairly major refactor of the code to add in a concept of a parser that can read different data types and then add their data to the database. SerializedFileParser encapsulates the old functionality and AddressablesBuildLayoutParser adds support for Addressables build reports.

You can point the analyzer at a mixture of build reports and asset bundles. An example of this sort of mixed directory:

buildlayout_2025.05.14.10.37.32.json
barbarian_assets_all_4b903e4b1543c7ba763f1af1ed4a93a9.bundle
d75049fa2e1f1a2a0778ee8c5bd6ca4a_monoscripts_2338978fc385860335d52af8af1b0937.bundle
d75049fa2e1f1a2a0778ee8c5bd6ca4a_unitybuiltinassets_2855ca7179c3f5c1bd47d03895d1d6f9.bundle
dungeon1_assets_all_9a0add2726c28c7741262c6c806a6104.bundle

@timt-unity3d timt-unity3d requested a review from Copilot July 8, 2025 18:13
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for importing Unity Addressables build reports by parsing JSON build layout files and writing their data into new SQLite tables.

  • Introduce WriteAddressablesBuild in SQLiteWriter and register all related commands.
  • Add dozens of AbstractCommand subclasses to support addressables tables.
  • Update database schema (Init.sql) and analyzer tool to handle .json Addressables build reports.

Reviewed Changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Analyzer/SQLite/SQLiteWriter.cs Register and use new Addressables build commands; implement WriteAddressablesBuild.
Analyzer/SQLite/Commands/*.cs Add command classes for each addressables-related table.
Analyzer/Resources/Init.sql Create all addr_build_* tables for addressables data.
Analyzer/AnalyzerTool.cs Detect .json files and route to ProcessAddressablesBuild.
Analyzer/Analyzer.csproj Add Newtonsoft.Json package for JSON deserialization.
Comments suppressed due to low confidence (2)

Analyzer/SQLite/SQLiteWriter.cs:62

  • [nitpick] The field name 'm_AddressablesDataFromOtherAsset' is missing 'Build' after 'Addressables'. Consider renaming to 'm_AddressablesBuildDataFromOtherAsset' for consistency.
    private AddressablesBuildDataFromOtherAsset m_AddressablesDataFromOtherAsset = new AddressablesBuildDataFromOtherAsset();

Analyzer/SQLite/SQLiteWriter.cs:259

  • This new method contains substantial logic for parsing and inserting data; consider adding unit tests to cover key code paths and error handling.
    public void WriteAddressablesBuild(string filename, BuildLayout buildLayout)

Copy link
Collaborator

@SkowronskiAndrew SkowronskiAndrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took an initial peek at the code (but didn't try it out)
So far just a few suggestions about organizing the new functionality with a bit more structure, which probably could pay off as establishing a pattern for other build-pipeline-specific tables we might add in future.

@timt-unity3d timt-unity3d force-pushed the add-buildlayout-support branch from 4ea43ea to 6206b19 Compare September 30, 2025 16:08
This refactors the code to have separate parsers for Asset Bundles
and Addressables Build Layout files. The parser implements a
CanParse and Parse method to handle applicability. Currently
there's no overlap so we won't be double-parsing, but it's
possible in the future.
@timt-unity3d timt-unity3d marked this pull request as ready for review October 2, 2025 17:17
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@timt-unity3d timt-unity3d requested a review from Copilot October 2, 2025 18:58
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 87 out of 89 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • Analyzer/Properties/Resources.Designer.cs: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@timt-unity3d timt-unity3d force-pushed the add-buildlayout-support branch from f4832e3 to 8303ae0 Compare October 6, 2025 16:25
@timt-unity3d timt-unity3d requested a review from Copilot October 6, 2025 16:25
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 87 out of 89 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • Analyzer/Properties/Resources.Designer.cs: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Collaborator

@SkowronskiAndrew SkowronskiAndrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good Tim. I have a few suggestions but also see this as an ongoing iteration. Now that you've adjusted your fix to work "on demand" it won't have risk of impact on existing use cases. I do plan to try it out more as well.

Copy link
Collaborator

@SkowronskiAndrew SkowronskiAndrew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like copilot mentioned a few fixes that look worth doing.

And I think there is an issue still with the /Build/ file that should be addressed.

But in terms of adding more examples and docs that can also happen in follow ups.

Comment on lines 19 to 20
**Files** - the file in the asset bundle that contains serialized files
**SubFiles** - files that are bundled in the asset bundle, but not stored with the rest of the serialized files (resS, scene sharedAssets)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
**Files** - the file in the asset bundle that contains serialized files
**SubFiles** - files that are bundled in the asset bundle, but not stored with the rest of the serialized files (resS, scene sharedAssets)
**Files** - the files of the Unity serialized file format in the asset bundle.
**SubFiles** - Additional files in the asset bundle that are not serialized files. These are referenced from serialized files, for example resS and resource.

One question i have is about .sharedAssets that you mention - those are actually serialized flies, which does make the definition of sub file a bit more complicated. Is it closely aligned with Addressables tracking that they are treated as a "sub files". I think the regular UnityDataTools tables would list .sharedAssets in the main tables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, right or wrong the addressables report treats them as sub files and puts them in the addressables_build_sub_files table:

5214|1|0|CAB-0e7808e7a61f3cca1f2d183e4a2d90d0.resS|50332672
5270|1|1|CAB-2c23c67af208a1a10429ef1458fc4a68.sharedAssets|4000
5271|1|1|CAB-2c23c67af208a1a10429ef1458fc4a68|28688
5272|1|1|CAB-2414edc0ddcd3b56e6e7e6a3280dc0e5.sharedAssets|3768
5273|1|1|CAB-2414edc0ddcd3b56e6e7e6a3280dc0e5|21040
5275|1|1|CAB-cb639d53e9792fd67401eb9cc4b8b84b|3744
5276|1|0|CAB-cb639d53e9792fd67401eb9cc4b8b84b.resource|400864

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks for checking it out.

It feels like that will make it harder to correctly cross reference from serialized_files and other tables into the Addressables tables when actual serialized files are reported into both files and subfiles table. But for the moment matching the Addressables schema probably is the most informative about how things work.

@timt-unity3d timt-unity3d requested a review from Copilot October 21, 2025 17:06
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 88 out of 90 changed files in this pull request and generated 6 comments.

Files not reviewed (1)
  • Analyzer/Properties/Resources.Designer.cs: Language not supported

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@timt-unity3d timt-unity3d requested a review from Copilot October 21, 2025 18:27
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 88 out of 90 changed files in this pull request and generated 7 comments.

Files not reviewed (1)
  • Analyzer/Properties/Resources.Designer.cs: Language not supported
Comments suppressed due to low confidence (9)

Analyzer/SQLite/Commands/AddressablesBuildReport/AddressablesBuildGroup.cs:1

  • Remove excessive blank lines at the end of the file (lines 35-37). Only one blank line should remain.
using Microsoft.Data.Sqlite;

Analyzer/SQLite/Commands/AddressablesBuildReport/AddressablesBuildBundleRegularDependency.cs:1

  • Remove excessive blank lines at the end of the file (lines 32-34). Only one blank line should remain.
using Microsoft.Data.Sqlite;

Analyzer/SQLite/Commands/AddressablesBuildReport/AddressablesBuildBundleFile.cs:1

  • Remove excessive blank lines at the end of the file (lines 32-34). Only one blank line should remain.
using Microsoft.Data.Sqlite;

Analyzer/SQLite/Commands/AddressablesBuildReport/AddressablesBuildBundleDependentBundle.cs:1

  • Remove excessive blank lines at the end of the file (lines 32-34). Only one blank line should remain.
using Microsoft.Data.Sqlite;

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


namespace UnityDataTools.Analyzer.SQLite.Writers;

public class AssetBundleSQLiteWriter : IDisposable
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UnityDataTools also supports Content Files from Dots and Player content in addition to AssetBundles
Some existing code is a bit unclear about that, e.g. code that works with Unity Archive files calls then AssetBundles.

This could be renamed as SerializedFileSQLiteWriter, that matches with WriteSerializedFile() which is what does the work.

Comment on lines 19 to 20
**Files** - the file in the asset bundle that contains serialized files
**SubFiles** - files that are bundled in the asset bundle, but not stored with the rest of the serialized files (resS, scene sharedAssets)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, thanks for checking it out.

It feels like that will make it harder to correctly cross reference from serialized_files and other tables into the Addressables tables when actual serialized files are reported into both files and subfiles table. But for the moment matching the Addressables schema probably is the most informative about how things work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants