Skip to content

Possible infinite loop in FrameLoop.ts update method #770

@thatsprettyfaroutman

Description

@thatsprettyfaroutman

🐛 Bug Report

Possible infinite loop in FrameLoop.ts update method on low end machines 📠

In this part of the code (line 74):

if (time > lastTime + 64) lastTime = time; // http://gafferongames.com/game-physics/fix-your-timestep/

let numSteps = Math.floor(time - lastTime);

What happens is when the delta time between two frames is longer than 64 ms numSteps will become 0 and the animation won't move forward, causing it to get stuck

To Reproduce

Steps to reproduce the behavior:

Start a low end machine on vm where delta time between frames gets longer than 64 ms. Alternatively force the numSteps to always be zero.

Expected behavior

Animations do not get stuck on low frame rate

Link to repro (highly encouraged)

https://codesandbox.io/s/fervent-carson-n4m3p

Environment

  • react-spring v8.0.23
  • react v16.8.6

Fix

Remove the line 74: if (time > lastTime + 64) lastTime = time;

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: performanceissues with performance in particular targetskind: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions