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

Non-looping GIFs in unfocused tabs never paint final frame #5521

Open
1 of 17 tasks
stalgiag opened this issue Dec 30, 2021 · 2 comments
Open
1 of 17 tasks

Non-looping GIFs in unfocused tabs never paint final frame #5521

stalgiag opened this issue Dec 30, 2021 · 2 comments

Comments

@stalgiag
Copy link
Contributor

stalgiag commented Dec 30, 2021

Most appropriate sub-area of p5.js?

  • Accessibility (Web Accessibility)
  • Build tools and processes
  • Color
  • Core/Environment/Rendering
  • Data
  • DOM
  • Events
  • Friendly error system
  • Image
  • IO (Input/Output)
  • Localization
  • Math
  • Unit Testing
  • Typography
  • Utilities
  • WebGL
  • Other (specify if possible)

Details about the bug:

  • p5.js version: main branch
  • Web browser and version: all
  • Operating System:
  • Steps to reproduce this:

Upload a non-looping GIF, switch tabs, wait a few seconds, return to sketch. The GIF will be frozen on the frame that it was on when the tab was switched.

I will try to loop back around and make a sketch example soon but in the meantime, someone else is welcome to do so.

related to #5484

@stampyzfanz
Copy link
Contributor

Reproduced with example sketch: https://editor.p5js.org/stampyzfanz/sketches/Wn9GsiQs2

@yashlamba
Copy link
Contributor

Hi, new to p5.js and looking forward to contribute!

I looked into this issue and it comes down to how we evaluate number of frames to skip here:

const skips = Math.floor(props.timeDisplayed / curDelay);

and this condition:

p5.js/src/image/p5.Image.js

Lines 241 to 243 in c3f4121

if (props.loopLimit !== null && props.loopCount >= props.loopLimit) {
props.playing = false;
} else {

I would like to work on this, but what is the ideal behaviour here? When someone switched tab, should the GIF:

  1. pause and resume or
  2. Continue running
    • If there are still frames left (gif takes 1 min and user switched for 30 seconds), it should resume from +30 seconds of when the tab was switched.
    • If no frames are left, show the last frame.

@Qianqianye Qianqianye added Area:Image and removed GIF labels Jul 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants