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

Add support for observers for macOS #2

Closed
tfmart opened this issue Aug 18, 2022 · 4 comments
Closed

Add support for observers for macOS #2

tfmart opened this issue Aug 18, 2022 · 4 comments
Labels
good first issue Good for newcomers

Comments

@tfmart
Copy link
Owner

tfmart commented Aug 18, 2022

Currently, the Mac version of LottieView do not support observation of the current progress/frame rate of an animation. For the iOS counterpart, I'm using CADisplayLink to observe the animation, but unfortunately it's not available on AppKit.

If anyone has any suggestion on how I could keep track of the animation's progress on macOS, feel free to let me know! You're also welcome to contribute with a pull request with your implementation if you're feeling extra generous.

Thanks for your help!

@tfmart tfmart added the good first issue Good for newcomers label Aug 18, 2022
@Psli
Copy link

Psli commented Aug 27, 2022

@tfmart
Copy link
Owner Author

tfmart commented Aug 30, 2022

Thanks for the suggestions @Psli! I'll give them a read later and see if I can work something out. Meanwhile, if you managed to get something working on your end with these, feel free to contribute with a pull request if you're feeling generous!

@tfmart
Copy link
Owner Author

tfmart commented Jan 30, 2023

I've got something working with CVDisplayLink, it's currently on the dev branch:
https://github.com/tfmart/LottieUI/blob/55d7ce4e2258484063d3d7cc2af2a926353537e8/Sources/LottieUI/macOS/AnimationProgressObserver%2BmacOS.swift

However, it seems that both this new solution for macOS and the current one for iOS with CADisplayLink doesn't seem to work with the new Core Animation engine introduced in Lottie 4.0. I'll attempt to take a second look at this issue at a later time, it might also be interesting to open a discussion or issue at Lottie's repo as well regarding this.

If you must use either the .onProgress or onFrame modifiers, it's required to use the main thread rendering engine, which can be done with the .renderingEngine modifier:

LottieView("MyAnimation")
    .renderingEngine(.mainThread)
    .onProgress { _ in
        // ...
    }

@tfmart
Copy link
Owner Author

tfmart commented Feb 17, 2023

I've just released v1.3.3 which includes the framerate/progress observers for macOS! However, there's an issue when using Lottie's new Core Animation rendering engine, for both iOS and macOS.

I'll be closing this issue since the observers are now available, and for further discussion about the rendering engine issues, I've opened issue #10 to do so

@tfmart tfmart closed this as completed Feb 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants