-
Notifications
You must be signed in to change notification settings - Fork 24.5k
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
[Native Animated] Support for animated tracking in native driver #17896
Changes from 1 commit
2a3055e
ea5353f
ada41b0
e149b17
9a34873
0590afa
9df5509
bfc6b58
c29611b
27f5d43
a64dbf6
e929b04
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ public void runAnimationStep(long frameTimeNanos) { | |
mFromValue = mAnimatedValue.mValue; | ||
} | ||
long timeFromStartMillis = (frameTimeNanos - mStartFrameTimeNanos) / 1000000; | ||
int frameIndex = (int) (timeFromStartMillis / FRAME_TIME_MILLIS); | ||
int frameIndex = (int) Math.round(timeFromStartMillis / FRAME_TIME_MILLIS); | ||
if (frameIndex < 0) { | ||
throw new IllegalStateException("Calculated frame index should never be lower than 0"); | ||
} else if (mHasFinished) { | ||
|
@@ -68,7 +68,7 @@ public void runAnimationStep(long frameTimeNanos) { | |
if (frameIndex >= mFrames.length - 1) { | ||
nextValue = mToValue; | ||
if (mIterations == -1 || mCurrentLoop < mIterations) { // looping animation, return to start | ||
mStartFrameTimeNanos = frameTimeNanos; | ||
mStartFrameTimeNanos = frameTimeNanos + ((long) FRAME_TIME_MILLIS) * 1000000L; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @axemclion @kmagiera I think this line could be the culprit. I guess it could be possible that mStartFrameTimeNanos is bigger than the curent clock time. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe this would be better as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember there was some other problem when I was setting it to -1 but can't remember what exactly. Will try that and send a new PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, ok I remember now, I didn't want There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Submitted it here: #18061 |
||
mCurrentLoop++; | ||
} else { // animation has completed, no more frames left | ||
mHasFinished = true; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this change needed? Does it match the iOS / JS implementation better like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to explain that in my PR description, you might have missed it as it is at the very end:
So basically because of unfortunate rounding here frames driver on android would always "play" first frame twice. This could also be seen in all the unit tests where we run update loop twice at the beginning for all the framedriver tests. I am also updating these in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this line is starting to cause IllegalStateException in apps-
Is there a reason why timeFromStartMills will be negative ? The exception seems to have started with this PR merged in