phetsims / wave-interference

"Wave Interference" is an educational simulation in HTML5, by PhET Interactive Simulations.
MIT License
18 stars 5 forks source link

Diffraction Screen Initializes Without Image Sometimes #443

Open JRomero0613 opened 4 years ago

JRomero0613 commented 4 years ago

For https://github.com/phetsims/QA/issues/424 when testing on MacOS 10.10.5 on Safari 10.1.2.10603.3.8 with various string test query parameters I noticed that sometimes after navigating to the Diffraction screen the right hand image does not appear. Instead of a blank black box it is just a white screen. I have attached a screenshot of this bug for reference. Once something on the sim is changed such as the image type or wavelength the right hand image appears again and the sim works fine, this is only an issue when navigating to the screen for the first time. I'll do some more testing to narrow down the specifics of the issue, but for now it has only occurred on Mac on Safari with string test query parameters. Screen Shot 2019-09-06 at 11 49 36 AM

samreid commented 4 years ago

I launched the Wave Interference RC several times on macOS 10.14.6 running Safari 12.1.2 (14607.3.9), I tried several different ?stringTest query parameters and did not see the problem.

I noticed some CanvasNode subclasses call this.invalidatePaint(); at the end of the constructor.

@jonathanolson what do you think is happening here, and do you think this.invalidatePaint(); at the end of CanvasNode construction would resolve it?

samreid commented 4 years ago

@jonathanolson what do you think is happening here, and do you think this.invalidatePaint(); at the end of CanvasNode construction would resolve it?

I set a breakpoint during Node construction and found that when the CanvasNodeDrawable is attached, it already has dirty: true, so (depending on the timing), another invalidate call at the end of the constructor may not help.

samreid commented 4 years ago

This is the last remaining issue before next Wave Interference RC, increasing priority.

jonathanolson commented 4 years ago

It doesn't seem like a repaint issue on the sim side, and that wouldn't be browser-specific.

I think I'd need to be able to reproduce it and debug it in the "broken" state. I'm curious if it's the result of something with the stringTest triggering improper/negative bounds that cascades into that type of failure. I don't see anything in the code that would trigger this.

I'll be available tomorrow before meetings to assist with this.

samreid commented 4 years ago

@jonathanolson and I reproduced this problem on Dirac. We see the problem about 1/5 reloads, even when using no string test query string, and ?screens=4 in requirejs mode. When resizing the screen, it draws right away. The canvas data this.imageDataRenderer.canvas.toDataURL() looks correct (black square), but it is not rendering. Putting a setInterval to invalidate works around the problem.

samreid commented 4 years ago

@ariel-phet reviewed the problem and pointed out that the sim doesn't do anything until the user presses the laser button anyways, and since that causes the view to redraw, it fixes the bug at this point. He therefore said this problem should be deferred.