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

Error: Assertion failed: Impossible set state (electric potential line) #130

Closed
phet-steele opened this issue Aug 22, 2017 · 9 comments
Closed

Comments

@phet-steele
Copy link
Contributor

phet-steele commented Aug 22, 2017

  1. State wrapper, http://www.colorado.edu/physics/phet/dev/html/charges-and-fields/1.1.0-phetiodev.1/wrappers/state/state.html?sim=charges-and-fields&relativeSimPath
  2. Drag out a charge.
  3. Drag out the electric potential sensor.
  4. Draw an electric potential line.
  5. Wait...
  6. Receive an error:
SimIFrameAPI Invocation Error: Error: Assertion failed: Impossible set state:
chargesAndFields.chargesAndFieldsScreen.model.electricPotentialLines_0
    at window.assertions.assertFunction (assert.js:22)
    at iterate (phetio.js?bust=1503431706507:210)
    at Object.setState (phetio.js?bust=1503431706507:227)
    at TPhETIO.implementation [as setState] (TPhETIO.js?bust=1503431706507:176)
    at Object.invoke (SimIFrameAPI.js?bust=1503431706507:258)
    at Object.handleSingleInvoke (SimIFrameAPI.js?bust=1503431706507:119)
    at Object.handleRequest (SimIFrameAPI.js?bust=1503431706507:161)
    at SimIFrameAPI.js?bust=1503431706507:278

Kills the wrapper. Seen on macOS 10.12.6 Chrome. For phetsims/qa/issues/37.

@samreid
Copy link
Member

samreid commented Aug 23, 2017

Proposed fix in preceding commits, @phet-steele can you verify on phettest? Would you like a new dev version?

@phet-steele
Copy link
Contributor Author

@samreid with this one, I'd like a new dev version and will probably update the QA task with the new version.

@samreid
Copy link
Member

samreid commented Aug 24, 2017

@phet-steele
Copy link
Contributor Author

Looks fixed in the above dev version.

@jbphet
Copy link
Contributor

jbphet commented Mar 13, 2019

@chrisklus and I stumbled across some code that looks potentially (pun semi-intended) problematic that was committed to resolve this issue. ChargesAndFieldsModel.addElectricPotentialLine now has two optional arguments - a Vector2 and a tandem, and there doesn't appear to be any code that is testing the types of the supplied arguments. Re-opening for @samreid to have a look.

@samreid
Copy link
Member

samreid commented Apr 1, 2019

In the commit, I rewrote the function using ES6 default parameters and I added checks for the parameter types. This pattern works in this case because the tandem is only supplied if the position is also supplied (options are not fully orthogonal). But let me know if this is too obscure and I can rewrite it using our idiomatic options pattern.

Also note: before I made any changes, I observed #161, which makes it difficult to test this code fully.

@jbphet
Copy link
Contributor

jbphet commented Apr 3, 2019

It definitely does look a little odd to me, especially since there are function invocations for setting the default parameters, and I've never done this before. However, this apparently is valid in JavaScript, and the sim runs and creates electric potential lines just fine. Also, the asserts would catch any inappropriate parameters, so it seems okay to me.

The only additional item I would suggest is to explicitly document that the tandem is optional but is never included if the vector position vector is not (and fix the comment to adhere to the line length convention). Otherwise, I think others will find this confusing the way that @chrisklus and I did.

@jbphet
Copy link
Contributor

jbphet commented Apr 3, 2019

@samreid - feel free to close once suggested comment is added, no need to assign back to us.

samreid added a commit that referenced this issue Apr 4, 2019
@samreid
Copy link
Member

samreid commented Apr 4, 2019

Thanks, I updated the comments accordingly, closing.

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

4 participants