phetsims / collision-lab

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

Balls disappear off screen when Kinetic Energy/Speed is too high #178

Closed brooklynlash closed 3 years ago

brooklynlash commented 3 years ago

Test device Lenovo ThinkPad

Operating System Windows 10

Browser Chrome

Problem description This is for https://github.com/phetsims/QA/issues/562 When observing the problem created in https://github.com/phetsims/collision-lab/issues/176, when the kinetic energy gets to a certain level and you add extra masses to the space, they end up disappearing off screen. If you change their masses, they appear for a few seconds and then fly off screen again. Eventually there is usually only one mass left on the screen.

Steps to reproduce

  1. Open Explore 1D
  2. Display the Kinetic Energy
  3. Make one ball maximum size and the other minimum size
  4. Play until the smaller ball has a relatively fast velocity
  5. Pause, switch masses so the smaller ball is maximum and the larger ball is minimum size
  6. Repeat 3-5 until the kinetic energy is in the millions.
  7. Add a ball or two, observe. If desired,
  8. Change masses of disappeared balls
  9. Click play and observe.

Visuals collisionissue3pt3

Troubleshooting information: !!!!! DO NOT EDIT !!!!! Name: ‪Collision Lab‬ URL: https://phet-dev.colorado.edu/html/collision-lab/1.1.0-dev.10/phet/collision-lab_all_phet.html Version: 1.1.0-dev.10 2020-10-15 01:57:00 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/86.0.4240.75 Safari/537.36 Language: en-US Window: 1707x818 Pixel Ratio: 2.25/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: 4095 Texture: size: 16384 imageUnits: 16 (vertex: 16, combined: 32) Max viewport: 32767x32767 OES_texture_float: true Dependencies JSON: {}

KatieWoe commented 3 years ago

Managed to reproduce this on Mac 10.15.7 Chrome and noting that when speeds get this high there is a massive amount of slowdown.

KatieWoe commented 3 years ago

Also noting that step 8:

Change masses of disappeared balls

brings back the balls even if they have left in a non-buggy manner. @arouinfar, @jonathanolson not sure if this is buggy behavior in itself. Let me know if it needs an issue. masschangebringsback

jonathanolson commented 3 years ago

I'm curious about what should be done for the increasing energy in the system. The main issue definitely happens mainly at higher energies, but it's possible to continue increasing them until the sim breaks due to overflow:

Screen Shot 2020-11-18 at 9 58 25 AM

It also seems to be related to "resizing a mass while it's close to a border", otherwise I wouldn't be able to get to such high velocities.

Since things will break anyway at high-enough velocities, what should we do about the general problem?

brings back the balls even if they have left in a non-buggy manner

It seems like if the mass is already outside of the boundary, we shouldn't push it back in the boundary? Thoughts @arouinfar on everything?

jonathanolson commented 3 years ago

Also, this has taken a lot of debugging effort, and I'm still not quite sure why it's happening. Happy to continue though.

To ease reproduction of increasing energy, the following in stepManual:

    // const bestBall = _.sortBy( this.ballSystem.balls, b => -b.velocityProperty.value.magnitude )[ 0 ];

    // this.ballSystem.balls.forEach( ball => {
    //   if ( bestBall === ball && ball.massProperty.value !== 3 ) {
    //     console.log( 'set high' );

    //     ball.massUserControlledProperty.value = true;
    //     ball.massProperty.value = 3;
    //     this.ballSystem.bumpBallAwayFromOthers( ball );
    //     ball.massUserControlledProperty.value = false;
    //   }
    //   else if ( bestBall !== ball && ball.massProperty.value !== 0.1 ) {
    //     console.log( 'set low' );

    //     ball.massUserControlledProperty.value = true;
    //     ball.massProperty.value = 0.1;
    //     ball.massUserControlledProperty.value = false;
    //   }
    // } );
jonathanolson commented 3 years ago

Design decision: do nothing, it's worked well in other sims in cases like this.