Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
## [1.22.2] - 2024-05-13
- Fixed memory leak when loading Sprite objects from a SpriteAtlas asset.
- Added support for directly calling Release() on AsyncOperationHandles that didn't have the option to.
- Fixed issue where operation that uses WaitForCompletion can timeout much earlier than it should.
- Sort collections to make serialized editor files deterministic
- Fixed an issue where tearing down the Addressables instance could happen before user teardown code was getting called.
- Fixed issue where labels on an addressable sub-entry are incorrectly added to the former parent entry.
  • Loading branch information
Unity Technologies committed May 13, 2024
1 parent 655b7ff commit 481c813
Show file tree
Hide file tree
Showing 145 changed files with 3,795 additions and 736 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this package will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [1.22.2] - 2024-05-13
- Fixed memory leak when loading Sprite objects from a SpriteAtlas asset.
- Added support for directly calling Release() on AsyncOperationHandles that didn't have the option to.
- Fixed issue where operation that uses WaitForCompletion can timeout much earlier than it should.
- Sort collections to make serialized editor files deterministic
- Fixed an issue where tearing down the Addressables instance could happen before user teardown code was getting called.
- Fixed issue where labels on an addressable sub-entry are incorrectly added to the former parent entry.

## [1.21.21] - 2024-05-03
- Fix "Unable to verify target bucket for Remote Catalog: Not Found. Object could not be found" error
- Fixed caching to prevent unnecessary refreshing of bucket data.
Expand Down
13 changes: 8 additions & 5 deletions Editor/Build/AddressableAnalytics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,14 @@ internal static BuildData GenerateBuildData(AddressablesDataBuilderInput builder

int selected = schema.DetermineSelectedIndex(groupTypes, -1, currentSettings, vars);

PathType pathType;
if (selected == -1)
pathType = PathType.Custom;
else
pathType = prefixToTypeMap[groupTypes[selected].GroupTypePrefix];
PathType pathType = PathType.Custom;
if (selected >= 0)
{
if (!prefixToTypeMap.TryGetValue(groupTypes[selected].GroupTypePrefix, out pathType))
{
pathType = PathType.Custom;
}
}

if (pathType == PathType.Custom)
{
Expand Down
6 changes: 4 additions & 2 deletions Editor/Build/AddressablesDataBuilderInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public class AddressablesDataBuilderInput
/// </summary>
public FileRegistry Registry { get; private set; }

//used only by tests to inject custom info into build...
internal string PathSuffix = string.Empty;
/// <summary>
/// can be used in testing to append a suffix to file paths
/// </summary>
public string PathSuffix = string.Empty;

/// <summary>
/// The name of the default Runtime Settings file.
Expand Down
2 changes: 1 addition & 1 deletion Editor/Build/AddressablesDataBuilders.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public class BundleBuildResult
/// <summary>
/// True if the build was doing an update to a previous build, else false.
/// </summary>
public bool IsUpdateContentBuild { get; internal set; }
public bool IsUpdateContentBuild { get; set; }

/// <summary>
/// Build results for AssetBundles created during the build.
Expand Down
28 changes: 15 additions & 13 deletions Editor/Build/BuildPipelineTasks/BuildLayoutGenerationTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ public int Version
}

/// <summary>
/// The mapping of the old to new bundle names.
/// The mapping of the old to new bundle names. Instead of using this directly inject
/// the value through IBuildLayoutParUse BuildLayoutParameters.BundleNameRemap instead
/// </summary>
public Dictionary<string, string> BundleNameRemap
{
get { return m_BundleNameRemap; }
set { m_BundleNameRemap = value; }
get { return m_BuildLayoutParameters.BundleNameRemap; }
set { m_BuildLayoutParameters.BundleNameRemap = value; }
}

#pragma warning disable 649
Expand All @@ -70,11 +71,12 @@ public Dictionary<string, string> BundleNameRemap

[InjectContext(ContextUsage.In)]
IBundleBuildResults m_BuildBundleResults;

[InjectContext(ContextUsage.In)]
IBuildLayoutParameters m_BuildLayoutParameters;
#pragma warning restore 649

internal Dictionary<string, string> m_BundleNameRemap;
internal AddressablesDataBuilderInput m_AddressablesInput;
internal ContentCatalogData m_ContentCatalogData;

private bool IsContentUpdateBuild => m_AddressablesInput != null && m_AddressablesInput.PreviousContentState != null;

Expand Down Expand Up @@ -695,14 +697,14 @@ private BuildLayout GenerateBuildLayout(AddressableAssetsBuildContext aaContext,
layout.RemoteCatalogBuildPath = aaContext.Settings.RemoteCatalogBuildPath.GetValue(aaContext.Settings);

AddressableAssetSettings aaSettings = aaContext.Settings;
if (m_ContentCatalogData != null)
layout.BuildResultHash = m_ContentCatalogData.m_BuildResultHash;
if (m_BuildLayoutParameters.BuildResultHash != null)
layout.BuildResultHash = m_BuildLayoutParameters.BuildResultHash;

using (m_Log.ScopedStep(LogLevel.Info, "Generate Basic Information"))
{
SetLayoutMetaData(layout, aaSettings);
layout.AddressablesEditorSettings = GetAddressableEditorSettings(aaSettings);
layout.AddressablesRuntimeSettings = GetAddressableRuntimeSettings(aaContext, m_ContentCatalogData);
layout.AddressablesRuntimeSettings = GetAddressableRuntimeSettings(aaContext);
}

if (IsContentUpdateBuild)
Expand Down Expand Up @@ -846,7 +848,7 @@ void CorrelateBundleToAssetGroup(BuildLayout layout, BuildLayout.Bundle b, Layou
if (aaContext.bundleToAssetGroup.TryGetValue(b.Name, out var grpName))
{
var assetGroup = lookup.GroupLookup[grpName];
b.Name = m_BundleNameRemap[b.Name];
b.Name = m_BuildLayoutParameters.BundleNameRemap[b.Name];
b.Group = assetGroup;
lookup.FilenameToBundle[b.Name] = b;
var filePath = Path.Combine(lookup.GroupNameToBuildPath[assetGroup.Name], b.Name);
Expand All @@ -861,7 +863,7 @@ void CorrelateBundleToAssetGroup(BuildLayout layout, BuildLayout.Bundle b, Layou
{
// bundleToAssetGroup doesn't contain the builtin bundles. The builtin content is built using values from the default group
AddressableAssetGroup defaultGroup = aaContext.Settings.DefaultGroup;
b.Name = m_BundleNameRemap[b.Name];
b.Name = m_BuildLayoutParameters.BundleNameRemap[b.Name];
b.Group = lookup.GroupLookup[defaultGroup.Guid]; // should this be set?
lookup.FilenameToBundle[b.Name] = b;

Expand Down Expand Up @@ -1157,7 +1159,7 @@ private static void SetLayoutMetaData(BuildLayout layoutOut, AddressableAssetSet
layoutOut.PlayerBuildVersion = aaSettings.PlayerBuildVersion;
}

static BuildLayout.AddressablesRuntimeData GetAddressableRuntimeSettings(AddressableAssetsBuildContext aaContext, ContentCatalogData contentCatalog)
BuildLayout.AddressablesRuntimeData GetAddressableRuntimeSettings(AddressableAssetsBuildContext aaContext)
{
if (aaContext.runtimeData == null)
{
Expand All @@ -1172,8 +1174,8 @@ static BuildLayout.AddressablesRuntimeData GetAddressableRuntimeSettings(Address
runtimeSettings.CatalogLoadPaths = new List<string>();
foreach (ResourceLocationData catalogLocation in aaContext.runtimeData.CatalogLocations)
runtimeSettings.CatalogLoadPaths.Add(catalogLocation.InternalId);
if (contentCatalog != null)
runtimeSettings.CatalogHash = contentCatalog.localHash;
if (m_BuildLayoutParameters.CatalogHash != null)
runtimeSettings.CatalogHash = m_BuildLayoutParameters.CatalogHash;

return runtimeSettings;
}
Expand Down
10 changes: 8 additions & 2 deletions Editor/Build/ContentUpdateScript.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ public static bool SaveContentState(List<ContentCatalogDataEntry> locations, str
/// <param name="remoteCatalogPath">The server path (if any) that contains an updateable content catalog. If this is empty, updates cannot occur.</param>
/// <param name="carryOverCacheState">Cached state that needs to carry over from the previous build. This mainly affects Content Update.</param>
/// <returns>True if the file is saved, false otherwise.</returns>
internal static bool SaveContentState(List<ContentCatalogDataEntry> locations, Dictionary<GUID, List<ContentCatalogDataEntry>> guidToCatalogLocation, string path, List<AddressableAssetEntry> entries, IDependencyData dependencyData, string playerVersion,
public static bool SaveContentState(List<ContentCatalogDataEntry> locations, Dictionary<GUID, List<ContentCatalogDataEntry>> guidToCatalogLocation, string path, List<AddressableAssetEntry> entries, IDependencyData dependencyData, string playerVersion,
string remoteCatalogPath, List<CachedAssetState> carryOverCacheState)
{
try
Expand Down Expand Up @@ -493,7 +493,13 @@ public static string GetContentStateDataPath(bool browse)
return GetContentStateDataPath(browse, null);
}

internal static string GetContentStateDataPath(bool browse, AddressableAssetSettings settings)
/// <summary>
/// Gets the path of the cache data from a selected build.
/// </summary>
/// <param name="browse">If true, the user is allowed to browse for a specific file.</param>
/// <param name="settings">The settings object to use for the build.</param>
/// <returns>The path of the previous state .bin file used to detect changes from the previous build to the content update build.</returns>
public static string GetContentStateDataPath(bool browse, AddressableAssetSettings settings)
{
if (settings == null)
settings = AddressableAssetSettingsDefaultObject.Settings;
Expand Down
64 changes: 1 addition & 63 deletions Editor/Build/DataBuilders/AddressableAssetsBuildContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,68 +100,6 @@ public AddressableAssetSettings Settings
/// <summary>
/// A mapping of Asset GUID's to resulting ContentCatalogDataEntry entries.
/// </summary>
internal Dictionary<GUID, List<ContentCatalogDataEntry>> GuidToCatalogLocation = null;

private Dictionary<string, List<ContentCatalogDataEntry>> m_PrimaryKeyToDependers = null;

internal Dictionary<string, List<ContentCatalogDataEntry>> PrimaryKeyToDependerLocations
{
get
{
if (m_PrimaryKeyToDependers != null)
return m_PrimaryKeyToDependers;
if (locations == null || locations.Count == 0)
{
Debug.LogError("Attempting to get Entries dependent on key, but currently no locations");
return new Dictionary<string, List<ContentCatalogDataEntry>>(0);
}

m_PrimaryKeyToDependers = new Dictionary<string, List<ContentCatalogDataEntry>>(locations.Count);
foreach (ContentCatalogDataEntry location in locations)
{
for (int i = 0; i < location.Dependencies.Count; ++i)
{
string dependencyKey = location.Dependencies[i] as string;
if (string.IsNullOrEmpty(dependencyKey))
continue;

if (!m_PrimaryKeyToDependers.TryGetValue(dependencyKey, out var dependers))
{
dependers = new List<ContentCatalogDataEntry>();
m_PrimaryKeyToDependers.Add(dependencyKey, dependers);
}

dependers.Add(location);
}
}

return m_PrimaryKeyToDependers;
}
}

private Dictionary<string, ContentCatalogDataEntry> m_PrimaryKeyToLocation = null;

internal Dictionary<string, ContentCatalogDataEntry> PrimaryKeyToLocation
{
get
{
if (m_PrimaryKeyToLocation != null)
return m_PrimaryKeyToLocation;
if (locations == null || locations.Count == 0)
{
Debug.LogError("Attempting to get Primary key to entries dependent on key, but currently no locations");
return new Dictionary<string, ContentCatalogDataEntry>();
}

m_PrimaryKeyToLocation = new Dictionary<string, ContentCatalogDataEntry>();
foreach (var loc in locations)
{
if (loc != null && loc.Keys[0] != null && loc.Keys[0] is string && !m_PrimaryKeyToLocation.ContainsKey((string)loc.Keys[0]))
m_PrimaryKeyToLocation[(string)loc.Keys[0]] = loc;
}

return m_PrimaryKeyToLocation;
}
}
public Dictionary<GUID, List<ContentCatalogDataEntry>> GuidToCatalogLocation = null;
}
}
47 changes: 47 additions & 0 deletions Editor/Build/DataBuilders/BuildLayoutParameters.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Collections.Generic;
using UnityEditor.Build.Pipeline.Interfaces;
using UnityEngine.AddressableAssets.ResourceLocators;

namespace UnityEditor.AddressableAssets.Build.DataBuilders
{
public interface IBuildLayoutParameters : IContextObject
{
Dictionary<string, string> BundleNameRemap { get; set; }

string BuildResultHash { get; }

string CatalogHash { get; }
}

public class BuildLayoutParameters : IBuildLayoutParameters
{
private Dictionary<string, string> m_BundleNameRemap;
private ContentCatalogData m_contentCatalogData;

public BuildLayoutParameters(Dictionary<string, string> bundleNameRemap)
{
m_BundleNameRemap = bundleNameRemap;
}

public BuildLayoutParameters(Dictionary<string, string> bundleNameRemap, ContentCatalogData contentCatalogData)
{
m_BundleNameRemap = bundleNameRemap;
m_contentCatalogData = contentCatalogData;
}
public Dictionary<string, string> BundleNameRemap
{
get => m_BundleNameRemap;
set => m_BundleNameRemap = value;
}

public string BuildResultHash
{
get => m_contentCatalogData?.BuildResultHash;
}

public string CatalogHash
{
get => m_contentCatalogData?.LocalHash;
}
}
}
3 changes: 3 additions & 0 deletions Editor/Build/DataBuilders/BuildLayoutParameters.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 481c813

Please sign in to comment.