phetsims / ph-scale

"pH Scale" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/ph-scale
GNU General Public License v3.0
0 stars 7 forks source link

Ion location changes in Standard PhET-iO wrapper with Reset All #257

Closed Nancy-Salpepi closed 1 year ago

Nancy-Salpepi commented 1 year ago

Test device MacBook Air (m1 chip)

Operating System macOS 13.01.1

Browser safari 16.1 and chrome

Problem description For https://github.com/phetsims/qa/issues/866, on the Micro screen in Studio, if I check the H30+/OH- Ratio checkbox and then launch the sim, pressing Reset All will continuously change the location of the ions. This also happens on the My Solution screen if the sim is launched when the pH is anything other than 7(default). When the sim is launched at pH=7 on this screen, the ion position doesn't change when pressing Reset All.

I'm not sure how big of a deal this is, but thought I would mention.

Steps to reproduce

  1. In Studio, select the Micro screen
  2. Check the H30+/OH- Ratio checkbox
  3. Press Test
  4. In the Standard PhET-iO wrapper, continually press Reset All

Visuals

https://user-images.githubusercontent.com/87318828/208130501-7495d7da-add2-4902-a4a5-45808eb2d03a.mp4

pixelzoom commented 1 year ago

Reproduced in master.

When the "H3O+/OH- Ratio" checkbox is check, the sim displays a qualitative representation of the ratio by drawing a "particle system" -- a set of circle representing H3O+ and OH- ions.

We have previously determined that for PhET-iO, the ions are not individually instrumented, so their positions are not stateful. So when state is restored/changed, the entire particle system is recomputed and redrawn. This means that in addition to what's reported here, record/playback will not result in identical representations being played back. The qualitative ratio (number of particles) will be the same, but the position of particles will differ. If you want to change this, it will be a significant project, not only for reimplementing the particle system, but for addressing PhetioGroup scalability issues that we anticipate encountering in Gas Properties. @arouinfar let me know what you want to do here.

One thing that I can and will investigate is why the display is updating each time the Reset All button is pressed. Since the ratio isn't changing, the particle system does not technically need to be redrawn.

pixelzoom commented 1 year ago

One thing that I can and will investigate is why the display is updating each time the Reset All button is pressed. Since the ratio isn't changing, the particle system does not technically need to be redrawn.

RatioNode.ts draws the particle system. It has ratioProperty, which is derived from pHProperty.

This is not an issue in the PhET brand version, because pressing the Reset All button also causes the beaker to empty and autofill. So pHProperty is reset to null, then set to the pH of the initial solute as the beaker fills. And ratioProperty is therefore also reset to null, then set to the ratio that corresponds to the initial solute.

In the case that @Nancy-Salpepi reported, pressing Reset All restores to the initial state that was saved by the instructional designer via Studio. The way that happens is that the sim is first reset to the default initial state, and then PhET-iO engine sets the saved initial state. So state is changing, which is why the particiles are redrawing. But the user doesn't see the intermediate state change, there has been no change to the solution from their perspective, so it may be confusing that the particle system is updated.

@samreid @zepumph suggestions on what to do here?

samreid commented 1 year ago

Taking a look now...

I observed this is a problem on the Micro screen but not the My Solution screen. This is not exactly a phet-io problem. On the Micro screen in phet brand, reset scrambles the particle locations. It looks like the micro screen sets ph to null, and hence triggers numberOfH3O, numberOfOH to equal (0,0). But this is not happening in My Solution. I'm unfamiliar with this sim and not feeling very efficient. Hopefully this helps? Or please reach out of you would like to collaborate synchronously.

arouinfar commented 1 year ago

The qualitative ratio (number of particles) will be the same, but the position of particles will differ. If you want to change this, it will be a significant project, not only for reimplementing the particle system, but for addressing PhetioGroup scalability issues that we anticipate encountering in Gas Properties.

The important goal is that the ratio is preserved. The individual positions are not important, and certainly not worth any large-scale reimplementation.

But the user doesn't see the intermediate state change, there has been no change to the solution from their perspective, so it may be confusing that the particle system is updated.

The case highlighted by @Nancy-Salpepi does indeed look strange, but I see it as a bit of an edge case. Typically, users don't press the ResetAllButton several times right after startup. Even if a user does notice the particles have moved, it could lead to a productive observation/discussion about the qualitative nature of the representation.

@pixelzoom I'm fine with closing this as wont-fix, but I don't want to close this before you have a chance to review @samreid's comment.

pixelzoom commented 1 year ago

@samreid said:

I observed this is a problem on the Micro screen but not the My Solution screen.

That's because the My Solution screen does not autofill. So phProperty does not change, ratioProperty therrefore does not change, and the ratio view is not updated.

@arouinfar said:

... I see it as a bit of an edge case ... I'm fine with closing this as wont-fix ...

Great, that's what I'm going to do. Because even if I added code to test whether we're restoring state, the value of phScaleProperty changes 2x on Reset All, and I can't prevent the recomputation of ratioProperty.

Even if I added code that tests whether we're restoring state, I don't