Skip to content
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

Listener order should be scrambled on fuzz #215

Closed
zepumph opened this issue Jan 31, 2019 · 77 comments
Closed

Listener order should be scrambled on fuzz #215

zepumph opened this issue Jan 31, 2019 · 77 comments

Comments

@zepumph
Copy link
Member

zepumph commented Jan 31, 2019

Today in phet-io/dev meeting we decided that axon listener order should not be guaranteed. One nice way that someone thought up (sorry I forgot who) to test this would be to shuffle the order of listeners while fuzzing.

@zepumph
Copy link
Member Author

zepumph commented Jan 31, 2019

see phetsims/scenery#928

@zepumph
Copy link
Member Author

zepumph commented Jun 27, 2019

Discussed in today's dev meeting. It was mentioned that though it is a bit of a code smell to have listener order matter. For example if you create an emitter and immediately add a listener to it such that that listener would HAVE to be before any others added. That said @jonathanolson thought that this didn't necessarily warrant a large investigation into an automatic fix for this.

@samreid
Copy link
Member

samreid commented Oct 15, 2019

It seems inappropriate to combine listener order scrambling with input fuzzing. Let's introduce a separate query parameter ?shuffleListeners for randomizing listener order. We can also add it to the code review checklist and optionally open issues for sims that have trouble with that at the moment. After we get many sims working with shuffled listener order, we can considering having CT run with both.

@samreid
Copy link
Member

samreid commented Oct 15, 2019

I shuffled listener order in TinyEmitter, which powers Emitter and Property (though not yet ObservableArray, see #270 ) via this patch:

Index: js/TinyEmitter.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/TinyEmitter.js	(revision 89d19e65ac30c9d39bc56f1d92b89ca5afe35c86)
+++ js/TinyEmitter.js	(date 1571116506547)
@@ -49,6 +49,8 @@
     emit() {
       assert && assert( !this.isDisposed, 'should not be called if disposed' );
 
+      this.listeners = _.shuffle( this.listeners );
+
       // Notify wired-up listeners, if any
       if ( this.listeners.length > 0 ) {
         this.activeListenersStack.push( this.listeners );

I ran local aqua fuzz on phet brand and saw errors for the following sims:

  • acid-base-solutions
  • area-builder
  • build-a-fraction
  • build-a-molecule
  • circuit-construction-kit-black-box-study
  • curve-fitting
  • diffusion
  • fraction-matcher
  • fractions-equality
  • fractions-intro
  • fractions-mixed-numbers
  • gas-properties
  • gases-intro
  • gravity-force-lab
  • molarity
  • states-of-matter
  • waves-intro

Note: some of these errors were pre-existing and unrelated to the listener order.

Sim errors (dev):
acid-base-solutions
Uncaught Error: Assertion failed: reentry detected, value=0.01, oldValue=0.009999999999999998
Error: Assertion failed: reentry detected, value=0.01, oldValue=0.009999999999999998
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116515663:22:13)
    at NumberProperty._notifyListeners (http://localhost/axon/js/Property.js?bust=1571116515818:261:17)
    at NumberProperty.set (http://localhost/axon/js/Property.js?bust=1571116515818:175:16)
    at NumberProperty.set (http://localhost/axon/js/NumberProperty.js?bust=1571116515818:98:13)
    at http://localhost/acid-base-solutions/js/mysolution/model/MySolutionModel.js?bust=1571116515818:82:79
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116515818:61:55)
    at NumberProperty._notifyListeners (http://localhost/axon/js/Property.js?bust=1571116515818:264:27)
    at NumberProperty.set (http://localhost/axon/js/Property.js?bust=1571116515818:175:16)
    at NumberProperty.set (http://localhost/axon/js/NumberProperty.js?bust=1571116515818:98:13)
    at http://localhost/acid-base-solutions/js/mysolution/view/ConcentrationSlider.js?bust=1571116515818:77:34
area-builder
Uncaught Error: Assertion failed: Error: Shapes should not become residents until they have completed animating.
Error: Assertion failed: Error: Shapes should not become residents until they have completed animating.
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116521383:22:13)
    at ShapePlacementBoard.addResidentShape (http://localhost/area-builder/js/common/model/ShapePlacementBoard.js?bust=1571116521454:254:17)
    at animationCompleteListener (http://localhost/area-builder/js/common/model/ShapePlacementBoard.js?bust=1571116521454:318:16)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116521454:61:55)
    at Property._notifyListeners (http://localhost/axon/js/Property.js?bust=1571116521454:264:27)
    at Property.set (http://localhost/axon/js/Property.js?bust=1571116521454:175:16)
    at MovableShape.step (http://localhost/area-builder/js/common/model/MovableShape.js?bust=1571116521454:93:34)
    at http://localhost/area-builder/js/explore/model/AreaBuilderExploreModel.js?bust=1571116521454:104:75
    at Array.forEach ()
    at ObservableArray.forEach (http://localhost/axon/js/ObservableArray.js?bust=1571116521454:300:27)
build-a-fraction
Uncaught Error: Assertion failed: Attempted to removeChild with a node that was not a child.
Error: Assertion failed: Attempted to removeChild with a node that was not a child.
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116655649:22:13)
    at TransitionNode.removeChild (http://localhost/scenery/js/nodes/Node.js?bust=1571116656363:644:17)
    at http://localhost/twixt/js/TransitionNode.js?bust=1571116656363:301:18
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116656363:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116656363:35:31
    at Emitter.execute (http://localhost/axon/js/Action.js?bust=1571116656363:229:20)
    at Emitter.emit (http://localhost/axon/js/Emitter.js?bust=1571116656363:60:21)
    at Transition.step (http://localhost/twixt/js/Animation.js?bust=1571116656363:326:27)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116656363:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116656363:35:31
build-a-molecule
Uncaught TypeError: Cannot read property 'hasConnection' of undefined
TypeError: Cannot read property 'hasConnection' of undefined
    at http://localhost/build-a-molecule/js/model/LewisDotModel.js?bust=1571116661540:33:22
    at Array.forEach ()
    at LewisDotModel.breakBondsOfAtom (http://localhost/build-a-molecule/js/model/LewisDotModel.js?bust=1571116661540:32:24)
    at Kit.recycleAtomIntoBuckets (http://localhost/build-a-molecule/js/model/Kit.js?bust=1571116661540:368:26)
    at http://localhost/build-a-molecule/js/model/Kit.js?bust=1571116661540:385:14
    at Array.forEach ()
    at Kit.recycleMoleculeIntoBuckets (http://localhost/build-a-molecule/js/model/Kit.js?bust=1571116661540:384:22)
    at Kit.atomDropped (http://localhost/build-a-molecule/js/model/Kit.js?bust=1571116661540:192:14)
    at DragListener.end [as _end] (http://localhost/build-a-molecule/js/view/BAMView.js?bust=1571116661540:222:24)
    at http://localhost/scenery/js/listeners/DragListener.js?bust=1571116661540:283:27
circuit-construction-kit-black-box-study
Uncaught Error: Assertion failed: Vertex wasn't in the model
Error: Assertion failed: Vertex wasn't in the model
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116747766:22:13)
    at Circuit.searchVertices (http://localhost/circuit-construction-kit-common/js/model/Circuit.js?bust=1571116747846:909:17)
    at Circuit.findAllConnectedVertices (http://localhost/circuit-construction-kit-common/js/model/Circuit.js?bust=1571116747846:897:19)
    at Circuit.markAllConnectedCircuitElementsDirty (http://localhost/circuit-construction-kit-common/js/model/Circuit.js?bust=1571116747846:877:41)
    at updateCharges (http://localhost/circuit-construction-kit-common/js/model/Circuit.js?bust=1571116747846:123:42)
    at NumberProperty.link (http://localhost/axon/js/Property.js?bust=1571116747846:345:7)
    at Array. (http://localhost/circuit-construction-kit-common/js/model/Circuit.js?bust=1571116747846:127:41)
    at ObservableArray._fireItemAdded (http://localhost/axon/js/ObservableArray.js?bust=1571116747846:136:18)
    at ObservableArray.push (http://localhost/axon/js/ObservableArray.js?bust=1571116747846:221:12)
    at addWireStubs (http://localhost/circuit-construction-kit-black-box-study/js/blackbox/model/BlackBoxSceneModel.js?bust=1571116747846:111:37)
curve-fitting
Uncaught Error: Assertion failed: Not enough coefficients for each term in the equation.
Error: Assertion failed: Not enough coefficients for each term in the equation.
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116810341:22:13)
    at EquationNode.setCoefficients (http://localhost/curve-fitting/js/curve-fitting/view/EquationNode.js?bust=1571116810496:159:17)
    at updateContent (http://localhost/curve-fitting/js/curve-fitting/view/EquationAccordionBox.js?bust=1571116810496:137:22)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116810496:61:55)
    at NumberProperty._notifyListeners (http://localhost/axon/js/Property.js?bust=1571116810496:264:27)
    at NumberProperty.set (http://localhost/axon/js/Property.js?bust=1571116810496:175:16)
    at NumberProperty.set (http://localhost/axon/js/NumberProperty.js?bust=1571116810496:98:13)
    at fire (http://localhost/sun/js/AquaRadioButton.js?bust=1571116810496:116:16)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116810496:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116810496:35:31
diffusion
Uncaught Error: Assertion failed: particles2 has not been populated yet
Error: Assertion failed: particles2 has not been populated yet
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116822335:22:13)
    at DiffusionModel.numberOfParticlesProperty.DerivedProperty.numberType (http://localhost/gas-properties/js/diffusion/model/DiffusionModel.js?bust=1571116822416:107:21)
    at listener (http://localhost/axon/js/DerivedProperty.js?bust=1571116822416:65:35)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116822416:61:55)
    at NumberProperty._notifyListeners (http://localhost/axon/js/Property.js?bust=1571116822416:264:27)
    at NumberProperty.set (http://localhost/axon/js/Property.js?bust=1571116822416:175:16)
    at NumberProperty.set (http://localhost/axon/js/NumberProperty.js?bust=1571116822416:98:13)
    at incrementFunction (http://localhost/sun/js/NumberSpinner.js?bust=1571116822416:140:22)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116822416:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116822416:35:31
fraction-matcher
Uncaught Error: Assertion failed: Attempted to removeChild with a node that was not a child.
Error: Assertion failed: Attempted to removeChild with a node that was not a child.
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116954367:22:13)
    at TransitionNode.removeChild (http://localhost/scenery/js/nodes/Node.js?bust=1571116954442:644:17)
    at http://localhost/twixt/js/TransitionNode.js?bust=1571116954442:301:18
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116954442:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116954442:35:31
    at Emitter.execute (http://localhost/axon/js/Action.js?bust=1571116954442:229:20)
    at Emitter.emit (http://localhost/axon/js/Emitter.js?bust=1571116954442:60:21)
    at Transition.step (http://localhost/twixt/js/Animation.js?bust=1571116954442:326:27)
    at TransitionNode.step (http://localhost/twixt/js/TransitionNode.js?bust=1571116954442:102:42)
    at MatchingGameScreenView.step (http://localhost/fractions-common/js/matching/view/MatchingGameScreenView.js?bust=1571116954442:260:27)
fractions-equality
Uncaught Error: Assertion failed: Attempted to removeChild with a node that was not a child.
Error: Assertion failed: Attempted to removeChild with a node that was not a child.
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116958163:22:13)
    at TransitionNode.removeChild (http://localhost/scenery/js/nodes/Node.js?bust=1571116958243:644:17)
    at http://localhost/twixt/js/TransitionNode.js?bust=1571116958243:301:18
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116958243:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116958243:35:31
    at Emitter.execute (http://localhost/axon/js/Action.js?bust=1571116958243:229:20)
    at Emitter.emit (http://localhost/axon/js/Emitter.js?bust=1571116958243:60:21)
    at Transition.step (http://localhost/twixt/js/Animation.js?bust=1571116958243:326:27)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116958243:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116958243:35:31
fractions-intro
Uncaught Error: Assertion failed: Attempted to removeChild with a node that was not a child.
Error: Assertion failed: Attempted to removeChild with a node that was not a child.
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116966634:22:13)
    at TransitionNode.removeChild (http://localhost/scenery/js/nodes/Node.js?bust=1571116966711:644:17)
    at http://localhost/twixt/js/TransitionNode.js?bust=1571116966711:301:18
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116966711:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116966711:35:31
    at Emitter.execute (http://localhost/axon/js/Action.js?bust=1571116966711:229:20)
    at Emitter.emit (http://localhost/axon/js/Emitter.js?bust=1571116966711:60:21)
    at Transition.step (http://localhost/twixt/js/Animation.js?bust=1571116966711:326:27)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116966711:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116966711:35:31
fractions-mixed-numbers
Uncaught Error: Assertion failed: Attempted to removeChild with a node that was not a child.
Error: Assertion failed: Attempted to removeChild with a node that was not a child.
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571116973427:22:13)
    at TransitionNode.removeChild (http://localhost/scenery/js/nodes/Node.js?bust=1571116973520:644:17)
    at http://localhost/twixt/js/TransitionNode.js?bust=1571116973520:301:18
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571116973520:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571116973520:35:31
    at Emitter.execute (http://localhost/axon/js/Action.js?bust=1571116973520:229:20)
    at Emitter.emit (http://localhost/axon/js/Emitter.js?bust=1571116973520:60:21)
    at Transition.step (http://localhost/twixt/js/Animation.js?bust=1571116973520:326:27)
    at TransitionNode.step (http://localhost/twixt/js/TransitionNode.js?bust=1571116973520:102:42)
    at BuildingGameScreenView.step (http://localhost/fractions-common/js/game/view/BuildingGameScreenView.js?bust=1571116973520:386:33)
gas-properties
Uncaught Error: Assertion failed: heavyParticles has not been populated yet
Error: Assertion failed: heavyParticles has not been populated yet
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571117013195:22:13)
    at http://localhost/gas-properties/js/common/model/ParticleSystem.js?bust=1571117013283:109:21
    at listener (http://localhost/axon/js/DerivedProperty.js?bust=1571117013283:65:35)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571117013283:61:55)
    at NumberProperty._notifyListeners (http://localhost/axon/js/Property.js?bust=1571117013283:264:27)
    at NumberProperty.set (http://localhost/axon/js/Property.js?bust=1571117013283:175:16)
    at NumberProperty.set (http://localhost/axon/js/NumberProperty.js?bust=1571117013283:98:13)
    at NumberProperty.set value [as value] (http://localhost/axon/js/Property.js?bust=1571117013283:334:34)
    at HandleDragListener.drag [as _dragListener] (http://localhost/scenery-phet/js/BicyclePumpNode.js?bust=1571117013283:673:34)
    at HandleDragListener.drag (http://localhost/scenery/js/listeners/PressListener.js?bust=1571117013283:401:12)
gas-properties
Uncaught Error: Assertion failed: reentry detected, value=64, oldValue=25
Error: Assertion failed: reentry detected, value=64, oldValue=25
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571117013195:22:13)
    at NumberProperty._notifyListeners (http://localhost/axon/js/Property.js?bust=1571117013283:261:17)
    at NumberProperty.set (http://localhost/axon/js/Property.js?bust=1571117013283:175:16)
    at NumberProperty.set (http://localhost/axon/js/NumberProperty.js?bust=1571117013283:98:13)
    at NumberProperty.set value [as value] (http://localhost/axon/js/Property.js?bust=1571117013283:334:34)
    at HandleDragListener.drag [as _dragListener] (http://localhost/scenery-phet/js/BicyclePumpNode.js?bust=1571117013283:673:34)
    at HandleDragListener.drag (http://localhost/scenery/js/listeners/PressListener.js?bust=1571117013283:401:12)
    at DragListener._dragAction.Action.parameters.name (http://localhost/scenery/js/listeners/DragListener.js?bust=1571117013283:194:36)
    at Action.execute (http://localhost/axon/js/Action.js?bust=1571117013283:229:20)
    at HandleDragListener.drag (http://localhost/scenery/js/listeners/DragListener.js?bust=1571117013283:308:24)
gases-intro
Uncaught Error: Assertion failed: lightParticles not been populated yet
Error: Assertion failed: lightParticles not been populated yet
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571117020194:22:13)
    at http://localhost/gas-properties/js/common/model/ParticleSystem.js?bust=1571117020270:111:21
    at listener (http://localhost/axon/js/DerivedProperty.js?bust=1571117020270:65:35)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571117020270:61:55)
    at NumberProperty._notifyListeners (http://localhost/axon/js/Property.js?bust=1571117020270:264:27)
    at NumberProperty.set (http://localhost/axon/js/Property.js?bust=1571117020270:175:16)
    at NumberProperty.set (http://localhost/axon/js/NumberProperty.js?bust=1571117020270:98:13)
    at NumberProperty.set value [as value] (http://localhost/axon/js/Property.js?bust=1571117020270:334:34)
    at HandleDragListener.drag [as _dragListener] (http://localhost/scenery-phet/js/BicyclePumpNode.js?bust=1571117020270:673:34)
    at HandleDragListener.drag (http://localhost/scenery/js/listeners/PressListener.js?bust=1571117020270:401:12)
gravity-force-lab
Uncaught Error: Assertion failed: max must be >= min. min: 7.241840277777778e-11, max: 0
Error: Assertion failed: max must be >= min. min: 7.241840277777778e-11, max: 0
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571117074581:22:13)
    at new Range (http://localhost/dot/js/Range.js?bust=1571117074746:22:15)
    at new ISLCObjectNode (http://localhost/inverse-square-law-common/js/view/ISLCObjectNode.js?bust=1571117074746:140:29)
    at new MassNode (http://localhost/gravity-force-lab/js/gravity-force-lab/view/MassNode.js?bust=1571117074746:64:7)
    at new GravityForceLabScreenView (http://localhost/gravity-force-lab/js/gravity-force-lab/view/GravityForceLabScreenView.js?bust=1571117074746:92:23)
    at Screen.backgroundColorProperty [as createView] (http://localhost/gravity-force-lab/js/gravity-force-lab-main.js?bust=1571117074746:51:18)
    at Screen.initializeView (http://localhost/joist/js/Screen.js?bust=1571117074746:260:25)
    at Array. (http://localhost/joist/js/Sim.js?bust=1571117074746:830:18)
    at http://localhost/joist/js/Sim.js?bust=1571117074746:838:27
molarity
Uncaught Error: distance must be between 0 and 1: 1.0253333333333332
Error: distance must be between 0 and 1: 1.0253333333333332
    at Function.Color.interpolateRGBA (http://localhost/scenery/js/util/Color.js?bust=1571117197590:714:13)
    at Solution.getColor (http://localhost/molarity/js/molarity/model/Solution.js?bust=1571117197590:101:22)
    at update (http://localhost/molarity/js/molarity/view/ConcentrationDisplay.js?bust=1571117197590:200:38)
    at http://localhost/molarity/js/molarity/view/ConcentrationDisplay.js?bust=1571117197590:211:7
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571117197590:61:55)
    at Property._notifyListeners (http://localhost/axon/js/Property.js?bust=1571117197590:264:27)
    at Property.set (http://localhost/axon/js/Property.js?bust=1571117197590:175:16)
    at Property.set value [as value] (http://localhost/axon/js/Property.js?bust=1571117197590:334:34)
    at ComboBoxListBox.Action.parameters.phetioPrivate (http://localhost/sun/js/ComboBoxListBox.js?bust=1571117197590:73:24)
    at Action.execute (http://localhost/axon/js/Action.js?bust=1571117197590:229:20)
states-of-matter
Uncaught Error: Assertion failed: Setting epsilon is not implemented for this class
Error: Assertion failed: Setting epsilon is not implemented for this class
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571117420565:22:13)
    at DiatomicVerletAlgorithm.setScaledEpsilon (http://localhost/states-of-matter/js/common/model/engine/AbstractVerletAlgorithm.js?bust=1571117420642:235:17)
    at MultipleParticleModel.setEpsilon (http://localhost/states-of-matter/js/common/model/MultipleParticleModel.js?bust=1571117420642:1168:47)
    at http://localhost/states-of-matter/js/phase-changes/view/EpsilonControlInteractionPotentialDiagram.js?bust=1571117420642:188:33
    at listener (http://localhost/axon/js/Multilink.js?bust=1571117420642:41:20)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571117420642:61:55)
    at Property._notifyListeners (http://localhost/axon/js/Property.js?bust=1571117420642:264:27)
    at Property.set (http://localhost/axon/js/Property.js?bust=1571117420642:175:16)
    at http://localhost/sun/js/buttons/RadioButtonGroupMember.js?bust=1571117420642:126:16
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571117420642:61:55)
states-of-matter
Uncaught Error: Assertion failed: reentry detected, value=NEON, oldValue=ADJUSTABLE_ATOM
Error: Assertion failed: reentry detected, value=NEON, oldValue=ADJUSTABLE_ATOM
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571117420565:22:13)
    at Property._notifyListeners (http://localhost/axon/js/Property.js?bust=1571117420642:261:17)
    at Property.set (http://localhost/axon/js/Property.js?bust=1571117420642:175:16)
    at Property.reset (http://localhost/axon/js/Property.js?bust=1571117420642:327:12)
    at MultipleParticleModel.reset (http://localhost/states-of-matter/js/common/model/MultipleParticleModel.js?bust=1571117420642:534:30)
    at listener (http://localhost/states-of-matter/js/phase-changes/view/PhaseChangesScreenView.js?bust=1571117420642:121:31)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571117420642:61:55)
    at http://localhost/axon/js/Emitter.js?bust=1571117420642:35:31
    at Emitter.execute (http://localhost/axon/js/Action.js?bust=1571117420642:229:20)
    at Emitter.emit (http://localhost/axon/js/Emitter.js?bust=1571117420642:60:21)
waves-intro
Uncaught Error: Assertion failed: matrix should not map plane to a line or point
Error: Assertion failed: matrix should not map plane to a line or point
    at window.assertions.assertFunction (http://localhost/assert/js/assert.js?bust=1571117553843:22:13)
    at HBox.setMatrix (http://localhost/scenery/js/nodes/Node.js?bust=1571117554051:2336:17)
    at Perspective3DNode.update (http://localhost/wave-interference/js/common/view/Perspective3DNode.js?bust=1571117554051:138:21)
    at TinyEmitter.emit (http://localhost/axon/js/TinyEmitter.js?bust=1571117554051:61:55)
    at NumberProperty._notifyListeners (http://localhost/axon/js/Property.js?bust=1571117554051:264:27)
    at NumberProperty.set (http://localhost/axon/js/Property.js?bust=1571117554051:175:16)
    at NumberProperty.set (http://localhost/axon/js/NumberProperty.js?bust=1571117554051:98:13)
    at NumberProperty.reset (http://localhost/axon/js/Property.js?bust=1571117554051:327:12)
    at WavesModel.reset (http://localhost/wave-interference/js/waves/model/WavesModel.js?bust=1571117554051:408:35)
    at listener (http://localhost/wave-interference/js/waves/view/WavesScreenView.js?bust=1571117554051:156:31)

@samreid
Copy link
Member

samreid commented Oct 15, 2019

The above commit adds ?shuffleListeners query parameter flag.

The behavior is also buried behind assert so it will be stripped from production build and won't impact production performance at all. There was some other issue about not leveraging assert to strip things from builds but I can't find it at the moment.

I also added a note to the CRC for checking runtime behavior with this flag enabled. @zepumph would you like to take a look before we run this past @pixelzoom or a dev team meeting?

@samreid samreid removed their assignment Oct 15, 2019
@samreid
Copy link
Member

samreid commented Oct 15, 2019

Also, is there a QA checklist where this would be documented as well?

@zepumph
Copy link
Member Author

zepumph commented Oct 15, 2019

My guess is that the above is only a piece of the errors that this may have caused. Though it is a code smell, I could foresee a case in which creating a Property and immediately linking to it feels so linked, that assertions aren't created making sure that that listener's logic happened before other logic, but it would still change something in the sim.

@samreid
Copy link
Member

samreid commented Oct 15, 2019

I agree, we would need to manually test simulation behavior to see how the listener order impacts it. I would expect some but not all of it to be caught in automated testing.

@zepumph
Copy link
Member Author

zepumph commented Oct 15, 2019

I really like this query parameter, and I think it is a step in the right direction. When creating this issue, it was clear that it is definitely PREFERRED to have all of these errors fixed. That said, I'm not sure what the priority of it would be. For example, in gravity force lab (having just worked on it and encountered this listener dependency order before), it is not an obvious fix, and may need serious model refactoring to resolve.

@zepumph
Copy link
Member Author

zepumph commented Oct 15, 2019

I also really like its role in the CRC. That will help this issue not proliferate.

@zepumph
Copy link
Member Author

zepumph commented Oct 15, 2019

Perhaps it would be good to try to fix one or two before passing this off to another for further discussion. That would inform our next steps here.

For example, if all of these issues were <10 mintues each, we would likely try to fix them up front. Perhaps a dev meeting chip away issue is needed. That said this really feels like an order of magnitude more costly than we will want to investigate.

We will know more after doing a few conversions.

@zepumph zepumph assigned samreid and unassigned zepumph Oct 15, 2019
samreid added a commit to phetsims/wave-interference that referenced this issue Oct 15, 2019
@samreid
Copy link
Member

samreid commented Oct 15, 2019

I fixed the waves-intro fuzz problem in the preceding commit. It took around 10 minutes. This seemed to be a good use of time, because it wasn't evident why that bug wasn't being triggered in the first place. So this fix seems to have made the code more tolerant and refactor-proof. I made a cursory look through the rest of the sim and didn't see other errors. I don't expect all problems will be this easy to solve, this is probably a best case scenario.

Assigning back to @zepumph but also flagging for dev meeting because it will likely be ready for discussion by then.

@jonathanolson
Copy link
Contributor

Also I can use this with snapshot comparison, which is already good at determining whether sims are purely deterministic based on the seed. We can also verify that changing listener order results in no visual differences in sims.

@zepumph
Copy link
Member Author

zepumph commented Oct 15, 2019

That sounds excellent.

@pixelzoom
Copy link
Contributor

pixelzoom commented Mar 31, 2023

.. Instead, for reproducible error behavior, I would recommend using reverseListeners without fuzzing.
@pixelzoom does that sound reasonable?

For CT, yes, it's better than what we're doing now. Just keep in mind that this will verify that the sim works with 2 specific listener orders, not that there are no dependencies on listener order.

So I think there's still a need for ?shuffleListeners with a seed, for developer use. With value "random" to choose a random seed that is printed to the console. Here's the use case:

  1. Fuzz your sim many times with ?shuffleListeners=random.
  2. If a problem is identified, note the seed that was printed to the console, then run with ?shuffleListeners={seed} to reproduce, diagnose, and address the problem.

This is still not guaranteed to identify all order dependencies, but it's lightyears better than only testing that the listener order works in reverse.

@samreid
Copy link
Member

samreid commented Apr 3, 2023

@marlitas and I made good progress, summarizing changes and next steps:

  • The query parameter key was changed to ?listenerOrder and you can specify values like random (chooses a seed for you), random(123) (specify a seed) or reverse.
  • Phetmarks has a shortcut checkbox for ?listenerOrder=random. If you need the other ways, you will need to type it in manually

@samreid will:

  • Run a few basic tests for the query parameters with a controlled TinyEmitter with a few listeners.
  • Request review from @pixelzoom

@zepumph
Copy link
Member Author

zepumph commented Apr 4, 2023

Null checking above for failing CT when we don't have chipper.queryParameters (scenery doc/playgrounds/etc)

samreid added a commit that referenced this issue Apr 5, 2023
@samreid
Copy link
Member

samreid commented Apr 5, 2023

OK I added a test harness to manually check the behavior with ?listenerOrder=reverse, ?listenerOrder=random and ?listenerOrder=random(123), and to automatically check the behavior with the default order.

@pixelzoom would you like to review this issue? Particularly the changes described in #215 (comment)

@samreid samreid assigned pixelzoom and unassigned samreid Apr 5, 2023
@pixelzoom pixelzoom assigned samreid and unassigned pixelzoom Apr 20, 2023
@pixelzoom
Copy link
Contributor

Looks good. But the info you put in #215 (comment) (description of the values) belongs in the documentation for listenerOrder in initialize-globals.js. A link to this issue is useful for someone who wants to see design history, but it's very inconvenient (as I found while reviewing) for understanding the values and how to use listenerOrder.

samreid added a commit to phetsims/chipper that referenced this issue Apr 20, 2023
@samreid
Copy link
Member

samreid commented Apr 20, 2023

I updated the JSDoc, ready for review.

@pixelzoom
Copy link
Contributor

👍🏻 JSdoc looks good.

@pixelzoom pixelzoom assigned samreid and unassigned pixelzoom Apr 24, 2023
@samreid
Copy link
Member

samreid commented Apr 24, 2023

Thanks, it seems this issue is ready to close.

@samreid samreid closed this as completed Apr 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants