phetsims / normal-modes

"Normal Modes" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 2 forks source link

CT: Assertion failed: recalculateVelocityAndAcceleration ... #56

Open pixelzoom opened 4 years ago

pixelzoom commented 4 years ago

Intermittent failure in CT (Continuous Testing):

normal-modes : fuzz : require.js : run
https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/normal-modes/normal-modes_en.html?postMessageOnLoad&postMessageOnError&postMessageOnBeforeUnload&brand=phet&ea&fuzz&memoryLimit=1000
Query: brand=phet&ea&fuzz&memoryLimit=1000
Uncaught Error: Assertion failed: bad result of recalculateVelocityAndAcceleration
Error: Assertion failed: bad result of recalculateVelocityAndAcceleration
    at window.assertions.assertFunction (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/assert/js/assert.js?bust=1585220009747:22:13)
    at OneDimensionModel.recalculateVelocityAndAcceleration (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/normal-modes/js/one-dimension/model/OneDimensionModel.js:342:13)
    at OneDimensionModel.setVerletPositions (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/normal-modes/js/one-dimension/model/OneDimensionModel.js:311:10)
    at OneDimensionModel.singleStep (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/normal-modes/js/one-dimension/model/OneDimensionModel.js:282:12)
    at OneDimensionModel.step (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/normal-modes/js/one-dimension/model/OneDimensionModel.js:262:14)
    at https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/joist/js/Sim.js:268:20
    at Action.execute (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/axon/js/Action.js:224:18)
    at Sim.stepSimulation (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/joist/js/Sim.js:921:31)
    at Sim.stepOneFrame (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/joist/js/Sim.js:911:12)
    at Sim.runAnimationLoop (https://bayes.colorado.edu/continuous-testing/snapshot-1585217674155/joist/js/Sim.js:894:12)
id: Bayes Chrome
Approximately 3/26/2020, 4:14:34 AM

Here's the assertion in OneDimensionModel.js:

assert( this.masses[ i ].velocityProperty.get().y === 0, 'bad result of recalculateVelocityAndAcceleration' );
pixelzoom commented 4 years ago

Still occurring intermittently as of 5/18/202.

Hyodar commented 4 years ago

Right, we'll take a look at it.

Hyodar commented 4 years ago

Well, I got some time to work on the sim again!

I have a pretty good idea of what may be happening: If the user grabs a mass and presses one of the arrow buttons to change the active AmplitudeDirection during the dragging process, the computed verlet positions (velocity and acceleration, too) directions will not match with the amplitudeDirectionProperty value. Thus, it will trigger the assert.

I don't think this would happen in a real situation, but it could be possible with the fuzz flag and some good hours of execution (I actually ran the sim here for a couple of hours and nothing happened).

@tmildemberger, do you think that makes any sense?

If this is really the issue, we should probably:

tmildemberger commented 4 years ago

Before 366a306 there was a method to swap x and y coordinates of the displacement and velocity of every mass when the amplitude direction changed. It was removed because I thought it wouldn't be possible to press the button to change the amplitude direction while dragging a mass.

But... I have just tested the sim for a while on my phone and this was not the only problem caused by forgetting about the existence of multitouch (I'll better investigate the other oddities I found out to be possible using more than one pointer and open the appropriate issues).

Maybe it's a good idea to bring this method back, as that will be enough to solve the failing of the assertion when dragging a mass while changing the amplitude direction using multitouch, but I'm still not sure if this will solve the intermittent failure detected in CT.

pixelzoom commented 4 years ago

Multitouch is always a little tricky. Using query parameterfuzzPointers might help you. It simulates multitouch while fuzzing. For example, running with ?ea&fuzz&fuzzPointers=2 will test the sim for mouse and touch events with 2 concurrent "pointers".

pixelzoom commented 2 years ago

This issue is a symptom of a more general problem, a lack of support for mulitouch, see https://github.com/phetsims/normal-modes/issues/80. In fact, the implementation assumes that there is no multitouch. E.g.draggingMassIndexProperty assumes there is only 1 mass that is draggable at a time (see the workaround applied in https://github.com/phetsims/normal-modes/issues/79 for the 1.0 prototpe).

That said... In the above commit, I added some additional info to the assertion messages. For example:

Uncaught Error: Assertion failed: recalculateVelocityAndAcceleration: N=3 i=2 velocity=Vector2(0.0014518150254393945, 0), expected non-zero y component

KatieWoe commented 2 years ago
normal-modes : multitouch-fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/normal-modes/normal-modes_en.html?continuousTest=%7B%22test%22%3A%5B%22normal-modes%22%2C%22multitouch-fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1647595636252%22%2C%22timestamp%22%3A1647598031817%7D&brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=false
Query: brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=false
Uncaught Error: Assertion failed: recalculateVelocityAndAcceleration: N=6 i=1 velocity=Vector2(-3.363756398051847, 0), expected non-zero y component
Error: Assertion failed: recalculateVelocityAndAcceleration: N=6 i=1 velocity=Vector2(-3.363756398051847, 0), expected non-zero y component
at window.assertions.assertFunction (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/assert/js/assert.js:25:13)
at OneDimensionModel.recalculateVelocityAndAcceleration (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:291:13)
at OneDimensionModel.setVerletPositions (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:257:10)
at OneDimensionModel.singleStep (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:230:12)
at OneDimensionModel.step (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:210:14)
at https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:254:22
at PhetioAction.execute (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/tandem/js/PhetioAction.js:90:17)
at Sim.stepSimulation (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:822:31)
at Sim.stepOneFrame (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:811:12)
at Sim.runAnimationLoop (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:789:12)
id: Bayes Chrome
Snapshot from 3/18/2022, 3:27:16 AM

----------------------------------

normal-modes : pan-and-zoom-fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/normal-modes/normal-modes_en.html?continuousTest=%7B%22test%22%3A%5B%22normal-modes%22%2C%22pan-and-zoom-fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1647595636252%22%2C%22timestamp%22%3A1647597662654%7D&brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=true
Query: brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=true
Uncaught Error: Assertion failed: recalculateVelocityAndAcceleration: N=10 i=1 velocity=Vector2(-0.5374822624290272, 0), expected non-zero y component
Error: Assertion failed: recalculateVelocityAndAcceleration: N=10 i=1 velocity=Vector2(-0.5374822624290272, 0), expected non-zero y component
at window.assertions.assertFunction (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/assert/js/assert.js:25:13)
at OneDimensionModel.recalculateVelocityAndAcceleration (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:291:13)
at OneDimensionModel.setVerletPositions (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:257:10)
at OneDimensionModel.singleStep (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:230:12)
at OneDimensionModel.step (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:210:14)
at https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:254:22
at PhetioAction.execute (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/tandem/js/PhetioAction.js:90:17)
at Sim.stepSimulation (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:822:31)
at Sim.stepOneFrame (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:811:12)
at Sim.runAnimationLoop (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:789:12)
id: Bayes Chrome
Snapshot from 3/18/2022, 3:27:16 AM

----------------------------------

normal-modes : pan-and-zoom-fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/normal-modes/normal-modes_en.html?continuousTest=%7B%22test%22%3A%5B%22normal-modes%22%2C%22pan-and-zoom-fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1647595636252%22%2C%22timestamp%22%3A1647613678472%7D&brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=true
Query: brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=true
Uncaught Error: Assertion failed: recalculateVelocityAndAcceleration: N=7 i=2 velocity=Vector2(0.21619212057443649, -0.04415930380800608), expected non-zero x component
Error: Assertion failed: recalculateVelocityAndAcceleration: N=7 i=2 velocity=Vector2(0.21619212057443649, -0.04415930380800608), expected non-zero x component
at window.assertions.assertFunction (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/assert/js/assert.js:25:13)
at OneDimensionModel.recalculateVelocityAndAcceleration (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:288:13)
at OneDimensionModel.setVerletPositions (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:257:10)
at OneDimensionModel.singleStep (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:230:12)
at OneDimensionModel.step (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/normal-modes/js/one-dimension/model/OneDimensionModel.js:210:14)
at https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:254:22
at PhetioAction.execute (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/tandem/js/PhetioAction.js:90:17)
at Sim.stepSimulation (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:822:31)
at Sim.stepOneFrame (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:811:12)
at Sim.runAnimationLoop (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/joist/js/Sim.js:789:12)
id: Bayes Chrome
Snapshot from 3/18/2022, 3:27:16 AM
pixelzoom commented 2 years ago

Latest stack trace:

normal-modes : fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1654864711113/normal-modes/normal-modes_en.html?continuousTest=%7B%22test%22%3A%5B%22normal-modes%22%2C%22fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1654864711113%22%2C%22timestamp%22%3A1654866068367%7D&brand=phet&ea&fuzz&memoryLimit=1000
Query: brand=phet&ea&fuzz&memoryLimit=1000
Uncaught Error: Assertion failed: recalculateVelocityAndAcceleration: N=3 i=1 velocity=Vector2(-0.0263046873121256, 0), expected non-zero y component
Error: Assertion failed: recalculateVelocityAndAcceleration: N=3 i=1 velocity=Vector2(-0.0263046873121256, 0), expected non-zero y component
at window.assertions.assertFunction (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1654864711113/assert/js/assert.js:28:13)
at assert (OneDimensionModel.js:308:12)
at recalculateVelocityAndAcceleration (OneDimensionModel.js:270:9)
at setVerletPositions (OneDimensionModel.js:241:11)
at singleStep (OneDimensionModel.js:221:13)
at step (Sim.ts:447:21)
at apply (PhetioAction.ts:124:16)
at execute (Sim.ts:990:30)
at stepSimulation (Sim.ts:980:11)
at stepOneFrame (Sim.ts:955:11)
id: Bayes Puppeteer
Snapshot from 6/10/2022, 6:38:31 AM
pixelzoom commented 2 years ago

It's likely to be a long time before this is fixed. It may be masking other problems, and it would be nice not to have to continually inspect in CT. So for now, I've commented out the failing assertion, and added a TODO that references this issue.

pixelzoom commented 2 years ago

In the above commit, I commented out a similar failing assertion for acceleration, marked with a TODO.

pixelzoom commented 2 years ago

In the above commit, I commented out the entire if ( assert ) {...} block, since all of its assertions are failing in CT.

KatieWoe commented 2 years ago

Can this be closed for https://github.com/phetsims/qa/issues/832?

pixelzoom commented 2 years ago

Please keep this open. The problem is still very much present. The reporting in CT has been silenced (by commenting out assertions) since there's no one to work on this.

marlitas commented 1 year ago

@pixelzoom, since the assertions have been silenced here can we add the label blocks-sim-publication and deferred to indicate we will not work on this until the sim is re-prioritized? Please remove the labels if you disagree.