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

AriaLiveAnnouncer: Assertion failed: value failed isValidValue: [object Object] on reset all #113

Closed
samreid opened this issue Mar 28, 2022 · 4 comments

Comments

@samreid
Copy link
Member

samreid commented Mar 28, 2022

While working on #99, @chrisklus and I discovered this error when pressing reset all:

Assertion failed: value failed isValidValue: [object Object]
assert.js:25 Uncaught Error: Assertion failed: value failed isValidValue: [object Object]
    at window.assertions.assertFunction (assert.js:25:13)
    at Object.isValueValid (ValidatorDef.js? [sm]:324:39)
    at validate (validate.js? [sm]:36:18)
    at StateSchema.checkStateObjectValid (StateSchema.js? [sm]:185:9)
    at IOType.isStateObjectValid (IOType.js? [sm]:342:43)
    at IOType.validateStateObject (IOType.js? [sm]:384:10)
    at IOType.toStateObject (IOType.js? [sm]:223:24)
    at Object.toStateObject (NullableIO.js? [sm]:42:75)
    at IOType.toStateObject (IOType.js? [sm]:210:32)
    at Emitter.getPhetioData (PhetioDataHandler.ts:202:53)
@samreid
Copy link
Member Author

samreid commented Mar 29, 2022

We investigated this and there appears to be a problem in the state validator in OrIO. It doesn't expect the index part of the state object. We tried this and it had other problems:

Index: js/types/OrIO.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/types/OrIO.js b/js/types/OrIO.js
--- a/js/types/OrIO.js	(revision 264f9ebf1c92925159221614c509edbb1aea182e)
+++ b/js/types/OrIO.js	(date 1648512393115)
@@ -67,7 +67,11 @@
         return parameterTypes[ stateObject.index ].fromStateObject( stateObject.state );
       },
       stateSchema: StateSchema.asValue( `${typeNames.join( '|' )}`, {
-        isValidValue: isValidValue
+        isValidValue: stateObject => {
+          return isValidValue( stateObject.state ) &&
+                 stateObject.hasOwnProperty( 'index' ) &&
+                 typeof stateObject.index === 'number';
+        }
       } )
     } ) );
   }

@zepumph can you please advise?

zepumph added a commit to phetsims/utterance-queue that referenced this issue Mar 29, 2022
zepumph added a commit to phetsims/tandem that referenced this issue Mar 29, 2022
@zepumph
Copy link
Member

zepumph commented Mar 29, 2022

Yes thanks. There were two issues. The first was that I was causing a problem in Utterance. The second is that our error handling was incorrect for OrIO so the problem was hard to realize (hence your horrid message above).

Basically Utterance.toStateObject wasn't using OrIO to get the index/state object, so the state object was invalid. I also realized that the validator for OrIO was totally wrong, because it didn't use the same state object recursive checking that needed to occur at each level.

So pretty much phetsims/utterance-queue@d85db29 fixed the bug, and phetsims/tandem@fe151c2 made it so that we could use OrIO on more complicated state objects like ChargedParticleIO which gets partial state from different levels in its IOType hierarchy.

Did this fix things for you as well?

@zepumph zepumph assigned samreid and unassigned zepumph Mar 29, 2022
@samreid
Copy link
Member Author

samreid commented Mar 29, 2022

Yes, it looks much better, thanks!

@samreid
Copy link
Member Author

samreid commented Apr 6, 2022

@chrisklus and I confirmed this is fixed in in #122, closing.

@samreid samreid closed this as completed Apr 6, 2022
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

2 participants