phetsims / arithmetic

"Arithmetic" is an educational simulation in HTML5, by PhET Interactive Simulations.
http://phet.colorado.edu/en/simulation/arithmetic
GNU General Public License v3.0
5 stars 5 forks source link

Inconsistent timer behavior #207

Closed KatieWoe closed 3 months ago

KatieWoe commented 4 months ago

Test device Dell Operating System Win 11 Browser Chrome Problem description For https://github.com/phetsims/qa/issues/1046. This does not seem to happen in published. If the timer is running on a scene that you are not on but previously started, it will continue to run if you are not on that scene. If you are on another tab of your browser, whether the timer runs depends on if you were in the scene or not when you switched tabs. If you were on the scene, the timer pauses until you return to the tab. If not, the timer continues running. Steps to reproduce

  1. Go to the first screen
  2. Turn on the timer
  3. Go to the first scene to start its timer
  4. Return to the first screen menu
  5. Go to the second scene to start its timer
  6. While in that scene, go to another tab in your browser for a minute or two
  7. Return to the sim and check the timers for both scenes

Troubleshooting information:

!!!!! DO NOT EDIT !!!!! Name: ‪Arithmetic‬ URL: https://phet-dev.colorado.edu/html/arithmetic/1.1.0-dev.4/phet/arithmetic_all_phet.html Version: 1.1.0-dev.4 2024-02-21 16:48:20 UTC Features missing: applicationcache, applicationcache, touch Flags: pixelRatioScaling User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36 Language: en-US Window: 1280x631 Pixel Ratio: 1.5/1 WebGL: WebGL 1.0 (OpenGL ES 2.0 Chromium) GLSL: WebGL GLSL ES 1.0 (OpenGL ES GLSL ES 1.0 Chromium) Vendor: WebKit (WebKit WebGL) Vertex: attribs: 16 varying: 30 uniform: 4096 Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32) Max viewport: 32767x32767 OES_texture_float: true Dependencies JSON: {}
Luisav1 commented 3 months ago

This can be fixed by removing this section from the code which accounts for elapsed time while the user was on the level selection screen. In removing this part, the timer only runs when the user is on a scene, which I thought was the desired timer behaviour. https://github.com/phetsims/arithmetic/blob/4d0a4cd8630448b33499b0debdb37e87010f8195/js/common/model/ArithmeticModel.js#L342-L349

However, I am a bit confused about the desired timer behaviour since in the published version it seems the timer is always running even when you are not a scene and it only stops once a level is completed or refreshed. Is that the behaviour we are aiming for?

Looking back at the history in #76, #59, #39, and #9 it seems as if that was the desired behaviour. If this is the case, then I believe the issue here is that the timer stops running when you go to another tab in your browser.

@amanda-phet could you weigh on on what timer behaviour we are aiming for? So it only runs when on a scene or so it runs all the time once a level has begun.

amanda-phet commented 3 months ago

I agree that it seems like the timer is behaving as desired. If there is a precedent for a different timer behavior, that might help us resolve what's going on here. @KatieWoe do you know if other sims have a timer behavior that would make more sense for this sim?

My inclination is to leave this as-is since it's doing exactly what people wanted in those previous issue discussions.

KatieWoe commented 3 months ago

I really don't know off the top of my head if there is a standard behavior. It's a bit odd, and I only caught it because I switching tabs to read emails and use github and happened to notice.

Luisav1 commented 3 months ago

During yesterday's standup with @KatieWoe, we discussed the importance of consistency regarding the game timer in the arithmetic PhET sim. In the current published version, the timer operates continuously in the background, which we aim to maintain.

However, in reviewing other sims using a game timer, in most cases, the timer only runs while the user is actively in the scene. This behavior is consistent across sims where the "Back" button functions as a "Start over" button to switch levels.

The exception to this pattern is the Fractions sims, which also have a back button similar to the Arithmetic sim. But even in these sims, the timer only runs when the user is in a scene. Maybe maintaining uniformity across all sims by having the timer run exclusively while users are on scene interaction is the approach we want to take. @amanda-phet What are your thoughts on this?

amanda-phet commented 3 months ago

I like consistency! So that sounds great to me.

Luisav1 commented 3 months ago

The timer now runs only when a user is on a scene. Even though this behaviour is different from what's published, it maintains uniformity across all sims now.