phetsims / build-a-molecule

"Build a Molecule" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
8 stars 7 forks source link

CT Bond not found #221

Closed KatieWoe closed 8 months ago

KatieWoe commented 3 years ago
build-a-molecule : multitouch-fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/build-a-molecule_en.html?continuousTest=%7B%22test%22%3A%5B%22build-a-molecule%22%2C%22multitouch-fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1612502607679%22%2C%22timestamp%22%3A1612515516379%7D&brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000
Query: brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000
Uncaught Error: Bond not found
Error: Bond not found
at LewisDotModel.getBondDirection (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/model/LewisDotModel.js:116:11)
at Kit.getBondDirection (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/model/Kit.js:340:31)
at new MoleculeBondNode (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/MoleculeBondNode.js:68:31)
at https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/MoleculeBondContainerNode.js:24:14
at Array.map (<anonymous>)
at new MoleculeBondContainerNode (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/MoleculeBondContainerNode.js:23:37)
at KitPlayAreaNode.addMoleculeBondNodes (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/KitPlayAreaNode.js:90:39)
at addedMoleculeListener (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/BAMScreenView.js:165:30)
at addedEmitterListener (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/BAMScreenView.js:233:11)
at TinyEmitter.emit (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/axon/js/TinyEmitter.js:71:18)
id: Bayes Chrome
Snapshot from 2/4/2021, 10:23:27 PM

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

build-a-molecule : multitouch-fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/build-a-molecule_en.html?continuousTest=%7B%22test%22%3A%5B%22build-a-molecule%22%2C%22multitouch-fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1612502607679%22%2C%22timestamp%22%3A1612533043466%7D&brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000
Query: brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000
Uncaught Error: Bond not found
Error: Bond not found
at LewisDotModel.getBondDirection (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/model/LewisDotModel.js:116:11)
at Kit.getBondDirection (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/model/Kit.js:340:31)
at new MoleculeBondNode (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/MoleculeBondNode.js:68:31)
at https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/MoleculeBondContainerNode.js:24:14
at Array.map (<anonymous>)
at new MoleculeBondContainerNode (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/MoleculeBondContainerNode.js:23:37)
at KitPlayAreaNode.addMoleculeBondNodes (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/KitPlayAreaNode.js:90:39)
at addedMoleculeListener (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/BAMScreenView.js:165:30)
at addedEmitterListener (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/build-a-molecule/js/common/view/BAMScreenView.js:233:11)
at TinyEmitter.emit (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1612502607679/axon/js/TinyEmitter.js:71:18)
id: Bayes Chrome
Snapshot from 2/4/2021, 10:23:27 PM
pixelzoom commented 3 years ago

In 2/4/21 dev meeting, we established that this may be due to CT multi-touch fuzz testing ( ?fuzzPointers=2) being enabled for phetsims/aqua#106.

KatieWoe commented 2 years ago
build-a-molecule : multitouch-fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/build-a-molecule/build-a-molecule_en.html?continuousTest=%7B%22test%22%3A%5B%22build-a-molecule%22%2C%22multitouch-fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1647595636252%22%2C%22timestamp%22%3A1647597604016%7D&brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=false
Query: brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=false
Uncaught Error: Bond not found
Error: Bond not found
at LewisDotModel.getBondDirection (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/LewisDotModel.js:122:11)
at Kit.getBondDirection (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/Kit.js:329:31)
at new MoleculeBondNode (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/view/MoleculeBondNode.js:62:31)
at https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/view/MoleculeBondContainerNode.js:22:14
at Array.map (<anonymous>)
at new MoleculeBondContainerNode (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/view/MoleculeBondContainerNode.js:21:37)
at KitPlayAreaNode.addMoleculeBondNodes (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/view/KitPlayAreaNode.js:77:39)
at addedMoleculeListener (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/view/BAMScreenView.js:148:30)
at addedEmitterListener (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/view/BAMScreenView.js:217:11)
at TinyEmitter.emit (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/axon/js/TinyEmitter.js:68:9)
id: Bayes Chrome
Snapshot from 3/18/2022, 3:27:16 AM

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

build-a-molecule : pan-and-zoom-fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/build-a-molecule/build-a-molecule_en.html?continuousTest=%7B%22test%22%3A%5B%22build-a-molecule%22%2C%22pan-and-zoom-fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1647595636252%22%2C%22timestamp%22%3A1647598695412%7D&brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=true
Query: brand=phet&ea&fuzz&fuzzPointers=2&memoryLimit=1000&supportsPanAndZoom=true
Uncaught TypeError: Cannot read properties of null (reading 'atoms')
TypeError: Cannot read properties of null (reading 'atoms')
at Function.getCombinedMoleculeFromBond (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/MoleculeStructure.js:546:10)
at Kit.getPossibleMoleculeStructureFromBond (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/Kit.js:578:30)
at Kit.canBond (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/Kit.js:667:88)
at https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/Kit.js:606:46
at Array.forEach (<anonymous>)
at https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/Kit.js:597:18
at Array.forEach (<anonymous>)
at Kit.attemptToBondMolecule (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/Kit.js:595:20)
at Kit.atomDropped (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/model/Kit.js:206:14)
at DragListener.end [as _end] (https://bayes.colorado.edu/continuous-testing/ct-snapshots/1647595636252/chipper/dist/js/build-a-molecule/js/common/view/BAMScreenView.js:410:20)
id: Bayes Chrome
Snapshot from 3/18/2022, 3:27:16 AM
jbphet commented 9 months ago

I have a way to duplicate this manually. This requires a touch screen.

  1. Load the sim and select the first screen
  2. Advance the carousel to the 2nd "kit"
  3. Drag one atom of oxygen into the play area
  4. With one finger, drag the 2nd molecule of oxygen over the first, but don't release it
  5. With another finger, attempt to advance the carousel to the next kit
jbphet commented 9 months ago

Here's a summary of what is causing this problem: If the "kit" is changed by selecting a different on in the carousel while an atom is being dragged, and that atom is subsequently released in a place where it would bond to something, the code can't find the Lewis dot model associated with the dropped atom because they are kept with the kits.

jbphet commented 9 months ago

I imagine this would have been found earlier and designed differently if we were designing for multitouch when this sim was being created, but we weren't. I can think of several refactorings that would eliminate this problem, such as keeping the Lewis dot models with the bonds instead of in a separate list, but that would be an invasive change. So here is what I've done: I added some code that will check to see if the selected kit was changed while an atom was being dragged and, if so, it puts the atom back in the kit. This not only appears to fix the problem, but will also prevent atoms from bonding into molecules when they are invisible.

I'll leave this in place overnight and check if the problem disappears from CT and doesn't add anything new. I'll then review it with @jonathanolson to see if he's okay with this or would like to try something else.

jbphet commented 8 months ago

At the moment, this issue still recurs on CT occasionally. @jonathanolson and I decided that I should go ahead and put the "workaround-ish" fix back in and see if everything clears up.

jbphet commented 8 months ago

I've added back the code for better handling of the case where the kit is changed while the atom is being dragged. I'll keep an eye on CT and if the error doesn't appear after a day or so, this issue can be closed.

jbphet commented 8 months ago

The error has not recurred on CT since the commit above. Closing.