anatawa12 / AvatarOptimizer

AAO: Avatar Optimizer: Non Destructive Avatar Optimization Utilities
MIT License
161 stars 23 forks source link

Avatar fails to build with AAO 1.7.0 "System.FormatException: Input string was not in a correct format." #1066

Closed inkuxuan closed 3 months ago

inkuxuan commented 4 months ago

When using AAO 1.7.0 or later (tested with 1.7.0, 1.7.1, 1.7.3), the following error occurs.

image

System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <eef08f56e2e042f1b3027eca477293d9>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <eef08f56e2e042f1b3027eca477293d9>:0 
  at System.Int32.Parse (System.String s) [0x00016] in <eef08f56e2e042f1b3027eca477293d9>:0 
  at Anatawa12.AvatarOptimizer.Processors.AnimatorOptimizer.AnimatablePropertyRegistry+<>c__DisplayClass4_0.<.cctor>b__1 (System.String prop) [0x00078] in .\Packages\com.anatawa12.avatar-optimizer\Editor\Processors\RemoveInvalidProperties.cs:73 
  at Anatawa12.AvatarOptimizer.Processors.AnimatorOptimizer.RemoveInvalidProperties.Execute (nadena.dev.ndmf.BuildContext context, Anatawa12.AvatarOptimizer.Processors.TraceAndOptimizes.TraceAndOptimizeState state) [0x0005f] in .\Packages\com.anatawa12.avatar-optimizer\Editor\Processors\RemoveInvalidProperties.cs:31 
  at Anatawa12.AvatarOptimizer.Processors.TraceAndOptimizes.TraceAndOptimizePass`1[T].Execute (nadena.dev.ndmf.BuildContext context) [0x00010] in .\Packages\com.anatawa12.avatar-optimizer\Internal\TraceAndOptimizeBase\TraceAndOptimizeProcessor.cs:95 
  at nadena.dev.ndmf.Pass`1[T].nadena.dev.ndmf.IPass.Execute (nadena.dev.ndmf.BuildContext context) [0x00000] in .\Packages\nadena.dev.ndmf\Editor\API\Fluent\Pass.cs:64 
  at nadena.dev.ndmf.ConcretePass.Execute (nadena.dev.ndmf.BuildContext context) [0x00000] in .\Packages\nadena.dev.ndmf\Editor\API\Solver\PluginResolver.cs:36 
  at nadena.dev.ndmf.BuildContext.RunPass (nadena.dev.ndmf.ConcretePass pass) [0x00124] in .\Packages\nadena.dev.ndmf\Editor\API\BuildContext.cs:350 
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <eef08f56e2e042f1b3027eca477293d9>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <eef08f56e2e042f1b3027eca477293d9>:0 
  at System.Int32.Parse (System.String s) [0x00016] in <eef08f56e2e042f1b3027eca477293d9>:0 
  at Anatawa12.AvatarOptimizer.Processors.AnimatorOptimizer.AnimatablePropertyRegistry+<>c__DisplayClass4_0.<.cctor>b__1 (System.String prop) [0x00078] in .\Packages\com.anatawa12.avatar-optimizer\Editor\Processors\RemoveInvalidProperties.cs:73 
  at Anatawa12.AvatarOptimizer.Processors.AnimatorOptimizer.RemoveInvalidProperties.Execute (nadena.dev.ndmf.BuildContext context, Anatawa12.AvatarOptimizer.Processors.TraceAndOptimizes.TraceAndOptimizeState state) [0x0005f] in .\Packages\com.anatawa12.avatar-optimizer\Editor\Processors\RemoveInvalidProperties.cs:31 
  at Anatawa12.AvatarOptimizer.Processors.TraceAndOptimizes.TraceAndOptimizePass`1[T].Execute (nadena.dev.ndmf.BuildContext context) [0x00010] in .\Packages\com.anatawa12.avatar-optimizer\Internal\TraceAndOptimizeBase\TraceAndOptimizeProcessor.cs:95 
  at nadena.dev.ndmf.Pass`1[T].nadena.dev.ndmf.IPass.Execute (nadena.dev.ndmf.BuildContext context) [0x00000] in .\Packages\nadena.dev.ndmf\Editor\API\Fluent\Pass.cs:64 
  at nadena.dev.ndmf.ConcretePass.Execute (nadena.dev.ndmf.BuildContext context) [0x00000] in .\Packages\nadena.dev.ndmf\Editor\API\Solver\PluginResolver.cs:36 
  at nadena.dev.ndmf.BuildContext.RunPass (nadena.dev.ndmf.ConcretePass pass) [0x00124] in .\Packages\nadena.dev.ndmf\Editor\API\BuildContext.cs:350 

This reproduces 100% on Unity 2022.3.6f1,

Avatar root object components: image

AAO Trace and Optimize is in all default settings.

This error does NOT occur on AAO 1.6.13 (The last version of 1.6) or earlier

anatawa12 commented 4 months ago

Thank you for reporting!

It looks material slot animation targets unexpected property. Could you provide minimum information about the animation? (I'll explain how below.)

AAO expects animating m_Materials.Array.data[<number>] if property name start with m_Materials.Array.data[ but it looks your animation doesn't.

Here's the way to provide minimum information about your animation. This will create text file that contains which property are animated in your avatar but it doesn't contain any animation curve information.

  1. Please backup (duplicate) your scene first.
  2. Remove AAO Trace and Optimize component.
  3. Left-click your avatar and click ModularAvatar/manual bake avatar
  4. Open Animator Parser Debug Window V2 in Tools/Avatar Optimizer/Animator Parser Debug Window V2 in tool bar above.
  5. Set your avatar to Avatar in the Animator Parser Debug Window V2.
  6. Click Parse button.
  7. Click Copy Parsed Text to copy the animation information
  8. Send me the copied text. You may use github gists. If you want to send me the data privately, you may send to twitter or fediverse (misskey/mastodon and tell me that here.
inkuxuan commented 4 months ago

@anatawa12 Thank you for your prompt reply.

  1. Click Copy Parsed Text to copy the animation information

On following your given step, this causes an error and copies nothing into the clipboard. Here is the details of the error.

(Note that the version of AAO which caused this error is 1.7.0)

NullReferenceException: Object reference not set to an instance of an object
Anatawa12.AvatarOptimizer.AnimatorParsersV2.AnimatorParserDebugWindow.CreateText (System.Boolean detailed) (at ./Packages/com.anatawa12.avatar-optimizer/Editor/AnimatorParserV2/AnimatorParserDebugWindow.cs:73)
Anatawa12.AvatarOptimizer.AnimatorParsersV2.AnimatorParserDebugWindow.OnGUI () (at ./Packages/com.anatawa12.avatar-optimizer/Editor/AnimatorParserV2/AnimatorParserDebugWindow.cs:35)
UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition) (at <347e3e2bef8c4deb82c9790c6e198135>:0)
UnityEditor.DockArea.DrawView (UnityEngine.Rect dockAreaRect) (at <347e3e2bef8c4deb82c9790c6e198135>:0)
UnityEditor.DockArea.OldOnGUI () (at <347e3e2bef8c4deb82c9790c6e198135>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Action onGUIHandler, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, System.Boolean canAffectFocus) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUIRaw (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.SendEventToIMGUI (UnityEngine.UIElements.EventBase evt, System.Boolean canAffectFocus, System.Boolean verifyBounds) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.IMGUIContainer.ProcessEvent (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEvent (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtCurrentTargetAndPhase (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.CallbackEventHandler.HandleEventAtTargetPhase (UnityEngine.UIElements.EventBase evt) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.MouseCaptureDispatchingStrategy.DispatchEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ApplyDispatchingStrategies (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, System.Boolean imguiEventIsInitiallyUsed) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEventQueue () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.OpenGate () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcherGate.Dispose () (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.ProcessEvent (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.EventDispatcher.Dispatch (UnityEngine.UIElements.EventBase evt, UnityEngine.UIElements.IPanel panel, UnityEngine.UIElements.DispatchMode dispatchMode) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.BaseVisualElementPanel.SendEvent (UnityEngine.UIElements.EventBase e, UnityEngine.UIElements.DispatchMode dispatchMode) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at <d30253adcd2a48faba9ee2264e211f5a>:0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <4397ca26b8a24183a25a95ffae967e39>:0)
anatawa12 commented 4 months ago

Sorry, I found the debug window is not working with object reference curves. Could you manually let me know the property name of object reference curves?

inkuxuan commented 4 months ago

Could you manually let me know the property name of object reference curves?

Sorry but I'm not sure what you are referring to by "object reference curves" Would you please provide some steps?

anatawa12 commented 4 months ago

one exampleof object reference curve is material swapping animation. I want to see the property name of the property. One of the way is open animation clip with material swap animation and see left side to know property name.

inkuxuan commented 4 months ago

image

Here is a screenshot of a material-swap animation used in the scene. I'm not sure how many animations are involved and do you need all of them?

anatawa12 commented 4 months ago

Thank you. It looks animating File ID and Path ID is unknown to AAO and that's why it cause exception.

Do you know about the animation is for? The Material Reference[N] is well-known and AAO understands.

inkuxuan commented 4 months ago

The animation is for swapping materials. I created them manually. image

anatawa12 commented 4 months ago

Umm... AFAIK, Material swapping animation only createsMaterial Reference[N]... but Thank you.

inkuxuan commented 3 months ago

Indeed, another animation swapping the same objects contains no FileID and PathID.

image