Fix potential NPE when checking transform identity with null startValue - #2690
Open
Nepomuk5665 wants to merge 1 commit into
Open
Nepomuk5665 wants to merge 1 commit into
Nepomuk5665 wants to merge 1 commit into
Conversation
The identity check methods in AnimatableTransformParser were accessing Keyframe.startValue without null checks, but startValue is annotated as @nullable and can be null in certain animation exports. This would cause a NullPointerException when: 1. For PointF values (anchorPoint, position): calling .equals() on null 2. For Float values (rotation, skew, skewAngle): auto-unboxing null to float 3. For ScaleXY values (scale): calling .equals() on null The existence of ensureValidRotationKeyframes() method that explicitly checks for null startValue demonstrates that null values are expected. This fix adds explicit null checks before accessing startValue in all identity check methods, treating null startValue as non-identity (which is the safe default behavior).
anandfresh
approved these changes
Jun 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes a potential NullPointerException in
AnimatableTransformParser.javawhen checking if transform values are identity transforms.The Bug
The identity check methods (
isAnchorPointIdentity,isPositionIdentity,isRotationIdentity,isScaleIdentity,isSkewIdentity,isSkewAngleIdentity) were accessingKeyframe.startValuewithout null checks, butstartValueis annotated as@NullableinKeyframe.java:This would cause a NullPointerException when:
PointFvalues (anchorPoint, position): calling.equals()on nullFloatvalues (rotation, skew, skewAngle): auto-unboxing null to floatScaleXYvalues (scale): calling.equals()on nullEvidence That Null Values Are Expected
The existence of
ensureValidRotationKeyframes()method in the same file explicitly checks for and handles nullstartValue:This demonstrates that null values can occur in practice from certain animation exports.
The Fix
Added explicit null checks before accessing
startValuein all identity check methods. IfstartValueis null, the transform is treated as non-identity, which is the safe default behavior that preserves the transform data in the parsed result.Testing
The fix is straightforward null-safety improvement. The behavior is:
startValueis null, returnfalse(not identity) instead of crashingstartValueis not null, behavior is unchanged