-
Notifications
You must be signed in to change notification settings - Fork 0
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
CT ERROR: Uncaught Error: Assertion failed: phetioState only accessible for instrumented objects in PhET-iO brand. #11
Comments
This error is related to these ObservableArrays in NumberPairsSceneModel: public readonly leftAddendObjects: ObservableArray<CountingObject>;
public readonly rightAddendObjects: ObservableArray<CountingObject>; The stack trace indicates that this is failing at Emitter line 61: // Although this is not the idiomatic pattern (since it is guarded in the phetioStartEvent), this function is
// called so many times that it is worth the optimization for PhET brand.
Tandem.PHET_IO_ENABLED && this.isPhetioInstrumented() && this.phetioStartEvent( 'emitted', {
61 data: this.getPhetioData( ...args )
} ); The ObservableArrays are indeed instrumented. But perhaps there's something in ObservableArray or Emitter that requires the elements of the array ( |
Yes, it looks the elements of an ObservableArray also need to be instrumented. @marlitas Below is a patch that instruments phetioState: false // until CountingObject has some state Also noting that I did not commit this because I immediately hit other PhET-iO problems in Studio of the "required tandems must be supplied" variety. patchSubject: [PATCH] rename param to collides(), https://github.com/phetsims/models-of-the-hydrogen-atom/issues/68
---
Index: js/common/model/NumberPairsSceneModel.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/model/NumberPairsSceneModel.ts b/js/common/model/NumberPairsSceneModel.ts
--- a/js/common/model/NumberPairsSceneModel.ts (revision 40fcf5346816fee6a050389f6d14162e1fe81fc1)
+++ b/js/common/model/NumberPairsSceneModel.ts (date 1727707693508)
@@ -40,24 +40,29 @@
numberType: 'Integer',
tandem: tandem.createTandem( 'leftAddendNumberProperty' )
} );
+
+ const leftAddendObjectsTandem = tandem.createTandem( 'leftAddendObjects' );
this.leftAddendObjects = createObservableArray( {
phetioType: ObservableArrayIO( CountingObject.CountingObjectIO ),
- tandem: tandem.createTandem( 'leftAddendObjects' )
+ tandem: leftAddendObjectsTandem
} );
this.rightAddendNumberProperty = new DerivedProperty( [ this.leftAddendNumberProperty ], leftAddendValue => {
return this.total - leftAddendValue;
} );
+
+ const rightAddendObjectsTandem = tandem.createTandem( 'rightAddendObjects' );
this.rightAddendObjects = createObservableArray( {
phetioType: ObservableArrayIO( CountingObject.CountingObjectIO ),
- tandem: tandem.createTandem( 'rightAddendObjects' )
+ tandem: rightAddendObjectsTandem
} );
- _.times( initialLeftAddendValue, () => {
- this.leftAddendObjects.push( new CountingObject() );
+ _.times( initialLeftAddendValue, index => {
+ this.leftAddendObjects.push( new CountingObject( leftAddendObjectsTandem.createTandem( `leftAddendObject${index}` ) ) );
} );
- _.times( initialRightAddendValue, () => {
- this.rightAddendObjects.push( new CountingObject() );
+
+ _.times( initialRightAddendValue, index => {
+ this.rightAddendObjects.push( new CountingObject( rightAddendObjectsTandem.createTandem( `rightAddendObject${index}` ) ) );
} );
assert && assert( this.leftAddendObjects.length + this.rightAddendObjects.length === this.total, 'leftAddendObjects.length + rightAddendObjects.length should equal total' );
Index: js/common/model/CountingObject.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/common/model/CountingObject.ts b/js/common/model/CountingObject.ts
--- a/js/common/model/CountingObject.ts (revision 40fcf5346816fee6a050389f6d14162e1fe81fc1)
+++ b/js/common/model/CountingObject.ts (date 1727707800781)
@@ -9,13 +9,17 @@
import PhetioObject from '../../../../tandem/js/PhetioObject.js';
import numberPairs from '../../numberPairs.js';
import IOType from '../../../../tandem/js/types/IOType.js';
+import Tandem from '../../../../tandem/js/Tandem.js';
// We will probably need this to be a PhET-iO CountingObject for Group Sort later on.
export default class CountingObject extends PhetioObject {
- public constructor() {
- super();
+ public constructor( tandem: Tandem ) {
+ super( {
+ tandem: tandem,
+ phetioState: false // until CountingObject has some state
+ } );
}
public static CountingObjectIO = new IOType( 'CountingObjectIO', { |
I am going to disable phet-io state testing on CT until more work has been done in this sim. It's not at a good place to be playing whac-a-mole with any state wrappers right now, nor is it worth it until more work has been done. I'll make sure that I am testing phet-io brand to ensure tandems are supplied as needed to address some of the |
I have added in all the necessary tandems for the sim. I am going to close this issue as it is now covered by #12 |
The text was updated successfully, but these errors were encountered: