Skip to content

Conversation

@a1291762
Copy link
Contributor

The custom animation example suggests that a stack-allocated AnimationImplementation variable can be used, but this is incorrect. The variable is not copied and so must remain valid while the animation runs.

For brevity, I have used a static qualifier to give the variable global lifespan without making it an explicit global variable.

I have also added a note about the lifetime of the AnimationImplementation variable.

The API documentation is not clear, and following this example led me to a crashing app. I am seemingly not the only one that has had this happen. See https://stackoverflow.com/questions/35661791/pebble-how-to-create-a-custom-animation for the same problem (though it's not clear if they also based their code on the example).

Copy link
Contributor

@C-D-Lewis C-D-Lewis left a comment

Choose a reason for hiding this comment

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

This caught me a few times 👍

@FlynnD273
Copy link

I think you should make the animation variable static const as well, and move the animation call logic into a separate function (named something like init_and_start_animation) to clarify the scope a little better.

Copy link
Member

@Sorixelle Sorixelle left a comment

Choose a reason for hiding this comment

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

Looks good, just needs a Signed-off-by and it's good to go!

@a1291762
Copy link
Contributor Author

I think you should make the animation variable static const as well, and move the animation call logic into a separate function (named something like init_and_start_animation) to clarify the scope a little better.

If I'm going to do a larger change, it would include both creating and destroying the Animation* variable. Just making it static isn't very useful (and it's allocated on the heap, so it doesn't have the scope problems that AnimationImplmentation has).

@a1291762 a1291762 force-pushed the fix_animation_documentation branch from 889a2fc to 169b710 Compare November 27, 2025 03:00
@a1291762
Copy link
Contributor Author

I updated the example to be more "complete", and hopefully representitive of how people will actually use it.

The custom animation example suggests that a stack-allocated
AnimationImplementation variable can be used, but this is incorrect.
The variable is not copied and so must remain valid while the
animation runs.

Rework the example to use a global variable for the implementation.

Signed-off-by: Lincoln Ramsay <a1291762@gmail.com>
@a1291762 a1291762 force-pushed the fix_animation_documentation branch from 7065cff to 7e0a605 Compare December 3, 2025 02:13
@a1291762
Copy link
Contributor Author

a1291762 commented Dec 3, 2025

It turns out deleting animations is ... complicated?
An animation that has .teardown called doesn't need to be destroyed.
It seems that there is unschedule and destroy that ... need to be
called depending on if the animation has been scheduled yet?

None of the other examples cover destroying, so I've removed it from this one.

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.

4 participants