Playmaker Forum

Bug Reporting => PlayMaker Bug Reporting => Topic started by: LordHorusNL on December 13, 2017, 11:26:26 AM

Title: Run FSM Stutter (Garbage Collection?)
Post by: LordHorusNL on December 13, 2017, 11:26:26 AM
I'm having some performance problems when using the Run FSM action as part of my VR system to interact with objects.

After using Run FSM/Finish FSM about a 100 times my game starts to stutter and becomes unplayable.

This does not happen when i remove the Run FSM actions and replace the templates with normal Fsm's.

This feels like a garbage collection problem of some sorts, are the template Fsm's actually being unloaded from memory when running Finish Fsm?
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: djaydino on December 13, 2017, 12:15:10 PM
Hi.
Can you give some more information what is in the fsm
and maybe a video showing the issue?
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: LordHorusNL on December 13, 2017, 06:26:33 PM
Okey found the culprate! i was using one "Run Template FSM" from the ecosystem.

For some reason it does not seem to finish the templates but keeps them active, so not a playmaker bug afterall.

I'll see if this actions can be updated by the author.
Title: Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
Post by: jeanfabre on December 14, 2017, 01:47:47 AM
Hi,

 I am here :) run Fsm Template is tricky action ( and I don't recommend it, it's advanced, I am thinking about remove it as well...), can you tell me what you think is the problem, maybe I can do something?

 Bye,

 Jean
Title: Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
Post by: LordHorusNL on December 14, 2017, 06:41:50 AM
Hi jean

Run Template FSM is very handy because it allows me to choose the template to run as a variable (so i can change it on the fly)

What i think is happening is that the action somehow does not finish the template properly when running the "Finish FSM" action inside itself.

I think this is happening because the stutter i get from using this action seems to be cumulative, in that it gets progressively worse the more you use it.

However this is just from observation!

So if the action can be fixed, or replaced with a "Run FSM" variant that lets the user define the template as a variable. That would be great.

I was going to look into that myself today.
Title: Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
Post by: jeanfabre on December 20, 2017, 02:53:06 AM
Hi,

 yeah, you have a good point here, I am not cleaning up the objects:

 try this ( update the method, that method already exists)

Code: [Select]
  public override void OnExit()
        {
            if (runFsm != null)
            {
                runFsm.Stop();
            }

fsmTemplateControl = new FsmTemplateControl();
runFsm = null;
        }

let me know how it goes.

 also, you can profile this and maybe you'll see the increase in memory consuption in your case that youc an then compare with this modification.

 Bye,

 Jean
Title: Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
Post by: LordHorusNL on December 20, 2017, 10:02:32 AM
Thanks for looking into this jean.

Unfortunately the fix did not solve the problem, i did find that there is a memory spike when using RundTemplateFSM that is not present when using RunFSM.

However i only see the spike when i run the action, and i have no idea if this could explain the stutter buildup i am experiencing.

(https://i.imgur.com/a6eRrMA.png)

Still new to the profiler, so not to sure what i could be looking for.

Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: jeanfabre on December 21, 2017, 01:31:40 AM
Hi,

 ok, simply click on the spike to bring the head to that spot and check what is taking the most time in the detailed.

The problem with running fsm is that it is about instantiating something at runtime and this alwasy is a costly operation, if the timing is wrong ( likely when in your gameloop) then it becomes noticeable.

I'll run the debugger on some project that use this action too and see if I can spot this on my end.
 
please bump me early next week if I haven't replied...  I need the bumps :)

 Bye,

 Jean
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: LordHorusNL on December 21, 2017, 07:04:40 AM
Ok, so i ran a comparison on the two actions and there seems to be a huge difference in resources used in the update call. (whatever it's called)

Note PlayMakerFSM.Update()

Run FSM
https://i.imgur.com/NQZW1BZ.png

Run Template FSM
https://i.imgur.com/UDDinwH.png

Should assigning a template at runtime be this costly? compared to in the editor.
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: LordHorusNL on January 05, 2018, 10:53:52 AM
*Bump*

Jean, I was wondering if you've had any time to look into this.
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: jeanfabre on January 09, 2018, 05:32:48 AM
Hi,

 Not yet, thanks for the bump :) Let me move that up in my long to do list :)

 Bye,

 Jean
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: jeanfabre on January 09, 2018, 06:02:15 AM
Hi,

 ok, I have found some obvious bad memory management, can you update the action from the Ecosystem, this will definitely improve the situation. I did not found anything when profiling, so let me know if that doesn't improve the situation on your end, maybe I'll need to check with your project.


 Bye,

 Jean
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: LordHorusNL on January 11, 2018, 06:35:52 PM
Thanks for the update jean, unfortunately the problem still persists.

The system is setup for VR right now, so i'll have to see if i can rework it for Non-VR and see if the problem is really with the action.
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: jeanfabre on January 12, 2018, 01:47:33 AM
Hi,
 
Ok, keep me up to date.

 Bye,

Jean
Title: Re: Run FSM Stutter (Garbage Collection?) [SOLVED]
Post by: Gua on March 20, 2018, 03:24:11 AM
Hi,

 I am here :) run Fsm Template is tricky action
Run FSM is a different action? And Run FSM is fine?
Title: Re: Run FSM Stutter (Garbage Collection?)
Post by: LordHorusNL on March 20, 2018, 01:32:17 PM
Run FSM works just fine.

Runs FSM Template seems to have some problems in certain situations.