-
Notifications
You must be signed in to change notification settings - Fork 8
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
detect Property loops #179
Comments
Seems like a good idea to me. I've accidentally set up property loops a number of times, and they often ended up locking up the browser tab due to recursion. The proposal above would have caught the problems earlier and more elegantly. |
This was talked about int he meeting today, but only briefly. I am wondering if we could have a property option that dictates whether or not you want to allow |
I think we should add |
So... Add this to options: // {boolean}
// true: reentrant calls to `set` fail an assertion
// false: reentrant calls to `set`are allowed
detectRentry: true Change assertion in assert && assert( !this.notifying || !options.detectRentry,
'reentry detected, value=' + this.get() + ', oldValue=' + oldValue ); ... and deal with assertion failures as they occur in CT (which is sure to be immediately). Objections? (EDIT: assertion message changed.) |
Sounds good to me, but I'd recommend a key name more like |
|
Unless someone else needs this feature for debugging, it might be advisable to defer until I return from vacation. EDIT by @samreid: devisable => advisable |
I have no urgent need for it at this time. |
It seems it would be good to have several developers "on hand" when we flip the switch for this, so responsible developers can catch their own |
Discussed at 6/21/18 - We will add #179 (comment) in a branch, then work on it when developers are available all at once. This will probably be done during core hours. We will do it in a branch so that CT continues to run and we can continue to work in common code in case this can't be fixed quickly. I will create a reminder to do this on July 9th since that is when devs will be back in town. |
On 7/9, @jessegreenberg reminded us about this issue on Slack. Unless someone else needs it, I would lobby for doing this work after EqEx is in RC, and after I return from vacation, so that I can address my sims. EqEx RC will start Wed 7/18 at the latest. I’ll be on vacation 7/19-8/5. |
More summarized discussion from slack: Since we will do this on a branch in axon, devs don't all need to be available to work on this at once. We will wait to work on this issue until priority goes up when it is required in Hooke's Law or somewhere else, and sometime after 8/5. |
I'm back to working on Hooke's Law PhET-iO, and could really use this to troubleshoot phetsims/hookes-law#52. So I'm going to resume work on this. |
Signed-off-by: Chris Malley <[email protected]>
Support for this pushed in the above commit. New option In the meantime, I'm going to explicitly set |
@zepumph has been randomly selected to review my work. |
That looks good to me. At first I was surprised that it would be an assertion rather than just a noop, but I think that is smart. Back to you. |
After using this to identify cycles (reentrant calls to Property |
Why not put the default as |
@samreid wrote:
I haven't confirmed, but I think this might create a lot of work.
The default is
Could do. Or a query parameter. I currently have a boolean |
I temporarily set Property.options.reentrant to default to false and ran a set of fuzz testing. I observed that the vast majority of property instances do not have a problem with reentrance. I saw 3 patterns for values that did have a problem with reentrance, here are examples of each of the three types:
Part of the documentation for Property.options.reentrant is:
I would like developers to be made aware of re-entrance during development, and for us to annotate all re-entrant Properties with Based on the results of this investigation, I'll commit my working copy changes, including changing Property's default to For future steps, it would be nice to (a) add code comments to each re-entrant Property indicating why they are re-entrant, or (b) implement it without re-entrance. I'll add a step to the code review document for that. |
As of 8/22/2018, 1:59:44pm, gravity-and-orbits is still failing with "Assertion failed: reentry detected" in CT. |
I pushed a fix for the gravity and orbits problem that occurred on Bayes CT. |
At today's meeting, we decided to create issues for the |
@samreid FYI, I believe that I've already created issues for all sims that I'm responsible for. E.g. phetsims/acid-base-solutions#155. |
Thanks @pixelzoom, I elevated priority to remind me to tackle the remainder sooner rather than later. |
I created issues for the remaining cases. @pixelzoom can this issue be closed? |
A Property loop occurs when a Property's
set
method is entered before a previous call toset
exits. PhET-iO makes it necessary to deal with these loops because it results in intermediate/redundant data in the message stream. See for example phetsims/hookes-law#52.PhetioObject previously was responsible for detecting Property loops, but that was removed in phetsims/tandem#57. And I believe it was @samreid who suggested that this responsibility does not belong in PhET-iO; it belongs in axon.
In phetsims/tandem#57 (comment), I suggested a way to add responsibility (conditionally) to Property, reproduced below. And I found this to be invaluable in troubleshooting phetsims/hookes-law#52. I'd like to see this added to Property.
The text was updated successfully, but these errors were encountered: