Search Unity

Bug (Case 1357637) ScriptableBuildPipeline does not abort when exception occurs

Discussion in 'Asset Bundles' started by Peter77, Jul 19, 2021.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,017
    When an exception is thrown during a build, SBP just continues the build process.

    Can you please implement when an exception occurs during a build, that the build fails immediately with an appropriate error?

    For example, I just built a Player and Unity printed thousands of the following errors to the Console window. I had to purge the build cache to workaround this issue.

    Code (CSharp):
    1. InvalidDataException: Could not create Type for 'EffectModuleAttachToEffectZone, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
    2. UnityEditor.Build.Pipeline.Utilities.USerialize.DeSerializer.ReadObject (System.Int32 depth) (at Library/PackageCache/com.unity.scriptablebuildpipeline@1.19.1/Editor/Utilities/USerialize/DeSerializer.cs:447)
    3. UnityEditor.Build.Pipeline.Utilities.USerialize.DeSerializer.ReadObject (System.Int32 depth) (at Library/PackageCache/com.unity.scriptablebuildpipeline@1.19.1/Editor/Utilities/USerialize/DeSerializer.cs:498)
    4. UnityEditor.Build.Pipeline.Utilities.USerialize.DeSerializer.ReadObject (System.Int32 depth) (at Library/PackageCache/com.unity.scriptablebuildpipeline@1.19.1/Editor/Utilities/USerialize/DeSerializer.cs:468)
    5. UnityEditor.Build.Pipeline.Utilities.USerialize.DeSerializer.DeSerialize[ClassType] (System.IO.Stream stream) (at Library/PackageCache/com.unity.scriptablebuildpipeline@1.19.1/Editor/Utilities/USerialize/DeSerializer.cs:154)
    6. UnityEditor.Build.Pipeline.Utilities.BuildCache+<>c__DisplayClass28_1.<LoadCachedData>b__0 (System.Int32 index) (at Library/PackageCache/com.unity.scriptablebuildpipeline@1.19.1/Editor/Utilities/BuildCache.cs:368)
    7. System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()
    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2. UnityEditor.Build.Pipeline.Utilities.BuildCache+<>c__DisplayClass28_1.<LoadCachedData>b__0 (System.Int32 index) (at Library/PackageCache/com.unity.scriptablebuildpipeline@1.19.1/Editor/Utilities/BuildCache.cs:368)
    3. System.Threading._ThreadPoolWaitCallback:PerformWaitCallback()
     
  2. yfn12343

    yfn12343

    Joined:
    May 15, 2021
    Posts:
    1
    same problem
     
  3. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    324
    Hmm, that looks like exceptions on threads are not bubbling up to the main thread and failing the build. Can you log a bug for this?
     
    Peter77 likes this.
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,017
    Thank you for the reply. Here are the bug-reports:

    (Case 1357637) 2019.4: ScriptableBuildPipeline does not abort when exception occurs

    (Case 1357636) 2019.4: Random editor crash when building Addressables content (USerialize.DeSerializer.ReadObject)
     
  5. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    324
    Ty!
     
    Peter77 likes this.
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,017
    I just realized it's the same error we often see on our build server as well. The workaround is to login to the build server and delete the
    Library/BuildCache
    and
    Library/com.unity.addressables
    directories from the particular build job that failed and then trigger the job again.

    I believe the actual problem is that the build pipeline attempts to read an outdated cached asset. For example, the class HorseXpItemModule (MonoBehaviour) was deleted from the project. The next build then failed with the errors below. In this case, any cached asset that used the HorseXpItemModule Component would be outdated, but it seems the build pipeline is still doing something with it which causes the InvalidDataException when loading the file.

    I guess there is missing a step that detects that the cached asset that uses the now removed HorseXpItemModule class is no longer valid. Does it make sense?

    Code (CSharp):
    1. DisplayProgressbar: Calculate Asset Dependency Data
    2. InvalidDataException: Could not create Type for 'HorseXpItemModule, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'
    3.   at UnityEditor.Build.Pipeline.Utilities.USerialize.DeSerializer.ReadObject (System.Int32 depth) [0x005a1] in D:\jenkinsNew\workspace\untamed\alpha-win64-debug-nightly\unity\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\USerialize\DeSerializer.cs:447
    4.   at UnityEditor.Build.Pipeline.Utilities.USerialize.DeSerializer.ReadObject (System.Int32 depth) [0x00746] in D:\jenkinsNew\workspace\untamed\alpha-win64-debug-nightly\unity\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\USerialize\DeSerializer.cs:498
    5.   at UnityEditor.Build.Pipeline.Utilities.USerialize.DeSerializer.ReadObject (System.Int32 depth) [0x0069e] in D:\jenkinsNew\workspace\untamed\alpha-win64-debug-nightly\unity\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\USerialize\DeSerializer.cs:468
    6.   at UnityEditor.Build.Pipeline.Utilities.USerialize.DeSerializer.DeSerialize[ClassType] (System.IO.Stream stream) [0x0006e] in D:\jenkinsNew\workspace\untamed\alpha-win64-debug-nightly\unity\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\USerialize\DeSerializer.cs:154
    7.   at UnityEditor.Build.Pipeline.Utilities.BuildCache+<>c__DisplayClass28_1.<LoadCachedData>b__0 (System.Int32 index) [0x0005d] in D:\jenkinsNew\workspace\untamed\alpha-win64-debug-nightly\unity\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\BuildCache.cs:368
    8. UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    9. UnityEngine.DebugLogHandler:LogException(Exception, Object)
    10. UnityEngine.Logger:LogException(Exception, Object)
    11. UnityEngine.Debug:LogException(Exception)
    12. UnityEditor.Build.Pipeline.Utilities.BuildLogger:LogException(Exception) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\BuildLogger.cs:134)
    13. UnityEditor.Build.Pipeline.Utilities.<>c__DisplayClass28_1:<LoadCachedData>b__0(Int32) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\BuildCache.cs:378)
    14. System.Threading.Tasks.<>c__DisplayClass17_0`1:<ForWorker>b__1()
    15. System.Threading.Tasks.Task:InnerInvoke()
    16. System.Threading.Tasks.Task:InnerInvokeWithArg(Task)
    17. System.Threading.Tasks.<>c__DisplayClass178_0:<ExecuteSelfReplicating>b__0(Object)
    18. System.Threading.Tasks.Task:ExecuteSelfReplicating(Task)
    19. System.Threading.Tasks.Task:Execute()
    20. System.Threading.Tasks.Task:ExecutionContextCallback(Object)
    21. System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
    22. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
    23. System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
    24. System.Threading.Tasks.Task:ExecuteEntry(Boolean)
    25. System.Threading.Tasks.ThreadPoolTaskScheduler:TryExecuteTaskInline(Task, Boolean)
    26. System.Threading.Tasks.TaskScheduler:TryRunInline(Task, Boolean)
    27. System.Threading.Tasks.Task:InternalRunSynchronously(TaskScheduler, Boolean)
    28. System.Threading.Tasks.Task:RunSynchronously(TaskScheduler)
    29. System.Threading.Tasks.Parallel:ForWorker(Int32, Int32, ParallelOptions, Action`1, Action`2, Func`4, Func`1, Action`1)
    30. System.Threading.Tasks.Parallel:For(Int32, Int32, ParallelOptions, Action`1)
    31. UnityEditor.Build.Pipeline.Utilities.BuildCache:LoadCachedData(IList`1, IList`1&) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\BuildCache.cs:350)
    32. UnityEditor.Build.Pipeline.Tasks.CalculateAssetDependencyData:RunInternal(TaskInput, TaskOutput&) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Tasks\CalculateAssetDependencyData.cs:222)
    33. UnityEditor.Build.Pipeline.Tasks.CalculateAssetDependencyData:Run() (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Tasks\CalculateAssetDependencyData.cs:130)
    34. UnityEditor.Build.Pipeline.BuildTasksRunner:Run(IList`1, IBuildContext) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Shared\BuildTasksRunner.cs:56)
    35. UnityEditor.Build.Pipeline.ContentPipeline:BuildAssetBundles(IBundleBuildParameters, IBundleBuildContent, IBundleBuildResults&, IList`1, IContextObject[]) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\ContentPipeline.cs:145)
    36. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:DoBuild(AddressablesDataBuilderInput, AddressableAssetsBuildContext) (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Build\DataBuilders\BuildScriptPackedMode.cs:236)
    37. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:BuildDataImplementation(AddressablesDataBuilderInput) (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Build\DataBuilders\BuildScriptPackedMode.cs:77)
    38. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptBase:BuildData(AddressablesDataBuilderInput) (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Build\DataBuilders\BuildScriptBase.cs:91)
    39. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContentImpl() (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Settings\AddressableAssetSettings.cs:2146)
    40. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent(AddressablesPlayerBuildResult&) (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Settings\AddressableAssetSettings.cs:2128)
    41. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent() (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Settings\AddressableAssetSettings.cs:2095)
    42.  

    Code (CSharp):
    1. NullReferenceException: Object reference not set to an instance of an object
    2.   at UnityEditor.Build.Pipeline.Utilities.BuildCache+<>c__DisplayClass28_1.<LoadCachedData>b__0 (System.Int32 index) [0x0005d] in D:\jenkinsNew\workspace\untamed\alpha-win64-debug-nightly\unity\Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\BuildCache.cs:368
    3. UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
    4. UnityEngine.DebugLogHandler:LogException(Exception, Object)
    5. UnityEngine.Logger:LogException(Exception, Object)
    6. UnityEngine.Debug:LogException(Exception)
    7. UnityEditor.Build.Pipeline.Utilities.BuildLogger:LogException(Exception) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\BuildLogger.cs:134)
    8. UnityEditor.Build.Pipeline.Utilities.<>c__DisplayClass28_1:<LoadCachedData>b__0(Int32) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\BuildCache.cs:378)
    9. System.Threading.Tasks.<>c__DisplayClass17_0`1:<ForWorker>b__1()
    10. System.Threading.Tasks.Task:InnerInvoke()
    11. System.Threading.Tasks.Task:InnerInvokeWithArg(Task)
    12. System.Threading.Tasks.<>c__DisplayClass178_0:<ExecuteSelfReplicating>b__0(Object)
    13. System.Threading.Tasks.Task:ExecuteSelfReplicating(Task)
    14. System.Threading.Tasks.Task:Execute()
    15. System.Threading.Tasks.Task:ExecutionContextCallback(Object)
    16. System.Threading.ExecutionContext:RunInternal(ExecutionContext, ContextCallback, Object, Boolean)
    17. System.Threading.ExecutionContext:Run(ExecutionContext, ContextCallback, Object, Boolean)
    18. System.Threading.Tasks.Task:ExecuteWithThreadLocal(Task&)
    19. System.Threading.Tasks.Task:ExecuteEntry(Boolean)
    20. System.Threading.Tasks.ThreadPoolTaskScheduler:TryExecuteTaskInline(Task, Boolean)
    21. System.Threading.Tasks.TaskScheduler:TryRunInline(Task, Boolean)
    22. System.Threading.Tasks.Task:InternalRunSynchronously(TaskScheduler, Boolean)
    23. System.Threading.Tasks.Task:RunSynchronously(TaskScheduler)
    24. System.Threading.Tasks.Parallel:ForWorker(Int32, Int32, ParallelOptions, Action`1, Action`2, Func`4, Func`1, Action`1)
    25. System.Threading.Tasks.Parallel:For(Int32, Int32, ParallelOptions, Action`1)
    26. UnityEditor.Build.Pipeline.Utilities.BuildCache:LoadCachedData(IList`1, IList`1&) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Utilities\BuildCache.cs:350)
    27. UnityEditor.Build.Pipeline.Tasks.CalculateAssetDependencyData:RunInternal(TaskInput, TaskOutput&) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Tasks\CalculateAssetDependencyData.cs:222)
    28. UnityEditor.Build.Pipeline.Tasks.CalculateAssetDependencyData:Run() (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Tasks\CalculateAssetDependencyData.cs:130)
    29. UnityEditor.Build.Pipeline.BuildTasksRunner:Run(IList`1, IBuildContext) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\Shared\BuildTasksRunner.cs:56)
    30. UnityEditor.Build.Pipeline.ContentPipeline:BuildAssetBundles(IBundleBuildParameters, IBundleBuildContent, IBundleBuildResults&, IList`1, IContextObject[]) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.19.1\Editor\ContentPipeline.cs:145)
    31. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:DoBuild(AddressablesDataBuilderInput, AddressableAssetsBuildContext) (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Build\DataBuilders\BuildScriptPackedMode.cs:236)
    32. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:BuildDataImplementation(AddressablesDataBuilderInput) (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Build\DataBuilders\BuildScriptPackedMode.cs:77)
    33. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptBase:BuildData(AddressablesDataBuilderInput) (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Build\DataBuilders\BuildScriptBase.cs:91)
    34. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContentImpl() (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Settings\AddressableAssetSettings.cs:2146)
    35. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent(AddressablesPlayerBuildResult&) (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Settings\AddressableAssetSettings.cs:2128)
    36. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent() (at Library\PackageCache\com.unity.addressables@1.18.13\Editor\Settings\AddressableAssetSettings.cs:2095)
    37.  
     
  7. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    324
    We have a fix for this in SBP 1.19.2
     
    SolidAlloy likes this.
  8. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,017
    Last edited: Aug 18, 2021
  9. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    324
    #2 is fixed, #1 is something we are still working on as we want to make sure that we only bubble up failures, not things we can just ignore and reprocess. Most of the time we can just ignore the error and reprocess it for this build.
     
    Peter77 likes this.
unityunity