-
Notifications
You must be signed in to change notification settings - Fork 11
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
Sometimes ammeter doesn't disappear in State Wrapper #974
Comments
@samreid suggested that we can likely fix this by implementing the same solution that we used for the Voltmeter, by turning it into a one-way stateful probe. |
Here is a working patch that tells the ammeter readout to behave like a DerivedProperty (do not try to load the state). It works in testing, but it is unfortunate to lose the Subject: [PATCH] Update credits, see https://github.com/phetsims/qa/issues/900
---
Index: main/circuit-construction-kit-common/js/model/Ammeter.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/main/circuit-construction-kit-common/js/model/Ammeter.ts b/main/circuit-construction-kit-common/js/model/Ammeter.ts
--- a/main/circuit-construction-kit-common/js/model/Ammeter.ts (revision 8eb8c7acd3c6bcce277b75ee9f22339f51625620)
+++ b/main/circuit-construction-kit-common/js/model/Ammeter.ts (date 1677010731548)
@@ -18,6 +18,7 @@
import AmmeterConnection from './AmmeterConnection.js';
import CircuitElement from './CircuitElement.js';
import ReferenceIO from '../../../tandem/js/types/ReferenceIO.js';
+import DerivedProperty from '../../../axon/js/DerivedProperty.js';
export default class Ammeter extends Meter {
@@ -49,6 +50,7 @@
phetioFeatured: true,
phetioValueType: NullableIO( ReferenceIO( CircuitElement.CircuitElementIO ) ),
phetioReadOnly: true,
+ phetioOuterType: DerivedProperty.DerivedPropertyIO,
phetioDocumentation: 'The circuit element that the ammeter is connected to, or null if not connected to a circuit element'
} );
}
Index: main/axon/js/DerivedProperty.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/main/axon/js/DerivedProperty.ts b/main/axon/js/DerivedProperty.ts
--- a/main/axon/js/DerivedProperty.ts (revision ecf09b3e5fca83283346330540d62836fd796b46)
+++ b/main/axon/js/DerivedProperty.ts (date 1677010766457)
@@ -256,7 +256,7 @@
if ( !cache.has( parameterType ) ) {
cache.set( parameterType, new IOType( `${DERIVED_PROPERTY_IO_PREFIX}<${parameterType.typeName}>`, {
- valueType: DerivedProperty,
+ // valueType: DerivedProperty,
parameterTypes: [ parameterType ],
supertype: Property.PropertyIO( parameterType ),
documentation: 'Like PropertyIO, but not settable. Instead it is derived from other DerivedPropertyIO or PropertyIO ' +
|
You could also mark it as phetioState: false right? When are we going to pull the trigger and make a new metadata flag called phetioSerializable for things that should not be settable? We could also make a new IOType that wraps another IOType, but overwrites fromStateObject and applyState with a stub. That is a bit lame, but kinda what we want here. We could also change the |
Also, why are we getting an unset state error? Shouldn't wire1 still exist as part of setting state? Also, can we just opt out of calling updateAmmeter in the Node when setting state? This is likely more on the workaround side. Let's talk! |
Ok. I think all the above are a bit downstream of the issue at hand. Here is what I see going on:
In addition to this likely being a memory leak, it is causing this bug too. |
This code added to the Ammeter constructor worked well. Over to @samreid to do what is best here.
this.isActiveProperty.link( ()=>{
this.probeConnectionProperty.value = null;
}) |
Good fix, thanks! I did the same thing in Voltmeter. I checked if that allowed me to remove @Nancy-Salpepi can you please test in master? @zepumph can you please review and comment? |
@matthew-blackman and I were not able to reproduce this locally or on phettest. On slack @Nancy-Salpepi is reporting other issues on Safari that may be local to that installation. So we think this issue can be closed. Let's reopen if this issue is discovered in RC.1. |
It was definitely my computer. Images were disabled somehow. Sorry for any trouble @samreid @matthew-blackman! |
Test device
MacBook Air M1 chip and iPad 9th generation
Operating System
13.1 and iOS 16.3
Browser
Safari
Problem description
For phetsims/qa#900, in the State Wrapper, pressing 'Set State Now' doesn't always remove the ammeter in the downstream sim.
Steps to reproduce
Visuals
ammeteronResetAll.mp4
The text was updated successfully, but these errors were encountered: