Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: coxy17 on February 03, 2017, 05:48:23 AM

Title: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 03, 2017, 05:48:23 AM
Hi

I have read around the forum but cant find an answer, i have a Activate/Deactivate script on the parent of a platform which i just want to disable. Im testing using Unity remote on an android when i noticed a spike (attached screenshot) in the 'PlaymakerFSM.OnDisable'. Any ideas why this is?

The moving platform has a RigidBody with Kinematic enabled and all children just have OnTriggerEnter scripts on them. Any ideas?


also attached a onTriggerEnter screenshot


also i created a new scene and added just a box with child objects and i can get the same issue. Deep profile screenshot attached (3rd)


Nick

Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 06, 2017, 01:25:13 AM
Hi,

 what you need to look for is what actually happens on these activated gameobject, typically, how do you move these objects?

 try to replace the platform with a dummy one that doesn't nothing and start fresh, if you still see the spikes, then it's simply that there is too much, regardless of your implement logic inside Playmaker.

Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 06, 2017, 03:54:32 AM
Hi Jean

I'll give that a go and see what happens

All i had before was a scene with just one platform (nothing else other than a skybox) and attached a script OnTriggerEnter (5 FSM scripts). The platform has a rigid body as ive read that i need to do this on objects which dont stay static (for mobile performance). The object doesn't move as its used as a vanishing platform which appears every 3 seconds and then disappears for 3 seconds. in a constant loop.

In the screenshot from the first post it shows the profiler for the above scene, so i don't know why deactivating a game object with a FSM script using only a  OnTriggerEnter creates garbage?

The object which is vanishing using disable/enable is just a imported very low poly mesh, its small enough to be dynamically batched.

Also i have tried a different test, i decided to not activate/deactivate the game object and instead use 'DisableFSM' to see what happens when the scripts are disabled on there own and keep the object untouched, the disabled FSM's still create a 0.7KB of garbage (per script) is this normal? just for disabling a FSM on one game object?

Nick
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 06, 2017, 08:35:08 AM
 Hi,

 uhm, ok, what dataversion do you have in the Fsm inspector in the PlayMaker Editor, if your project is old, maybe the fsm is carrying over data from previous data structure of PlayMaker, I recall something like that.

 

Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 06, 2017, 08:50:28 AM
Hi

Ok yes my project is 2 years old and im just developing it further so i will take a look when i get home after work. If it is the case then what can i do?

Nick
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 06, 2017, 02:55:16 PM
Hi Jean

I've checked and i have Data Version 2.

also tested in a new scene now with a cube and a fsm with deactivate and i get 0.7kb garbage.



Nick
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 08, 2017, 02:46:37 PM
Hi,

 I would copy the whole fsm and paste it into a new one, remove the old one and see if the garbage collection is still here.

 Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 08, 2017, 03:32:50 PM
Hi Jean

I did this. I setup a new project and imported playmaker and setup a cube and added a new fsm. Still the same

When I do this it still says data version 2 on the fsm. Should it be this?

Nick
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 09, 2017, 02:13:55 AM
HI,

 ok, dataversion 2 is good, it if you had dataversion 1 that it would have been problematic.

 I'll raise a case internally, to check if something can be done on this.

Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 09, 2017, 08:04:22 AM
Thanks Jean. 

I thought I was doing something wrong for ages now haha. 

I hope there is a resolution otherwise it's going to be a big performance issue for my game with alot of enable and disable fsms.

Thanks
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 10, 2017, 12:57:09 AM
Hi,

Ok, since you are still in editor, this is actually coming from the PlayMaker editor logging system, so nothing to worry about when you'll deploy, this won't happen.

 Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 10, 2017, 03:23:46 AM
Hi Jean

Ok yes that makes sense then as in the deep profiler it has FSM Logs in it. So even with the Unity Remote 5 it shows so i guess ill have to log this as ok. anyway is there a way i can check this out of the Unity Editor at all?

Also was this the same issue for when i deactivated the game object? i guess so as all that was attached to the game object was the FSM's.

Thanks Jean for looking into this!
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 10, 2017, 09:10:43 AM
Hi,

 Not sure, the best way is to have android tools and watch memory consumption as you play your game.

 Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 11, 2017, 07:36:29 AM
ok thanks anyway
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 12, 2017, 06:21:14 PM
Hi Jean

