Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed GIF Freezing After Returning to Unfocused Tab #5484

Merged
merged 1 commit into from
Dec 30, 2021

Conversation

frigorific44
Copy link
Contributor

Resolves #5434

Changes:
GIFs now only use _lastFrameTime to track when to show the next frame. A sum with deltaTime was used before to estimate what the current time was in a way which would keep frames across all GIFs synchronized, but had the side effect of freezing a GIF when returning from a different tab or window, as the estimate would use the large deltaTime between the previous frames to estimate a curTime which has not yet been reached. Everything is effectively the same, except GIF frames are no longer translated by the running-average of deltaTime.

PR Checklist

  • npm run lint passes
  • [Inline documentation] is included / updated
  • [Unit tests] are included / updated

@welcome
Copy link

welcome bot commented Nov 28, 2021

🎉 Thanks for opening this pull request! Please check out our contributing guidelines if you haven't already. And be sure to add yourself to the list of contributors on the readme page!

@stalgiag
Copy link
Contributor

stalgiag commented Dec 7, 2021

Thank you for this contribution! Returning to this after a long time away and trying to wrap my head around the messy stuff done here in the name of 'real-time'. I sometimes return to #3380 as that was the original spec for the GIF implementation.

First things first, I am not sure but I believe that + deltaTime was put in place to account for the time between the current frame and the previous frame. This is a minor sync issue and is probably a worthy trade to keep the GIFs from breaking with unfocused tabs.

Second, this PR is affected by a different but similar problem. It seems that when a GIF is not looping and the tab is unfocused long enough to reach the end, p5 never paints the final frame. This wasn't introduced by you but is likely a side effect of fixing the main issue with unfocused tabs.

I would be willing to merge this if we open another issue that clearly explains the known imperfections of the current implementation.

@stalgiag stalgiag merged commit fcdb321 into processing:main Dec 30, 2021
@stalgiag
Copy link
Contributor

Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Animated GIFs freeze after the browser tab is off screen.
2 participants