Closed zepumph closed 6 years ago
The appropriate solution to this problem is to use Vector3 for this case (and sometimes ignore the z attribute).
@jonathanolson you are listed as the responsible dev, can you please work on this?
Looking into it. Seems like MovableDragHandler should ideally only be handling Vector2s, and CLB should be working around that.
This is consistently failing for phet-io capacitor lab on bayes (not surprisingly), I just wanted to let people know.
The easiest way to reproduce this is screens=2 then drag the voltmeter across the bottom left wire.
I added a workaround in the preceding commit, the JSDoc says:
/**
* Capacitor Lab Basics uses Vector3 for the model, but MovableDragHandler only supports Vector2 and PhET-iO
* types Vector2IO and CLBVector3IO cannot be mixed. This file is a workaround for https://github.com/phetsims/capacitor-lab-basics/issues/215
* and supports Vector2 and Vector3
*
* @author Sam Reid (PhET Interactive Simulations)
* @author Andrew Adare (PhET Interactive Simulations)
*/
This is clearly noted as a workaround, this is intended to get fuzz testing passing again. This runs the risk of giving us a false sense of hope, but will prevent any other errors from getting masked by this one.
So I recommend to (a) run this workaround past @zepumph to make sure I've got it right then (b) leave this issue open for investigation by @jonathanolson for a better long term solution.
Looks like a good workaround to me.
In https://github.com/phetsims/capacitor-lab-basics/issues/215#issuecomment-345374585, @samreid said:
The appropriate solution to this problem is to use Vector3 for this case (and sometimes ignore the z attribute).
Absolutely not. The documentation for MovableDragHandler very clearly indicates that the locationProperty
is of type {Property.<Vector2>}
. CL:B's use of Vector3
is therefore incorrect and inappropriate.
The workaround is incomplete - it only addresses CLBVector3IO, not the improper use of MovableDragHandler. If I add this assertion to MovableDragHandler's constructor, CL:B fails:
assert && assert( locationProperty.value instanceof Vector2 );
Please address the root problem.
Working on addressing the root problem now.
Should be fixed in master.
Somewhat comically, it wasn't even passing in a ModelViewTransform2 as modelViewTransform! Maybe we should add type checks there?
@zepumph, can you verify?
Looks good, thanks. Assigning back to you to decide if you want to add type checks for the drag handler.
+1 for type checks
Type checking every single option in every file seems like a lot of work and we would want a way to standardize and simplify and avoid repeating types. Let's rely on automated and manual testing to catch this error for now, closing.
This assertion is coming from https://github.com/phetsims/beers-law-lab/issues/215, where many assertions were added to phet-io stateObject methods. Here it looks like the MovableDragHandlers in CLB are passing in Vector3 positions, but the MovableDragHandler is expecting it to be Vector2.
@samreid I'm worried about a proliferation of these multi-type types if we made
Vector2or3IO
. Whatchya think?