OnValueChange listeners are not unregistered when underlaying gameobjects are disabled

Issue #76 resolved
Jan D created an issue

During testing of our project, we have found out, that the onvaluechanged handler is called multiple times. Since we are still using v 1.0.9. we have prepared a simple change of Property.cs file to test it out in the latest 1.0.13 version (see the attachment)

Problem is, that deinit is basically almost never called, so when property does change, it gets handled multiple times at once.

How to test it out: 1. Replace your property.cs file with the attached one 2. Try to run for example synchronizers test scene 3. change characters multiple times (Property.ValueChanged [CharacterContext.cs:13.Property<Int32>] registering Slash.Unity.DataBind.Core.Data.ValueChangedDelegate) 4. Update property of the character

You should see when you update the property Size of invocation list 1 but instead you will see Size of invocation list X where X is up to 4.

  1. when you disable gameobject, which is called "root" and re-enable it, it does not help even thought, there is a code, that shoudl de-inicialize property bindings ondisable, it just is not working

Comments (7)

  1. Jan D reporter

    To turn tracking ON you have to define TRACE_EVENT_HANDLERS in the Project settings->scripting define symbols

  2. Jan D reporter

    Will do in a few hours and then i will let you know

    Dne ne 29. 4. 2018 13:56 uživatel Christian Oeing <

  3. Christian Oeing repo owner

    What kind of problems did occur for you on the visual side? As the issue is already in there for some versions, I'm not sure if it is that critical.

    The thing is that the data node fires a ValueChanged event as well and it will only listen to one node value observer. So at that place it's made sure that the ValueChanged event is not propagated multiple times.

    It's of course bad anyway that some event handlers remain active (and pile up over time), so thanks a lot for the report :) I'm just trying to decide if I have to release another version right away or if it's okay that the fix will be in the next release.

  4. Jan D reporter

    Looks like, that the fix is working.

    It is critical for us, because our project is based on enablig/disabling gameobjects with a bindingoperators/contextholders/etc on them, so it consumed much more resources than necesary.

    We are in the process of migrating 1.0.13 on our custom 1.0.9. hopefully, it will work or at least we will be able to isolate the problems so i can report them. You do not have to create a new release, because we can use this patch as well. cheers

  5. Christian Oeing repo owner

    Okay, great.

    In my projects I often keep the logic scripts, like getters, setters, etc. on separate game objects and enable/disable only the game objects which are responsible for viewing the object. But of course there should be no event handlers leaking anyway, hope that was the only place where something like that happened.

    If you encounter any other problems, let me know and I will look into it as soon as possible :)

  6. Log in to comment