Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug SBP Exception during CalculateSceneDependencyData

Discussion in 'Addressables' started by Berens_mds, Feb 3, 2023.

  1. Berens_mds

    Berens_mds

    Joined:
    Mar 10, 2020
    Posts:
    5
    Hello,

    Recently we experienced build fails because of this error:

    Build Task CalculateSceneDependencyData failed with exception:
    Sequence contains no elements
    at System.Linq.Enumerable.First[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00010] in <7619ace64c6741ef82e9e455289b1377>:0
    at UnityEditor.Build.Pipeline.Utilities.ExtensionMethods.FilterReferencedObjectIDs (UnityEditor.GUID asset, UnityEditor.Build.Content.ObjectIdentifier[] references, UnityEditor.BuildTarget target, UnityEditor.Build.Player.TypeDB typeDB, System.Collections.Generic.HashSet`1[T] dependencies) [0x000c9] in C:\Project\Library\PackageCache\com.unity.scriptablebuildpipeline@1.20.1\Editor\Utilities\ExtensionMethods.cs:104
    at UnityEditor.Build.Pipeline.Tasks.CalculateSceneDependencyData.Run () [0x00370] in C:\Project\Library\PackageCache\com.unity.scriptablebuildpipeline@1.20.1\Editor\Tasks\CalculateSceneDependencyData.cs:169
    at UnityEditor.Build.Pipeline.BuildTasksRunner.Run (System.Collections.Generic.IList`1[T] pipeline, UnityEditor.Build.Pipeline.Interfaces.IBuildContext context) [0x000cd] in C:\Project\Library\PackageCache\com.unity.scriptablebuildpipeline@1.20.1\Editor\Shared\BuildTasksRunner.cs:56

    The error is not consistent and happens most often in batchmode. The lack of information regarding the assets responsible for the exception make this tedious to debug. Any advice will be welcome.

    Thanks
     
  2. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    354
    You can move sbp package from Library folder to Packages folder and add some logs to debug. For example, you can add a log in ExtensionMethods.FilterReferencedObjectIDs (Line 13 ~ 14) to see which asset causes this issue:
    Code (CSharp):
    1. public static ObjectIdentifier[] FilterReferencedObjectIDs(GUID asset, ObjectIdentifier[] references, BuildTarget target, TypeDB typeDB, HashSet<GUID> dependencies)
    2. {
    3.     // ...
    4.  
    5.     // We need to ensure that we have a reference to a visible representation so our runtime dependency appending process
    6.     // can find something that can be appended, otherwise the necessary data will fail to load correctly in all cases. (EX: prefab A has reference to component on prefab B)
    7.     foreach (var dependency in encounteredDependencies)
    8.     {
    9.         // For each dependency, add just the main representation as a reference
    10.         var representations = ContentBuildInterface.GetPlayerAssetRepresentations(dependency.guid, target);
    11.      
    12.         ////---- BEGIN
    13.         if (!representations.Any())
    14.             Debug.LogErrorFormat("Error: {0}, {1}", asset, dependency.guid);
    15.         ////---- END
    16.      
    17.         collectedImmediateReferences.Add(representations.First());
    18.     }
    19.     collectedImmediateReferences.UnionWith(encounteredDependencies);
    20.     return collectedImmediateReferences.ToArray();
    21. }
     
    Last edited: Feb 4, 2023
    Berens_mds likes this.
  3. Berens_mds

    Berens_mds

    Joined:
    Mar 10, 2020
    Posts:
    5
    After adding a null-check and a 'continue' statement on it, it appears that the assets responsible for the exception to be thrown were 4 Sprites and the dependency was the SpriteAtlas from which those Sprites are comming from.

    Both the SpriteAtlas and the Sprites are implicitly addressables because their parent folder is marked addressable.
    The SpriteAtlas is referencing the same parent folder as content. Is this why the exception is thrown ?

    No error concerning those Sprites was observed in build.
     
  4. Alan-Liu

    Alan-Liu

    Joined:
    Jan 23, 2014
    Posts:
    354
    Which Unity version are you using? Since 'ContentBuildInterface.GetPlayerAssetRepresentations' is implemented in the Engine, maybe you can try a newer version to see if the issue still exists.
     
  5. pillakirsten

    pillakirsten

    Unity Technologies

    Joined:
    May 22, 2019
    Posts:
    346
    Hi @Berens_mds if the issue still persists, I would recommend sending a bug report. It sounds like you were able to narrow down the issue to the offending assets, and could potentially send a small reproduction project.