Closed phet-steele closed 7 years ago
@phet-steele is the bug present in the last published version:
@phet-steele is the bug present in the last published version:
No, and I would imagine you would need to run with ?ea to see the issue. To clarify it it wasn't already known, this issue was found on master in require js.
I ran into this while taking a look at https://github.com/phetsims/forces-and-motion-basics/issues/220.
Dispose is registered to events in FlagNode with
model.once( 'reset-all', this.dispose.bind( this ) );
model.once( 'cart-returned', this.dispose.bind( this ) );
When one is triggered, the other isn't removed in dispose, so if you press "Return" and then "Reset All", and the flag will be disposed multiple times.
Also, dispose can be called in NetForceScreenView whenever the cart moves, and whenever the cart model stateProperty
changes.
Property.multilink( [ model.stateProperty, model.cart.xProperty ], function( state, x ) {
flagNode && flagNode.dispose();
if ( state === 'completed' && Math.abs( x ) > 1E-6 ) {
showFlagNode();
}
} );
After a winning state, "Reset All" and "Return" buttons (which already trigger dispose) are the only way to change these Properties, so I am not sure if this disposal is necessary.
I can no longer reproduce this issue, but want to wait for verification in the phet-io issue before closing.
I just got it again today:
SimIFrameAPI Invocation Error: Error: Assertion failed: Cannot register two different instances to the same id: forcesAndMotionBasics.netForceScreen.view.flagNode
at window.assertions.assertFunction (assert.js:21)
at Object.addInstance (phetio.js?bust=1498414858945:417)
at Object.addInstance (phetio.js?bust=1498414858945:57)
at Tandem.addInstance (Tandem.js?bust=1498414858945:127)
at FlagNode.setTandem (Node.js?bust=1498414858945:3481)
at FlagNode.set tandem [as tandem] (Node.js?bust=1498414858945:3486)
at Node.js?bust=1498414858945:4777
at u (lodash-4.17.4.min.js?bust=1498414858945:5)
at Function.ru (lodash-4.17.4.min.js?bust=1498414858945:67)
at FlagNode.mutate (Node.js?bust=1498414858945:4764)
I can get this problem by running instance proxies and winning tug of war once:
Cannot register two different instances to the same id:
forcesAndMotionBasics.netForceScreen.view.flagNode
Proposed fix is above, and testing in instance proxies seems OK (no more "cannot register two") errors that I can see, and the flag still seems to be displayed when it should be. @jessegreenberg can you please review and test?
The above looks great @samreid, I tested in PhET brand and the instance proxies wrapper, its working great. Closing.
From the checks in phetsims/scenery/issues/601:
To reproduce:
@samreid @kathy-phet note that this severely affects the classroom activity wrapper for this sim (should go without saying).