Closed Nancy-Salpepi closed 1 year ago
Reproduced in master with macOS 13.4.1 + Chrome 115.
This is a warning, informing us that there's a way to improve performance of how we're using the Canvas2D API.
I don't know where this warning is manifesting. Natural Selection uses scenery Sprite
, which is supposed to default to webgl
, with canvas
fallback. The only sim-specific use of Canvas2D that I can find is in BunnySelectionRectangleSprite.ts;
// Convert to {HTMLCanvasElement}, as required by Sprite
let selectionRectangleSpriteImage: SpriteImage;
selectionRectangle.toCanvas( canvas => {
const offset = new Vector2( selectionRectangleBounds.width / 2, selectionRectangleBounds.height - SELECTION_RECTANGLE_DILATION );
selectionRectangleSpriteImage = new SpriteImage( canvas, offset, { pickable: false } );
} );
@jonathanolson Is there something that should be done here that might improve performance? Something in the sim or scenery that should be using willReadFrequently
? Or should we just ignore this warning?
We were reading a scratch Canvas multiple times (it was reused) in order to support the hitTestPixels
feature (used at least for the bunnies). The Canvas's only use is for that purpose, so I've added the flag so that it should be CPU-side and won't have the warning.
Back to @Nancy-Salpepi to verify in master. You should no longer see this warning in Chrome. Close if OK.
I no longer see the warning in Chrome. Closing.
Test device MacBook Air (M1 chip) and Dell
Operating System macOS13.5 and Win10
Browser Chrome 115
Problem description For https://github.com/phetsims/qa/issues/967, a warning message appears in the console on startup for the PhET brand sim and PhET-iO wrappers.
Visuals