Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor failure when using data declared in the managed code in animation graph #2620

Open
mtszkarbowiak opened this issue May 18, 2024 · 1 comment

Comments

@mtszkarbowiak
Copy link
Contributor

mtszkarbowiak commented May 18, 2024

Issue description:

Attempts to set parameters of animation graph of type declared in managed code leads to problems with the editor.

Note 1.: I'm not sure if the bug is triggered only for C# structs. I didn't check for C++.
Note 2.: There seems to be no bugs in built game. The bug is very annoying, but does not cause issues in built game.

Steps to reproduce:

  1. Declare a structure in C# code.
  2. Create animation graph with this struct as input.
  3. Run the game and modify its value via code.
  4. Select the model with changed parameter in the editor (during runtime).

The editor crashes, sometimes recovering, sometimes not into a weird zombie state.

Flax version:

1.8.1

[ 00:01:06.905 ]: [Error] Native interop exception!
[ 00:01:06.908 ]: [Warning] Exception has been thrown. Invalid ManagedHandle
Stack strace:
   at FlaxEngine.Interop.ManagedHandle.ManagedHandlePool.GetObject(IntPtr handle) in ...\FlaxEngine\Source\Engine\Engine\NativeInterop.Managed.cs:line 536
   at FlaxEngine.Interop.ManagedHandle.get_Target() in ...\FlaxEngine\Source\Engine\Engine\NativeInterop.Managed.cs:line 380
   at FlaxEngine.Interop.ManagedHandleMarshaller.NativeToManaged.ConvertToManaged(IntPtr unmanaged) in ...\FlaxEngine\Source\Engine\Engine\NativeInterop.Marshallers.cs:line 34
   at FlaxEngine.AnimatedModel.Internal_GetParameterValue1(IntPtr __obj, Guid& id) in ...\FlaxEngine\Microsoft.Interop.LibraryImportGenerator\Microsoft.Interop.LibraryImportGenerator\LibraryImports.g.cs:line 28473
   at FlaxEngine.AnimatedModel.GetParameterValue(Guid id) in ...\FlaxEngine\Cache\Intermediate\FlaxEditor\Windows\x64\Debug\Level\Level.Bindings.Gen.cs:line 1844
   at FlaxEditor.CustomEditors.Dedicated.AnimatedModelEditor.<>c.<Initialize>b__0_0(Object instance, GraphParameter parameter, Object tag) in ...\FlaxEngine\Source\Editor\CustomEditors\Dedicated\AnimatedModelEditor.cs:line 31
   at FlaxEditor.Surface.SurfaceUtils.DisplayGraphParameters(LayoutElementsContainer layout, GraphParameterData[] data, GetGraphParameterDelegate getter, SetGraphParameterDelegate setter, ValueContainer values, GetGraphParameterDelegate defaultValueGetter, CustomPropertySpawnDelegate propertySpawn) in ...\FlaxEngine\Source\Editor\Surface\SurfaceUtils.cs:line 316
   at FlaxEditor.CustomEditors.Dedicated.AnimatedModelEditor.Initialize(LayoutElementsContainer layout) in ...\FlaxEngine\Source\Editor\CustomEditors\Dedicated\AnimatedModelEditor.cs:line 30
   at FlaxEditor.CustomEditors.CustomEditor.Initialize(CustomEditorPresenter presenter, LayoutElementsContainer layout, ValueContainer values) in ...\FlaxEngine\Source\Editor\CustomEditors\CustomEditor.cs:line 124
   at FlaxEditor.CustomEditors.Editors.GenericEditor.Initialize(CustomEditorPresenter presenter, LayoutElementsContainer layout, ValueContainer values) in ...\FlaxEngine\Source\Editor\CustomEditors\Editors\GenericEditor.cs:line 702
   at FlaxEditor.CustomEditors.CustomEditorPresenter.RootEditor.Initialize(LayoutElementsContainer layout) in ...\FlaxEngine\Source\Editor\CustomEditors\CustomEditorPresenter.cs:line 181
   at FlaxEditor.CustomEditors.CustomEditor.Initialize(CustomEditorPresenter presenter, LayoutElementsContainer layout, ValueContainer values) in ...\FlaxEngine\Source\Editor\CustomEditors\CustomEditor.cs:line 124
   at FlaxEditor.CustomEditors.CustomEditorPresenter.RootEditor.Setup(CustomEditorPresenter presenter) in ...\FlaxEngine\Source\Editor\CustomEditors\CustomEditorPresenter.cs:line 157
   at FlaxEditor.CustomEditors.CustomEditorPresenter.BuildLayout() in ...\FlaxEngine\Source\Editor\CustomEditors\CustomEditorPresenter.cs:line 400
   at FlaxEditor.CustomEditors.CustomEditorPresenter.OnSelectionChanged() in ...\FlaxEngine\Source\Editor\CustomEditors\CustomEditorPresenter.cs:line 476
   at FlaxEditor.CustomEditors.CustomEditorPresenter.Select(IEnumerable`1 objects) in ...\FlaxEngine\Source\Editor\CustomEditors\CustomEditorPresenter.cs:line 371
   at FlaxEditor.Windows.PropertiesWindow.OnSelectionChanged() in ...\FlaxEngine\Source\Editor\Windows\PropertiesWindow.cs:line 77
   at FlaxEditor.Modules.SceneEditingModule.OnSelectionChanged() in ...\FlaxEngine\Source\Editor\Modules\SceneEditingModule.cs:line 684
   at FlaxEditor.States.PlayingState.RestoreSelection() in ...\FlaxEngine\Source\Editor\States\PlayingState.cs:line 129
   at FlaxEditor.States.PlayingState.OnEnter() in ...\FlaxEngine\Source\Editor\States\PlayingState.cs:line 161
   at FlaxEngine.Utilities.StateMachine.SwitchState(State nextState) in ...\FlaxEngine\Source\Engine\Utilities\StateMachine.cs:line 128
   at FlaxEditor.States.EditorStateMachine.SwitchState(State nextState) in ...\FlaxEngine\Source\Editor\States\EditorStateMachine.cs:line 110
   at FlaxEngine.Utilities.StateMachine.GoToState(State state) in ...\FlaxEngine\Source\Engine\Utilities\StateMachine.cs:line 88
   at FlaxEngine.Utilities.StateMachine.GoToState[TStateType]() in ...\FlaxEngine\Source\Engine\Utilities\StateMachine.cs:line 62
   at FlaxEditor.Modules.SimulationModule.OnUpdate() in ...\FlaxEngine\Source\Editor\Modules\SimulationModule.cs:line 310
   at FlaxEditor.Editor.Update() in ...\FlaxEngine\Source\Editor\Editor.cs:line 492
[ 00:01:06.908 ]: [Warning] Exception has been thrown.
Invalid ManagedHandle
@GoaLitiuM
Copy link
Contributor

Can you post a simple project to reproduce this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants