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

Use proper units when setting preferredFramesPerSecond #572

Merged
merged 2 commits into from
Oct 6, 2020

Conversation

bdolman
Copy link
Contributor

@bdolman bdolman commented Oct 6, 2020

preferredFramesPerSecond expects frames-per-second, rather than the
fractional interval expected by frameInterval.

For example, frameInterval=2 is the equivalent (on most devices) of
preferredFramesPerSecond=30.

This issue was introduced in #552

It's likely this fixes #570

preferredFramesPerSecond expects frames-per-second, rather than the
fractional interval expected by frameInterval.

For example, frameInterval=2 is the equivalent (on most devices) of
preferredFramesPerSecond=30.

This issue was introduced in pinterest#552
Copy link
Collaborator

@garrettmoon garrettmoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for fixing!

@garrettmoon
Copy link
Collaborator

Can you address:

    - WARN  | [PINRemoteImage/Core, PINRemoteImage/OSX, PINRemoteImage/WebP, and more...] xcodebuild:  /Users/runner/work/PINRemoteImage/PINRemoteImage/Source/Classes/AnimatedImages/PINAnimatedImageView.m:226:15: warning: unused variable 'frameRate' [-Wunused-variable]
29

And I'll merge?

@bdolman
Copy link
Contributor Author

bdolman commented Oct 6, 2020

@garrettmoon Sure thing. I would like to move the frameRate calculation closer to its use, like this:

#if PIN_TARGET_IOS
        if (@available(iOS 10.0, tvOS 10.0, *)) {
            // Convert from display link fractional value to fps (note: frameInterval is always at least 1)
            NSInteger frameRate = ceil([PINAnimatedImage maximumFramesPerSecond] / ((double) frameInterval));
            _displayLink.preferredFramesPerSecond = frameRate;
        } else {
#endif

Rather than doing the calculation up above when it might not be used, but I was concerned about this comment:

// Get frame interval before holding display link lock to avoid deadlock
    NSUInteger frameInterval = self.animatedImage.frameInterval;

I didn't know if I risked creating a deadlock by doing it after referencing the display link. Do you know if that would be safe?

@garrettmoon
Copy link
Collaborator

Ah! Please remove that comment, I believe it copy-pasta'd it from the version I wrote in Texture. It's not relevant here since this class is designed to access the displayLink only on main.

@bdolman
Copy link
Contributor Author

bdolman commented Oct 6, 2020

Perfect! I'll address that now.

Also remove an obsolete comment warning about a lock (does not apply)
@bdolman
Copy link
Contributor Author

bdolman commented Oct 6, 2020

I'm not sure why the testResumeSkipCancelation test failed, since it succeeded for me locally.

@garrettmoon
Copy link
Collaborator

I'm not sure why the testResumeSkipCancelation test failed, since it succeeded for me locally.

Seems to be flakey, I'll rerun.

@garrettmoon garrettmoon merged commit 495c6dc into pinterest:master Oct 6, 2020
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.

GIF playback is slow/broken
2 participants