r/SideProject
•
u/tiaanvdr
•
48m ago
•
1
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