Excalibur icon indicating copy to clipboard operation
Excalibur copied to clipboard

Scene transitions may not start in correct state when fixedUpdateFps is set

Open mattjennings opened this issue 1 year ago • 3 comments

https://github.com/excaliburjs/Excalibur/assets/8703090/8557ea64-fabd-4805-8158-f3d2bee210a4

It seems that the first frame of a scene transition may be incorrect when fixedUpdateFps is set to a rate lower than the screen refresh rate. To exaggerate the effect, I've set the fixedUpdateFps to 5 in the video, but it's occasionally noticeable when set to 60fps on a 120hz screen.

It occasionally does something similar on the final frame as well, where it'll flicker back to the beginning of the transition.

Steps to Reproduce

  • Set fixedUpdateFps to something lower than the screen's refresh rate
  • Start a game with an inTransition

https://jsfiddle.net/mattjennings/mkL637pz/2/

Expected Result

Should not see a flicker on first frame of transition

Actual Result

It flickers on the first frame

Environment

  • browsers and versions: Chrome 122.0.6261.129
  • operating system: macOS
  • Excalibur versions: 0.29.1

mattjennings avatar Mar 16 '24 01:03 mattjennings

Ack! Good find, fixed update strikes again!

eonarheim avatar Mar 16 '24 01:03 eonarheim

I've done a little poking around, I think there are multiple things going on.

During the fixed update

  1. The camera is not updating the position transform after scene init so it causes a flicker at that point
  2. Transitions start a frame late sometimes due to the async/await code, they don't get added to the scene at the right time.
  3. On the initial transition gets setup as a deferred transition and there is also a timing issue when the game starts
  4. I think there might be a few more quirks related to the update/draw as well that I haven't yet figured out

All of these seem fixable with some light refactoring, really things that need to happen simultaneously should not be separate await's but a single atomic call because we are at the mercy of browser scheduling (my theory).

eonarheim avatar Mar 28 '24 02:03 eonarheim

This issue hasn't had any recent activity lately and is being marked as stale automatically.

github-actions[bot] avatar May 28 '24 00:05 github-actions[bot]