Post

Unity Addressables Optimization Guide

Unity Addressables Optimization Guide
Visitors



Addressables Optimization

Duplicate dependency issue in Addressables

  • You can check duplicate dependencies through the Addressables report. Personally, I usually handle this through Analyze.


What is a duplicate dependency?

  • Addressables can register assets regardless of where they are in the Assets folder, because they are handled through memory-address-based references.
  • But with that convenience comes one key caution: duplicate dependencies.

Desktop View

  • Assume there are Asset Group A and B.
  • Suppose asset a and b in each group both reference asset c.


Desktop View

  • Then generated AssetBundle A and B each include asset c.
  • That means two copies of asset c are loaded into memory.


Desktop View

  • The solution is simple.
  • Create Asset Group C and move asset c there.
  • Then AssetBundle A and B both reference AssetBundle C, so asset c is not loaded twice.


Summary

  • Shaders are a typical case of this issue because many materials reference the same shader.
  • So create a dedicated shader group (this also connects to shader variant optimization below).
  • Even if you do not assign an Address directly, for assets referenced by multiple groups, make an explicit dependency-only group.
  • You can also reduce catalog size by excluding addresses from the catalog.

    Uncheck Include Addresses in Catalog.


Desktop View

  • Addressables has an Analyze tool. In Fixable Rules, run Analyze Selected Rules from the top toolbar.
  • It automatically creates a Duplicate Isolation group and moves duplicate dependency assets into it.



Addressables optimization tips

  • If you are not using AssetReference, you can remove GUIDs from the catalog.

    Uncheck Include GUIDs in Catalog.

Desktop View


  • Use binary catalogs instead of JSON catalogs. There are ways to inspect and tamper with update contents from catalog JSON, so binary can add a first security layer.


  • On mobile, the number of concurrent web requests is limited.

    Max Concurrent Web Request defaults to 500; reduce it to a reasonable lower value.

Desktop View



Shader variant optimization

Project Auditor

Desktop View

  • Project Auditor Github
  • Static analysis tool

    Analyzes Unity assets, project settings, and scripts.
    Useful for reducing shader variants.


What is a shader variant?

Desktop View

  • A derived shader version generated by keyword combinations and similar conditions.

    If you use multiple keywords such as OpenGL and Vulkan, multiplied shader variants are produced during build.


Desktop View

  • Also, if variant count grows too large:
  • SetPass Call increases
  • Memory usage can double per keyword


Cleaning up shader variants

  • Do not use unnecessary shader keywords. Merge shaders/variants that serve similar roles.
  • Most common case:

    If you do not separate a shader group in Addressables, duplicated shader variants are included in each AssetBundle, causing duplicate dependencies and extra memory load.
    Create a dedicated asset group for shaders.


  • In Lighting settings, disable unused lightmap modes so related shader keywords are explicitly removed.

Desktop View


  • Disable unused Graphics APIs. Separate shader variants are generated per graphics API.

    Personally, on Android mobile, OpenGL ES3 has felt more stable than Vulkan (for example, particle flicker issues).
    On Apple platforms, the graphics API is Metal.

Desktop View


  • Be careful with materials not included in build

    Keywords declared with shader_feature are stripped if no included material uses them.
    Build-time keyword stripping is based on project materials, but materials excluded from build can still affect which keywords remain.

Desktop View


  • Enable strip settings in URP

    Debug keywords
    Unused post-process variant keywords
    Unused URP feature variants

Desktop View


Cleanup by elimination with Project Auditor

  • First, clear previous build cache!
  • Collect all variants included in build
  • Collect variants actually used during gameplay from logs
  • Remove unused variants

    Remove keywords directly in shader code
    Disable options in materials
    Filter with IPreprocessShaders


Desktop View

  • Enable shader compilation logs in Project Settings

    Project Settings > Graphics > Log Shader Compilation

  • Enable Development Build
  • Run both Addressables build and player build

    When running Addressables build, clear previous Addressables build cache first

  • In Project Auditor’s Shader Variant window, shaders included in the build are shown


Desktop View

  • Play the game and traverse the full content
  • Names of loaded and GPU-compiled shader variants are written to logs
  • Drag and drop that log into Project Auditor window

    Variants compiled by GPU (= actually used) are marked as Compiled

  • Now you can clean up unused variants



Side note: CRC check when implementing an Addressables patch system

Desktop View

  • In Addressables group settings, there is an option to enable/disable CRC.
  • CRC check is an integrity check that verifies whether AssetBundles were tampered with.
  • I implemented a patch system by iterating all ResourceLocators, not by downloading an entire label set.
  • During this process, I saw abnormal behavior in resource download loading progress. (Progress value was built by summing key values from each resource locator.)
  • For example, when downloading 200MB, at 98%-99%, downloading the last 1%-2% took longer than downloading the first ~90%.
  • I was advised by instructor Je-min Lee that this may be due to CRC integrity checks near the end of loading, so disabling CRC is worth testing.
  • Or if it is the same with CRC off, web requests may be entering contention; in that case, lower Max Web Request value.
This post is licensed under CC BY 4.0 by the author.