Skip to content

View recycling - fix API access and disable when not possible#45484

Closed
tdn120 wants to merge 1 commit into
facebook:mainfrom
tdn120:export-D59827328
Closed

View recycling - fix API access and disable when not possible#45484
tdn120 wants to merge 1 commit into
facebook:mainfrom
tdn120:export-D59827328

Conversation

@tdn120
Copy link
Copy Markdown

@tdn120 tdn120 commented Jul 16, 2024

Summary:
Prior to Android SDK 28, there was no way to tell if a View's pivotX or pivotY were set. Unfortunately this breaks view recycling due to the default behavior of:

Thus even if we were to check for getPixotX() == 0, we wouldn't know if it was specifically set to 0 (making the pivot actually 0), or still just the default value. We'd then need to reset the pivot any time the width or height changed. View.resetPivot() was presumably added to fix this in API 28.

This diff adds nullability to prepareToRecycleView() so we can act accordingly - returning null if the view can't be recycled.

Also added a version check for setAnimationMatrix(), which is only available in 29+.

Changelog: [Internal]

Differential Revision: D59827328

Summary:
Prior to Android SDK 28, there was no way to tell if a View's pivotX or pivotY were set.  Unfortunately this breaks view recycling due to the default behavior of:
- `getPivotX()` and `getPivotY()` [initialize as 0](https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r81/libs/hwui/RenderProperties.h#643)
- As long as they haven't been set, [they actually default to width/2 and height/2](https://android.googlesource.com/platform/frameworks/base/+/android-8.1.0_r81/libs/hwui/RenderProperties.cpp#195).

Thus even if we were to check for `getPixotX() == 0`, we wouldn't know if it was specifically set to 0 (making the pivot actually 0), or still just the default value.  We'd then need to reset the pivot any time the width or height changed.  [`View.resetPivot()`](https://developer.android.com/reference/android/view/View#resetPivot%28%29) was presumably added to fix this in API 28.

This diff adds nullability to `prepareToRecycleView()` so we can act accordingly - returning null if the view can't be recycled.

Also added a version check for [`setAnimationMatrix()`](https://developer.android.com/reference/android/view/View#setAnimationMatrix%28android.graphics.Matrix%29), which is only available in 29+.

Changelog: [Internal]

Differential Revision: D59827328
@facebook-github-bot facebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. p: Facebook Partner: Facebook Partner labels Jul 16, 2024
@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request was exported from Phabricator. Differential Revision: D59827328

@facebook-github-bot
Copy link
Copy Markdown
Contributor

This pull request has been merged in b107248.

@react-native-bot
Copy link
Copy Markdown
Collaborator

This pull request was successfully merged by Thomas Nardone in b107248

When will my fix make it into a release? | How to file a pick request?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported Merged This PR has been merged. p: Facebook Partner: Facebook Partner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants