phetsims / build-an-atom

"Build an Atom" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/build-an-atom
GNU General Public License v3.0
11 stars 10 forks source link

Assertion failed: mismatched messageIndex, possible start/end mismatch #181

Closed phet-steele closed 6 years ago

phet-steele commented 6 years ago

Complete a challenge (any?) on a game level (any?).

Uncaught Error: Assertion failed: mismatched messageIndex, possible start/end mismatch
    at window.assertions.assertFunction (assert.js:22)
    at Object.end (phetioEvents.js?bust=1515086094100:192)
    at TextPushButton.endEvent (PhetioObject.js?bust=1515086094100:121)
    at TextPushButton.dispose (PhetioObject.js?bust=1515086094100:135)
    at TextPushButton.dispose (Node.js?bust=1515086094100:4791)
    at TextPushButton.dispose (RectangularButtonView.js?bust=1515086094100:536)
    at TextPushButton.dispose (RectangularPushButton.js?bust=1515086094100:79)
    at TextPushButton.dispose (TextPushButton.js?bust=1515086094100:58)
    at TextPushButton.Node.dispose (Node.js?bust=1515086094100:492)
    at SymbolToCountsChallengeView.dispose (ChallengeView.js?bust=1515086094100:199)
jbphet commented 6 years ago

I suspect this is a phet-io thing, since I don't think anything else has changed.

jbphet commented 6 years ago

This issue does not occur when running in RequireJS mode from phetmarks, which doesn't include phet-io.

It is easily duplicated by launching instance-proxies, selecting instance-proxies, mirror-inputs, screenshot, and probably any of the other phet-io wrappers, then starting the game and completing a challenge. The assert statement is hit when the "Next" button is pressed.

I tried launching instance-proxies from the "index" page, and the problem did NOT occur.

Given that this only occurs in phet-io mode, and the assertion is in phetioEvents.js, I think @samreid should take it from here and can bring me back in if needed.

samreid commented 6 years ago

Sounds good, thanks!

samreid commented 6 years ago

I tried launching instance-proxies from the "index" page, and the problem did NOT occur.

It looks like that mode does not include assertions, so it fails silently and likely disturbs the rest of the data stream.

samreid commented 6 years ago

When the "next" button is pressed, it changes the state and disposes the next button. The phetioEvents is expecting the state change message to end, but the button message ends first (because the button was disposed).

I cannot figure out whether (a) Build an Atom is doing something suspicious and PhET-iO is catching a potential problem or (b) PhET-iO is too restrictive and showing a false positive for this case.

samreid commented 6 years ago

Proposed solution committed above. I'd like @zepumph to take a closer look when he returns. Note that adding phetioEvents.stack as an instance variable, then using the console wrapper is helpful to understand what is happening.

zepumph commented 6 years ago

@samreid I apologize I didn't get to this, leaving me assigned if it sits until Feb, otherwise back to you.

samreid commented 6 years ago

No worries, we can look at this on your return.

zepumph commented 6 years ago

// N.B. That is to say, I don't really understand the problem nor why this solution works.

I agree and it doesn't bother me. We have run into these sorts of problems before where something disposes itself before the phet-io messaging can finish. This seems like a fine workaround until we go back to this simulation.