phetsims / projectile-data-lab

"Projectile Data Lab" is an educational simulation in HTML5, by PhET Interactive Simulations.
GNU General Public License v3.0
0 stars 0 forks source link

Designs of Mystery Launchers 5-6 can fail to render after a period of time #271

Closed Nancy-Salpepi closed 5 months ago

Nancy-Salpepi commented 6 months ago

Test device iPad 9th generation

Operating System iPadOS 17.3

Browser Safari

Problem description For https://github.com/phetsims/qa/issues/1060, after playing with the sim for a while, Mystery Launchers 5 and 6 appeared as gray and black instead of with their designs. Restarting the sim didn't fix the problem; only clearing my cache did. This happened 2 times on the iPad and once with mac/safari during testing.

Visuals

Screenshot 2024-03-22 at 11 21 06 AM Screenshot 2024-03-22 at 11 20 40 AM Screenshot 2024-03-22 at 11 20 04 AM
matthew-blackman commented 6 months ago

@samreid and I are unable to reproduce this with Safari on macOS.

@Nancy-Salpepi how long does this take to trigger this? Is there a direction that we can pursue to try and reproduce it reliably?

@jonathanolson we are also wondering if this looks like something you are aware of. We are using svgs for the launcher pattern, but there is no difference in the way that launchers 5 and 6 are being rendered compared to the other launchers. Is there something we can pursue further to try and track down the source of this rendering issue?

Nancy-Salpepi commented 6 months ago

I wish I had more info to give. I will go back and take another look on the iPad because I spent less time testing on that device and it happened twice there.

Nancy-Salpepi commented 6 months ago

I looked back at the dev version and the easiest way to reproduce it on the iPad/mac + safari is to keep changing the query parameters.

For example, with mac + safari:

  1. Clear cache
  2. Open Variability screen of sim --all looks good
  3. Add ?autoGenerateData=true to url
  4. Check Launchers 5-6 on Variability screen
  5. Change to ?autoGenerateData=false
  6. Check Launchers
  7. keep repeating

I also saw it with iPad by changing between stringTests. I hope this helps!

https://github.com/phetsims/projectile-data-lab/assets/87318828/dc4cda7d-f331-4528-81f0-6d5fc3336e3c

samreid commented 6 months ago

I saw the problem by following @Nancy-Salpepi instructions and it happened after setting auto generate to false only one time, on the built dev version:

image

Note it is only broken in the icon and not in the play area.

samreid commented 6 months ago

I was surprised to see that removing the rasterization did not help here. The icons are rendered in https://github.com/phetsims/projectile-data-lab/blob/main/js/common/view/MysteryLauncherIcon.ts, and we are ready to request help from @jonathanolson

Nancy-Salpepi commented 6 months ago

To get the Launcher in the play area solid gray/black:

  1. On the Variability screen click on Launcher 5
  2. Add ?stringTest=double
  3. If the Launcher 5 icon is gray on the Variability screen, select it --the launcher should also be gray in the play area
  4. If the Launcher 5 icon isn't gray, change the stringTest to something else until it is and then repeat step 3.

Hope this helps!

jonathanolson commented 6 months ago

Isolated to somewhat-minimal html: https://bayes.colorado.edu/dev/phettest/scenery/tests/browsers/safari-pattern-test.html

If loaded in Safari (in a new tab), it seems to randomly decide to show the texture or not.

jonathanolson commented 6 months ago

It seems like rasterization actually might be required for this bug to present, but I haven't tested fully without rasterization.

jonathanolson commented 6 months ago

Actual (Safari, sometimes) vs. Expected (Chrome)

image image
samreid commented 6 months ago

In https://github.com/phetsims/projectile-data-lab/issues/271#issuecomment-2030661414 I observed that removing rasterization from the icon did not seem to prevent the problem.

jonathanolson commented 6 months ago

Added a workaround that forces a rasterization of the SVG launcher pattern (on Safari) synchronously to a Canvas pattern, so it isn't getting an embedded SVG-image inside SVG case (where the pattern seems to fail).

jonathanolson commented 6 months ago

Let me know if this workaround works for people!

samreid commented 6 months ago

@matthew-blackman and I had difficulty reproducing the problem again, even before the fix from @jonathanolson. I'll create a dev test for @Nancy-Salpepi to check a built version before RC.1.

samreid commented 6 months ago

Deployed: https://phet-dev.colorado.edu/html/projectile-data-lab/1.0.0-dev.23/phet/projectile-data-lab_all_phet.html Deployed: https://phet-dev.colorado.edu/html/projectile-data-lab/1.0.0-dev.23/phet-io/

samreid commented 6 months ago

I tested the link above on macOS Safari, and saw this result after loading once with no query parameters:

https://phet-dev.colorado.edu/html/projectile-data-lab/1.0.0-dev.23/phet/projectile-data-lab_all_phet.html?autoGenerateData=true&stringTest=a

image

Do you think there is something odd in the SVG itself? Should we try exporting it a different way? Should we try a PNG instead of SVG? @jonathanolson what do you recommend?

samreid commented 6 months ago

@jonathanolson suggested trying PNG to see if it works around the problem for now.

matthew-blackman commented 5 months ago

@samreid and I made progress tracking down the source of this bug. It only affects the two svg files that are using the <pattern> tag. This tag is added to the file when Illustrator exports a 'pattern' image type.

It looks like Safari may not have liked the following part of the last 2 launcher svgs: <pattern id="StarsYellow" x="0" y="0" width="75" height="75" patternTransform="translate(-10715.89 23009.05) rotate(45) scale(2.97)" patternUnits="userSpaceOnUse" viewBox="0 0 75 75">

The commit updates those 2 svgs to avoid using the pattern tag, and instead using all vector paths. @Nancy-Salpepi @samreid can you see if this fixes the problem?

samreid commented 5 months ago

Everything looks good here (testing on unbuilt). We should also test on a build one.

samreid commented 5 months ago

I tested a local built version, and everything seems good. Closing.