I am struggling now as im testing in the profiler and it seems that playmaker is logging alot more than i though in the Editor. so its becoming hard to tell if my game is garbage free or not. Is there a way these notifications in the profiler can be turned off for remote profiling?

Nick
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 13, 2017, 01:30:22 AM
Hi,

I don't think it's possible no, but what you can do is go in the PlayMaker pref and turn off everything related to debugging, and also make a Unity layout that has no PlayMaker editor at all, nor the Unity Inspector, this is how you minimize Editor Impact.

But really, it's only when you profile when running from the device that you can see better what's going on ( while of course it still has a cost).

Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 14, 2017, 11:54:03 AM
Hi, i have disabled all settings for debugging and no luck. It still logs Trigger events and Activating Game Objects and Scripts. No good. I making it very difficult to see what id performing well and not, a nightmare for a non development guy. Why cant this be sorted? has it been programmed that way?

Or is there a guide for testing performance of playmaker scripts outside of the Unity Editor? as im looking at guides constantly and nothing looks easy. I have really enjoyed using playmaker so far and now im going to spend ages just just finding out what each spike means in the profiler.

Nick
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 15, 2017, 01:53:59 AM
Hi,

 can you paste the full logs entries? maybe they are inside actions, which means you simply have to comment them lines.

to test Performances outside Unity Editor, you must resort to the platform debugging tools themselves, so xCode for IOS for example.

Testing is really hard, don't think that it's easy task, cause it's not. So many layers of indirections between Unity, the compiler, and on top of that PlayMaker Framework which adds a level of complexity in testing is a beast to master for testing.

This is why it's important to monitor your development with the profiler often so that you detect for example such spikes as early as possible and you can then reflect on what happened since the last time you profiled and did not see these spikes.

To debug properly, you need to shut down whole features of your game, for example remove all enemies, all fancy effect, and have just your player, then add incrementally features, one after the other until you narrow down where the problem is.

Bye,

 Jean
Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 15, 2017, 08:39:11 AM
Hi Jean

Thanks for this information, im not sure how to get a full log from the profiler, so for until i do i have created the largest screenshot i can of the overall view of the profiler at the spike of garbage collection (attached)

I'll look around to see if i can get a full log.

ive created a basic scene with a wait action, which then switches state to then deactivate the child objects and then returns after 3 seconds (real time) I don't use the wait action in my actual game it was just to see what happens in my test scene.

Each child object has a onTriggerEnter script on each start state of the FSM.

In a large scene in my game I have 100 of these activations and it creates 2 MB of garbage. So alot for just deactivating and activating script.

Nick
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: jeanfabre on February 16, 2017, 12:42:48 AM
Hi,

 the best ways are likely them:

http://answers.unity3d.com/questions/32368/how-do-i-profile-on-an-android-device.html

have you tried this?

Bye,

 Jean
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 16, 2017, 02:04:20 PM
Hi Jean

Yes i have tried those methods

I have used ADK to see the cpu and gpu but gives little information. I have built and ran a new project with only one scene (with my device plugged in) and ran a deep profile once more. Attached are the results. Seems it is still an issue when i get turn off everything to do with playmaker in the editor too.

Brief overview of the scene setup

