Search Issue Tracker

In Progress

Fixed in 2022.3.70f1, 6000.2.15f1, 6000.3.0f1, 6000.5.0a3

Fix In Review for 6000.4.0a6

In Progress in 6000.5.X

Votes

0

Found in

2022.3.62f3

6000.1.15f1

6000.2.6f2

6000.3.0b10

6000.4.0a4

6000.5.0a1

Issue ID

UUM-126809

Regression

Yes

URP is using in-memory assets without saving them

Content Build

-

Scopely migrated from Unity 6000.1.0f1 to 6000.1.17f1. The team is using Asset Bundles via the {}Legacy Build Pipeline{}, After migration  they started to see a drastic jump in build times; what used to take 20 minutes per incremental build per platform, jumped to 3 hours+ . The issue is introduced by https://jira.unity3d.com/browse/UUM-109242
 
In a nutshell, the important bit of that small commit is in 
{code:java}
BuildAssetBundle.cpp{code}
, where 2 calls to 
{code:java}
Scripting::UnityEditor::Build::BuildPipelineInterfacesProxy::InitializeBuildCallbacks(kAllAssetBundleProcessors);{code}
 were moved to 
{code:java}
BuildAssetBundlesImplementation{code}
Before, they were done early, inside our two flavours of 
{code:java}
BuildAssetBundles {code}
one that does it from the asset Database, and the one that does it from AssetBundleBuildInfos.
These two then called 
{code:java}
BuildAssetBundlesImplementation {code}
, which does the hefty lifting.
Now, the call to the InitializeBuildCallbacks is done properly, after the BuildTarget stuff is initialized. This is the intended fix.
Now, this causes an issue when you use URP. Because this call is now done AFTER BuildAssetBundlesImplementation calls AssetDatabase.SaveAssets(). This means that now, any asset changed inside the initialization of the callbacks (debatable if that should happen), is not saved to disc. Before, they were saved.
This is crucial for URP though, because of its UpdateShaderPrefilterDataBeforeBuild:
 
{code:java}
class UpdateShaderPrefilteringDataBeforeBuild : IPreprocessShaders {     public int callbackOrder => -100;       public UpdateShaderPrefilteringDataBeforeBuild()     {         ShaderBuildPreprocessor.GatherShaderFeatures(Debug.isDebugBuild);     }   public void OnProcessShader(Shader shader, ShaderSnippetData snippetData, IList<ShaderCompilerData> compilerDataList){} }{code}
 
As you see, this IPreprocessShaders is not just initializing stuff, it's actually doing work in the constructor. And that work changes the URP Asset content in memory.
So before the fix, URP was doing its change as part of the process initialization code, then the build asset bundle implementation was saving them to disc. Now it's not.
This is crucial, because when building bundles that contain shaders, the hash of the bundle includes the hash of the URP Asset. If it was not saved, the bundle are going to use the old one.

Add comment

Log in to post comment