Cinemachine Allocation Every Frame With ReadControlValueOverride

I have a problem with allocations (0.8 KB) every frame when using Cinemachine:

As far as I can tell this is because I’ve set CinemachineInputAxisController.ReadControlValueOverride (that’s the ExponentialControlValueReader), but the allocation is not coming from my code.

I think this is the guilty line (from com.unity.cinemachine\Runtime\Helpers\CinemachineInputAxisController.cs Line 212:):

// If client installed an override, use it
if (context.ReadControlValueOverride != null)
    return context.ReadControlValueOverride.Invoke(m_CachedAction, hint, context, ReadInput);

That final argument ReadInput is a class method, passed as a ControlValueReader delegate. That means a new delegate object will be allocated every call!

Delegate creation should be cached to avoid this.

Please report this if you haven’t already: Help => Report a bug

Will do, I wanted a quick “sanity check” first to make sure I wasn’t missing something obvious!