Skip to content

Commit

Permalink
anim: make SVGOMAnimatedRect.getUnderlyingValue() less prone to races
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosame committed Aug 6, 2024
1 parent 77573ea commit 6a886ef
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,13 @@ protected void updateAnimatedValue(AnimatableValue val) {
*/
@Override
public AnimatableValue getUnderlyingValue(AnimationTarget target) {
SVGRect r = getBaseVal();
return new AnimatableRectValue(target, r.getX(), r.getY(), r.getWidth(), r.getHeight());
// Make sure that baseVal exists
getBaseVal();

// Calling SVGOMRect.toArray() revalidates only once and narrows the possibility
// of a race condition.
float[] rect = baseVal.toArray();
return new AnimatableRectValue(target, rect[0], rect[1], rect[2], rect[3]);
}

/**
Expand Down

0 comments on commit 6a886ef

Please sign in to comment.