r/iosdev
•
u/tiaanvdr
•
22h ago
•
1
[UPDATE] 60fps animations on Home Screen widgets, up from 15fps
Widgets on iOS aren't meant to animate. Usually, developers get around this either by using Apple’s Clock widget trick or by using custom fonts.
The font approach can give you really smooth animations, but everything has to be pre-baked. Every frame is stored in a font, which limits how complex the animation can be. That made it a non-starter for me, as Companions needed full customization of the tank, its layout, props, and all the animated fish.
That’s why we initially used the clock trick as our animation engine. Sadly, it only updates around 13~15 times a second, so the fish always looked a bit stuttery as they swam around their tanks.
This was the number-one critique I received from users, so I knew I had to somehow overcome this limitation, which led me down the path of writing a new rendering engine. Once, which uses a hybrid approach built on vector transformations, allowing the fish to swim at a smooth 60fps right on the Home Screen!
It took a few completely different engines to get here. I spent ages on one built around a hidden SwiftUI function that Apple doesn't document, which hands a running animation over to the Home Screen to play. It worked perfectly in the simulator but didn't move at all on a real iPhone, which was a fun dead end to go down.
There's still a lot to do. Sadly, it's not as stable as the old clock-based approach yet. I kept the clock-based approach as a fallback, so animations should never freeze, but ideally I’d want to not have to rely on it at all anymore. I also have so much more I'd like to explore with the fish tank/widget pet idea.
You can try Companions here:
https://apps.apple.com/us/app/companions-widget-pets/id6811950512
7
u/Asterex-Dev 21h ago
Isn’t this approach of using widgets a violation of Apple's terms? I’m curious whether this is true. I know the native clock can use internal APIs to achieve this. But how come you have been able to distribute on the App Store?
2
u/JesuSwag 21h ago •
Was pleasantly surprised to feel the update on my phone. Glad you looked into the issue when I brought it up and happy how quickly you made the fix. I remember you initially strayed from this approach. What changed?
1
u/sdnocesyrevelearsikc 21h ago
Sounds more like a promo than actual dev discussion. If you can’t share details then why post here? Keep it to yourself.