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

Set State problems with particle locations and container width #276

Closed
Tracked by #1123 ...
Nancy-Salpepi opened this issue Jun 24, 2024 · 17 comments
Closed
Tracked by #1123 ...

Set State problems with particle locations and container width #276

Nancy-Salpepi opened this issue Jun 24, 2024 · 17 comments

Comments

@Nancy-Salpepi
Copy link

Nancy-Salpepi commented Jun 24, 2024

Test device
MacBook Air M1 chip

Operating System
14.5

Browser
Safari 17.5

Problem description
For phetsims/qa#1100, and possibly related to #269 in the State Wrapper on all screens, the first time I set state with the sim paused, the state of the particles in the downstream sim matches the upstream. If I unpause the upstream sim and allow the particles to move a bit before pausing again, the downstream sim will not match the upstream sim when setting state. Everything else does update (the graphs, pressure, temperature etc). Once I press play, the particles in the downstream sim update. On Reset All the state is correctly set.

This also happens whens I resize the container. It will not update the second time I set state.

Steps to reproduce
Here is an example:

  1. In the State Wrapper, set state rate = 0
  2. In the upstream sim on the Ideal Screen add a bunch of particles and then hit Pause
  3. Press Set State Now
  4. In the upstream sim, press Play
  5. After the particles have obviously changed locations, press Pause
  6. Press Set State Now

Visuals

ParticleState.mp4
Screenshot 2024-06-24 at 2 02 16 PM
@KatieWoe
Copy link
Contributor

I see this in the 4th screen as well.
pausedstate

@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 3, 2024

Reproduced in main.

Note that #276 and #280 are both bad State Wrapper behavior when the sim is paused, and both related to the position of particles.

This is probably related to incorrect or missing use(s) of isSettingPhetioStateProperty, in relation to isPlayingProperty.

@pixelzoom
Copy link
Contributor

@Nancy-Salpepi said:

This also happens when I resize the container. It will not update the second time I set state.

Fixed in e8aaef0.

pixelzoom added a commit that referenced this issue Jul 9, 2024
@pixelzoom
Copy link
Contributor

The reason that the particles updated the first time that state was set is that the number of particles had changed, and that triggers an update of the view. When the number of particles is constant, and all that changes is their positions, there was nothing telling the view to update when state was set. In 98b2d2d, I added a listener that explicitly calls particleSystemNode.update when state is restored while the sim is paused.

So... The particles and container size should now update correctly when state is set while the sim is paused.

@Nancy-Salpepi please verify, close if OK.

@Nancy-Salpepi
Copy link
Author

Working great! Closing.

@Nancy-Salpepi
Copy link
Author

Sorry. I see this again in phetsims/qa#1107

@Nancy-Salpepi Nancy-Salpepi reopened this Jul 16, 2024
@Nancy-Salpepi
Copy link
Author

Nancy-Salpepi commented Jul 16, 2024

It works correctly on main but not in 1.1.0-rc.1

@pixelzoom pixelzoom self-assigned this Jul 16, 2024
@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 16, 2024

It works correctly on main but not in 1.1.0-rc.1

This behavior would be typical of a missing cherry-pick. But the commits above were all made before the 1.1 branch was created on 7/10/24 @ 5:55PM. And I confirmed that the changes in the commits for this issue (e8aaef0, 98b2d2d, 4753e62) are present in the gas-properties 1.1 branch.

@pixelzoom
Copy link
Contributor

For particle positions, broken in 1.1.0-rc.1, OK in main.

For container size, OK in both 1.1.0-rc.1 and main.

@Nancy-Salpepi is that what you are seeing too?

@Nancy-Salpepi
Copy link
Author

Yes that is what I see @pixelzoom

@pixelzoom pixelzoom changed the title Particle location while paused fails to update when setting state for the second time Set State problems with particle locations and container width Jul 17, 2024
@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 17, 2024

Duh... The problem is a difference between built and unbuilt versions. The workaround added in 98b2d2d looks like this:

    if ( assert && Tandem.PHET_IO_ENABLED ) {
      phet.phetio.phetioEngine.phetioStateEngine.stateSetEmitter.addListener( () => {
        if ( !model.isPlayingProperty.value ) {
          particleSystemNode.update();
        }
      } );
    }

That chunk of code was copied from elsewhere, from a case that we want to execute only if assertions are enabled. Hence the if ( assert . But assertions are stripped out in built versions, so this workaround never gets executed.

@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 17, 2024

The primary fix is 081fbea, the other commits are for patching release branches.

@Nancy-Salpepi please review. You can test unbuilt using main in phetmarks. You can test the built version using 1.2.0-dev.1. Leave this open for verification in 1.1.0-rc.2.

@Nancy-Salpepi
Copy link
Author

Looks good in 1.2.0-dev.1 and on main.

@Nancy-Salpepi
Copy link
Author

Nancy-Salpepi commented Jul 19, 2024

@pixelzoom on the Diffusion Screen using Studio/State I noticed that if I increase the radius of either particle and then launch the sim, the particles in the launched/downstream sim can partially cross the container wall.
Screenshot 2024-07-19 at 1 39 05 PM

This issue isn't present in 1.2.0-dev.1 or in main. I'm guessing it may have been related to this issue?

@pixelzoom
Copy link
Contributor

This issue isn't present in 1.2.0-dev.1 or in main. I'm guessing it may have been related to this issue?

Yes, that's right. Both mass and radius were not being deserialized, and that was fixed in 081fbea. So while it was a problem in 1.1.0-dev.rc.1, it is no longer a problem in main and (upcoming) 1.1.0-rc.2.

So we're still ready for 1.1.0-rc.2. for this issue.

@pixelzoom
Copy link
Contributor

pixelzoom commented Jul 23, 2024

Please verify for particle locations and container width in phetsims/qa#1123 and phetsims/qa#1124.

Please verify for particle locations in phetsims/qa#1125. (Container width is fixed in Diffusion.)

Follow "Steps to reproduce" in #276 (comment), and something similar in the Diffusion screen.

If everything looks OK, please close.

@Nancy-Salpepi
Copy link
Author

Looks good in rc.2 for all sims.
Closing.

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

3 participants