Closed pixelzoom closed 1 year ago
To reproduce:
The relevant Property is dispensingProperty
in Shaker, and it's set in step
:
// @public Sets the dispensing rate if the shaker is moving.
step() {
if ( this.visibleProperty.get() && !this.emptyProperty.get() ) {
if ( this.previousPosition.equals( this.positionProperty.get() ) ) {
this.dispensingRateProperty.set( 0 ); // shaker is not moving, don't dispense anything
}
else {
this.dispensingRateProperty.set( this.maxDispensingRate ); // max rate seems to work fine
}
}
this.previousPosition = this.positionProperty.get();
}
Over in ShakerParticles, particle instances are created if:
if ( shaker.dispensingRateProperty.get() > 0 )
@samreid suggested creating a flag like this to suppress particle creation while the PhetioEngine is setting state. But we didn't get it to work in 15 minutes, so bailed.
const settingState = _.hasIn( window, 'phet.phetIo.phetioEngine' ) && phet.phetIo.phetioEngine.phetioStateEngine.isSettingState;
We'll return to this later.
I created phetsims/phet-io#1624 to come up with a general solution to knowing when state is being restored. Assigned to the PhET-iO team. This issue is blocked until that is addressed.
Over in phetsims/phet-io#1624, phet.joist.sim.isSettingPhetioStateProperty
was added to determine whether PhetioEngine is setting state. I'll proceed with that.
This was resolved by the above commits. Closing.
The second-to-previous commit left some code commented out that seemed suspicious. I discovered it as I was working on https://github.com/phetsims/tandem/issues/212.
Shaker has:
options = merge( {
// phetioType: ShakerIO
}, options );
Is this meant to be commented out? If so, can ShakerIO be deleted?
Is this meant to be commented out? If so, can ShakerIO be deleted?
I commented it out in 0d53c0d1b9b9f4a4c9f257aa6e7522b66e2a9442, but I suspect that was not intentional. I typically do not commit dead code.
I didn't instrument this sim, so I don't know why ShakerIO was instrumented, or if it needs to be. Probably a topic for #230.
On hold until #230 has progress.
This problem no longer occurs. And shaker particles that were in motion continue to move from where they were when the Studio "Test" button was pressed. So nothing to do here, closing.
In https://github.com/phetsims/beers-law-lab/issues/244#issuecomment-593631064, @samreid reported:
We'll look at this as part of PhET-iO redesign #230.