Closed KatieWoe closed 3 years ago
There is something about the RutherfordNucleousIcon causing this, this change makes the bug go away
static RutherfordNucleusIcon( protonCount, neutronCount ) {
// create static properties and nucleus for the icon
const protonCountProperty = new Property( protonCount );
const neutronCountProperty = new Property( neutronCount );
const nucleus = new RutherfordNucleus( protonCountProperty, neutronCountProperty );
return new phet.scenery.Circle( 25, { fill: 'red' } );
// return new IconCanvasNode( nucleus );
}
The usage of bind to paint the canvas was kind of inefficient, fixed in the above commit. But that didn't resolve the issue.
I noticed that the bug goes away when "Nuclear Scale" is selected in the RutherfordAtomScreenView.
The bug happens when the RutherfordNucleusIcon has some non-1 opacity and pan and zoom tries to move it entirely out of view so it has no bounds. The error is in CanvasBlock.walkDown
if ( node.getOpacity() !== 1 ) {
sceneryLog && sceneryLog.CanvasBlock && sceneryLog.CanvasBlock( `Pop opacity ${trail.subtrailTo( node ).toDebugString()}` );
// Pop opacity
const topWrapper = this.wrapperStack[ this.wrapperStackIndex ];
const bottomWrapper = this.wrapperStack[ this.wrapperStackIndex - 1 ];
this.popWrapper();
// Draw the transparent content into the next-level Canvas.
bottomWrapper.context.setTransform( 1, 0, 0, 1, 0, 0 );
bottomWrapper.context.globalAlpha = node.getOpacity();
bottomWrapper.context.drawImage( topWrapper.canvas, 0, 0 );
bottomWrapper.context.globalAlpha = 1;
}
topWrapper
has zero width and height, and browser throws an error. I think this is beyond the sim, moving to scenery.
I opened https://github.com/phetsims/scenery/issues/1179 to investigate further. THis is on hold until fixed there.
https://github.com/phetsims/scenery/issues/1179 has a fix and this should be gone now, ill wait till next CT iterations to close. Also, we don't need to disable pan and zoom in this sim anymore, ill remove that from package.json.
It is gone, closing