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

Updated Interpolation example and fix rare crash #411

Merged
merged 16 commits into from
Apr 20, 2022

Conversation

chrfalch
Copy link
Contributor

@chrfalch chrfalch commented Apr 19, 2022

To better support path interpolation use cases I updated the example to interpolate between paths when paths are changed - meaning that whenever we set a new path the component will animate between the previous and the new path. The example also supports interruptible animation.

Also fixed a bug in the runTiming function where the value.animation property was not reset when the animation finished.

Changes in this PR:

  • Removed mounting example, not very interesting
  • Added interpolation between new paths to better support use cases
  • Fixed bug with runTiming not releasing the animation value after it is done - which causes crashes in the native code after a while.

Fixes #414

- Removed mounting example, not very interesting
- Added interpolation between new paths to better support use cases
- Fixed bug with runTiming not releasing the animation value after it is done - which causes crashes in the native code after a while.
@@ -27,7 +27,11 @@ export const runTiming = (
callback?: AnimationCallback
): SkiaAnimation => {
const resolvedParameters = getResolvedParams(toOrParams, config);
const animation = createTiming(resolvedParameters, value, callback);
const resolvedCallback = (current: number) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

I appear to be able to reproduce the crash on iOS even on this branch, could that be? 🤔

wcandillon and others added 4 commits April 20, 2022 11:25
- Removed mounting example, not very interesting
- Added interpolation between new paths to better support use cases
- Fixed bug with runTiming not releasing the animation value after it is done - which causes crashes in the native code after a while.
@chrfalch chrfalch force-pushed the feature/updated-path-interpolation branch from dfc52f7 to f3ff1e6 Compare April 20, 2022 09:50
chrfalch and others added 5 commits April 20, 2022 11:50
… method on the JS thread.

Used the trick where we use shared_from_this() and pass it to the lambda to make sure we keep alive until the dispatch method is finished.

Also added automatic interpolation in demo to be able to reproduce error.

Also made destructors virtual since the class has virtual members.
@wcandillon wcandillon self-requested a review April 20, 2022 18:56
@wcandillon
Copy link
Contributor

very nice

// We need to stop/unsubscribe
stopClock();
}
virtual ~RNSkAnimation() {}
Copy link
Contributor

Choose a reason for hiding this comment

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

😅

@wcandillon wcandillon self-requested a review April 20, 2022 19:15
@chrfalch chrfalch merged commit e76041d into main Apr 20, 2022
@chrfalch chrfalch deleted the feature/updated-path-interpolation branch April 20, 2022 19:15
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.

Fix rare crash in animation value deallocation / race condition
2 participants