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

Pause the playback of GIF when scroll and resume when scroll stopped #520

Open
zhongwuzw opened this issue Jul 11, 2019 · 0 comments
Open
Labels

Comments

@zhongwuzw
Copy link
Contributor

I have the requirement to improve the scroll performance when collection view has many GIFs, thus pause the playback in scrolling state and resume after scroll finished. (By setting runloop mode to default mode other than common mode)

For example, a gif has 20 frames, frame interval 16ms, collection view not scrolled, now it's playing 5th frame, and scroll started, after scroll finished, maybe 5s passed, it started to resume, and even 5s passed, it still need to play 6th frame.

But in our implementation currently, we use absolute time(CACurrentMediaTime) to calculate which frame we should play, leads to frame skip. Another simple example, if a gif's loop count is 1(play only once), 20 frames, frame interval 16ms, after it played 1th frame, scroll started, keep runloop mode to default 3s, after that, gif would not resume any more, because elapsed time already exceed total duration of gif.

@garrettmoon Any reason why we choose absolute time to calculate frame index? seems all other third frameworks like YYImage/FLAnimatedImage... use CADisplayLink.duration.

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

No branches or pull requests

2 participants