phetsims / models-of-the-hydrogen-atom

"Models of the Hydrogen Atom" is an educational simulation in HTML5, by PhET Interactive Simulations at the University of Colorado Boulder.
GNU General Public License v3.0
2 stars 3 forks source link

CT: Cannot read properties of null (reading 'transformMatrix') #24

Closed pixelzoom closed 2 years ago

pixelzoom commented 2 years ago
models-of-the-hydrogen-atom : fuzz : unbuilt
https://bayes.colorado.edu/continuous-testing/ct-snapshots/1653496821904/models-of-the-hydrogen-atom/models-of-the-hydrogen-atom_en.html?continuousTest=%7B%22test%22%3A%5B%22models-of-the-hydrogen-atom%22%2C%22fuzz%22%2C%22unbuilt%22%5D%2C%22snapshotName%22%3A%22snapshot-1653496821904%22%2C%22timestamp%22%3A1653501460642%7D&brand=phet&ea&fuzz&memoryLimit=1000
Query: brand=phet&ea&fuzz&memoryLimit=1000
Uncaught TypeError: Cannot read properties of null (reading 'transformMatrix')
TypeError: Cannot read properties of null (reading 'transformMatrix')
at transformMatrix (RectangleCanvasDrawable.js:102:35)
at paintCanvas (Rectangle.ts:725:38)
at canvasPaintSelf (Node.ts:5276:11)
at renderToCanvasSelf (Node.ts:5291:9)
at renderToCanvasSubtree (Node.ts:5342:16)
at renderToCanvasSubtree (Node.ts:5310:16)
at renderToCanvasSubtree (Node.ts:5342:16)
at renderToCanvasSubtree (Node.ts:5342:16)
at renderToCanvasSubtree (Node.ts:5342:16)
at renderToCanvasSubtree (Node.ts:5342:16)
id: Bayes Chrome
Snapshot from 5/25/2022, 10:40:21 AM
pixelzoom commented 2 years ago

Reproduced locally with ?brand=phet&ea&debugger&initialScreen=1&fuzz.

Uncaught TypeError: Cannot read properties of null (reading 'transformMatrix')
    at CanvasSelfDrawable.paintCanvas (RectangleCanvasDrawable.js? [sm]:102:14)
    at Rectangle.canvasPaintSelf (Rectangle.ts:725:39)
    at Rectangle.renderToCanvasSelf (Node.ts:5276:12)
    at Rectangle.renderToCanvasSubtree (Node.ts:5291:10)
    at Node.renderToCanvasSubtree (Node.ts:5342:17)
    at AlignBox.renderToCanvasSubtree (Node.ts:5342:17)
    at RectangularRadioButton.renderToCanvasSubtree (Node.ts:5342:17)
    at LightModeRadioButtonGroup.renderToCanvasSubtree (Node.ts:5342:17)
    at Node.renderToCanvasSubtree (Node.ts:5342:17)
    at SpectraScreenView.renderToCanvasSubtree (Node.ts:5342:17)
pixelzoom commented 2 years ago

LightModeRadioButtonGroup.ts creates this radio-button group:

screenshot_1685

The icons for these radio buttons have a derived stroke for the beam (to adapt to the default vs projector color profile), like this:

  // If the beam color is the same as the radio button fill, stroke the beam.
  const strokeProperty = new DerivedProperty( [ MOTHAColors.lightModeRadioButtonFillProperty ],
    lightModeRadioButtonFill => ( lightModeRadioButtonFill.equals( beamColor ) ) ? 'black' : null
  );

  const beamNode = new Rectangle( 0, 0, 5, 10, {
    fill: beamColor,
    stroke: strokeProperty,
    ...
  } );

I don't know why this should be a problem. But I suspect that in RectangleCanvasDrawable.js, the call to node.hasPaintableStroke() (line 99) doesn't know that it's stroke has changed to null. @jonathanolson can you confirm/explain?

In the meantime, I've changed null to 'transparent' in my implementation.

jonathanolson commented 2 years ago

Definite bug. hasFill()/hasStroke() should not be returning true if it's a Property with a null value. Seeing if the fix breaks anything.

pixelzoom commented 2 years ago

I haven't seen any problems in the sim or in CT. @jonathanolson can this issue be closed?

jonathanolson commented 2 years ago

Yes, thanks!