Empty game object (FSM with OnTriggerEnter & Disable Children FSM's script)
    - Cube Object
         - Box Collider Trigger (FSM with OnTriggerEnter)
    - Cube Object
         - Box Collider Trigger (FSM with OnTriggerEnter)
    - Cube Object
         - Box Collider Trigger (FSM with OnTriggerEnter)
    - Cube Object
         - Box Collider Trigger (FSM with OnTriggerEnter)

Tested On Samsung J3 & Samsung Galaxy S6 devices

Nick
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: brucezhu2018 on February 17, 2017, 07:49:30 AM
I have similar  issue  as well.
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 18, 2017, 10:23:45 AM
Hi brucezhu2018

What similar issue are you having? it would be good to know.
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: HeathClose on February 18, 2017, 05:29:22 PM
So I had some issues before with profiler showing me huge numbers in this thread...

http://hutonggames.com/playmakerforum/index.php?topic=14224.0 (http://hutonggames.com/playmakerforum/index.php?topic=14224.0)

During that research, I came across information on how to profile from your device into the unity editor to bypass all the editor overhead... and also how to use xcode instruments to profile as well...


Unity profiler
vid  "Profiler Overview for Beginners"...
https://youtu.be/tdGvsoASS3g (https://youtu.be/tdGvsoASS3g)

profiler from ios device
http://blog.collectivemass.com/2014/03/unity-profiler-ios/ (http://blog.collectivemass.com/2014/03/unity-profiler-ios/)
(not sure this post says it but you have to have it connected by usb and wifi both if I remember right)

xcode intruments...
this video "Unite Europe 2016 - Optimizing Mobile Applications"...
https://youtu.be/j4YAY36xjwE (https://youtu.be/j4YAY36xjwE)

pointed me to this post...
https://blogs.unity3d.com/2016/02/01/profiling-with-instruments/ (https://blogs.unity3d.com/2016/02/01/profiling-with-instruments/)
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: brucezhu2018 on February 19, 2017, 02:18:44 AM
Hi coxy17, I do have the similar issue,but mine is made with physics2D, so you can refer to may post:http://hutonggames.com/playmakerforum/index.php?topic=14166.msg65816
My project is very simple 2D shooting game , for the problem mentioned above, I rebuild a new scene for the test:
I only build an spawn point to shoot bullet every second, the bullet is come from the core game kit pool boss, the bullet use the rigidbody2d and fsm, the bullet is triggered by the OnTriggerEnter2D event when hit the collider tagged with enemy then the bullet will despawn to the poolboss.
I have profile my project in android device, there are still some Gc Alloc  mainly locate in the physics2d.onTriggerEnter2D, but the unity profiler only show N/A object in the right panel when I am profiling on device, so I can not tract what is the exact reason for the garbage collection.
Title: Re: Activate/Deactivate game objects and garbage in profiler
Post by: coxy17 on February 20, 2017, 04:16:05 AM
So I had some issues before with profiler showing me huge numbers in this thread...

http://hutonggames.com/playmakerforum/index.php?topic=14224.0 (http://hutonggames.com/playmakerforum/index.php?topic=14224.0)

During that research, I came across information on how to profile from your device into the unity editor to bypass all the editor overhead... and also how to use xcode instruments to profile as well...


Unity profiler
vid  "Profiler Overview for Beginners"...
https://youtu.be/tdGvsoASS3g (https://youtu.be/tdGvsoASS3g)

profiler from ios device
http://blog.collectivemass.com/2014/03/unity-profiler-ios/ (http://blog.collectivemass.com/2014/03/unity-profiler-ios/)
(not sure this post says it but you have to have it connected by usb and wifi both if I remember right)

xcode intruments...
this video "Unite Europe 2016 - Optimizing Mobile Applications"...
https://youtu.be/j4YAY36xjwE (https://youtu.be/j4YAY36xjwE)

pointed me to this post...
https://blogs.unity3d.com/2016/02/01/profiling-with-instruments/ (https://blogs.unity3d.com/2016/02/01/profiling-with-instruments/)


Hey HeathClose, i'll take a look at the links you sent. Im currently testing on Android so hopefully there might be references to this unless the guides are just for IOS. I looked at your other thread and i can see that you still have OnTriggerEnter garbage being collected http://hutonggames.com/playmakerforum/index.php?action=dlattach;topic=14224.0;attach=10318;image (http://hutonggames.com/playmakerforum/index.php?action=dlattach;topic=14224.0;attach=10318;image) was this still creating garbage outside of the Editor?


Hi coxy17, I do have the similar issue,but mine is made with physics2D, so you can refer to may post:http://hutonggames.com/playmakerforum/index.php?topic=14166.msg65816
My project is very simple 2D shooting game , for the problem mentioned above, I rebuild a new scene for the test:
I only build an spawn point to shoot bullet every second, the bullet is come from the core game kit pool boss, the bullet use the rigidbody2d and fsm, the bullet is triggered by the OnTriggerEnter2D event when hit the collider tagged with enemy then the bullet will despawn to the poolboss.
I have profile my project in android device, there are still some Gc Alloc  mainly locate in the physics2d.onTriggerEnter2D, but the unity profiler only show N/A object in the right panel when I am profiling on device, so I can not tract what is the exact reason for the garbage collection.

Hi brucezhu2018, it seems that we both cant track down the cause, mine also shows n/a when profiling on a device and the numbers are not massive in my screenshots but this is just for a sample scene and when i have 30 or so objects then this causes a massive spike. not good :(

So now the hunt still goes on.