[VersionedCallback] feedback

In SBP 1.7.0 you added this:

  • Added [VersionedCallback] attribute for flagging build impacting changes to IProcessScene, IProcessSceneWithReport, IPreprocessShaders, and IPreprocessComputeShaders callbacks.

This is probably meant to fix the issues I reported earlier:

  • (Case 1297713) Addressables doesn’t create proper build when “Scene Postprocessor” changed ( forum post )
  • (Case 1321433) Addressables/SBP don’t detect IPreprocessShaders changes ( forum post )

Unfortunately, the way this is implemented doesn’t fix the issue for me. The problem is that you implemented versioning per type, but I need this per object instance. I need this just like it’s found in AssetPostprocessor.GetVersion, which I assumed would be how you’re going to implement it in SBP too.

Please let me explain why [VersionedCallback] isn’t solving the problem.

My “Scene Processing Pipeline” is stored in a ScriptableObject asset, it looks like this in the Inspector:

Each of these “Components” performs a specific task, for example removing GameObjects with a specific tag. Rather than coding the “scene processing”, you have a few “lego bricks” that you can mix&match to what you need to perform.

The actual IProcessSceneWithReport implementation just runs the asset and it looks like this:

[VersionedCallback(1)]
class MyCustomBuildProcessor : IProcessSceneWithReport
{
    public int callbackOrder
    {
        get { return 0; }
    }

    public void OnProcessScene(UnityEngine.SceneManagement.Scene scene, BuildReport report)
    {
        var context = SceneProcessingPipeline.Begin("testasset");
        try
        {
            SceneProcessingPipeline.ProcessScene(context, scene);
        }
        finally
        {
            SceneProcessingPipeline.End(context);
        }
    }
}

As you already imagine, changing the Scene Processing Pipeline Asset does not rebuild scenes, because changing the asset content does not cause the VersionedCallback attribute version to change.

Instead of specifying the version on the type, I need to be able return the version of the IProcessSceneWithReport object instance. For example like this:

class MyCustomBuildProcessor : IProcessSceneWithReport
{
    public int callbackOrder
    {
        get { return 0; }
    }
 
    public uint GetVersion()
    {
      // return hash of asset to return a different version each time the content changed
        get { return HashOfAssetArtifact(); }
    }
 
    public void OnProcessScene(UnityEngine.SceneManagement.Scene scene, BuildReport report)
    {
        var context = SceneProcessingPipeline.Begin("testasset");
        try
        {
            SceneProcessingPipeline.ProcessScene(context, scene);
        }
        finally
        {
            SceneProcessingPipeline.End(context);
        }
    }
}

I hope you can revisit your VersionedCallback implementation and come up with something that solves the issue for me. Thank you in advance.

2 Likes

Thanks for the feedback, Peter! I’ll flag this for the team to review!

1 Like

The bug-report was resolved with “works as designed” and this note was added:

I would like to understand why it’s such a gigantic task with breaking API changes. From the outside, it looks like a simple change actually that can be tackled in different ways that should not cause breaking API changes:

Using an interface

  • Introduce interface that allows to implement a “GetVersion” property
  • Rather than adding the VersionedCallback to the type, you would implement the “GetVersion” interface
  • The build pipeline that’s currently using the VersionedCallback attribute would create an object instance of the processor to call its “GetVersion” method (if it implements the interface).

Using an attribute
If you don’t like to introduce an interface, support that the VersionedCallback can be added to a method. The build-system would use the return value of that method instead of the hard-coded version number you pass to the VersionedCallback ctor. Even if it supports static methods only would be a lot more useful than it’s right now.

What do I miss?

Is your decision to not fix the problem final?

Hey Peter,

We went the attribute route as that allowed us to make a change to just the Scriptable Build Pipeline package to provide a solution to the problem of callbacks not being versioned to all unity versions supported by the Scriptable Build Pipeline, and not force users to upgrade Unity versions to get access to this fix.

There’s some technical limitations to making this work instanced based to solve your specific use case. Main one is that the package doesn’t have access to the constructed instances of these callbacks as this information is privately owned by the editor. It might be possible we can solve this with reflection but we want to be careful with excessive reliance on reflection due to possible performance hits and how easily it can break. I created a feature request to look into allowing VersionedCallback to be added to methods and support instanced based versioning, but no immediate eta.

2 Likes

Hello :slight_smile: Can you provide some info by now, whether it has been planned to fix? It’s still a problem for me that I would like to see resolved.

Ah it sounds like this would also resolve the issue I’m also running into - Clear Specific Player Content - Unity Engine - Unity Discussions

+1 this really needs to be resolved :slight_smile:

Ping: I haven’t forgotten about this feedback. Sadly I don’t have anything I can mention yet.

Any news on this front, Ryan? Thank you for the help :slight_smile: