GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||
GeezerVison is showing github.com — Fix view indices with Android LayoutAnimation (attempt 2) by lnikkila · Pull Request #19775 · react/react-native Conversation
Contributor
This addresses the same issue as #18830 which was reverted since it didn’t handle When subview clipping is on, ReactViewGroup keeps track of its own children directly and accounts for the offset introduced by clipped views when calling ViewGroup methods that modify children. Instead of accounting for just clipped children (views with no parent), it should account for any children that aren’t in the ViewGroup which also includes children that are being transitioned. If you look at the ViewGroup source code, it explicitly retains the view parent until the transition finishes which caused the Test PlanI reproduced the earlier crash by enabling clipping in this test app and adding a “clear views” button that resets the state to an empty items array with an animation. Related PRsRelease Notes[ANDROID] [BUGFIX] [LayoutAnimation] - Removal LayoutAnimations no longer remove adjacent views as well in certain cases.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
janicduplessis
approved these changes
Contributor
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. Nice work, sorry about the delay reviewing this!
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
janicduplessis
approved these changes
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
facebook-github-bot
approved these changes
Contributor
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. janicduplessis is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. Fixes issue #11828 that causes layout animations for removed views to remove some adjacent views as well. This happens because the animated views are still present in the ViewGroup, which throws off subsequent operations that rely on view indices having updated. This issue was addressed in #11962, which was closed in favour of a more reliable solution that addresses the issue globally since it’s difficult to account for animated views everywhere. @janicduplessis recommended[0] handling the issue through ViewManager. Since API 11, Android provides `ViewGroup#startViewTransition(View)` that can be used to keep child views visible even if they have been removed from the group. ViewGroup keeps an array of these views, which is only used for drawing. Methods such as `ViewGroup#getChildCount()` and `ViewGroup#getChildAt(int)` will ignore them. I believe relying on these framework methods within ViewManager is the most reliable way to solve this issue because it also works if callers ignore ViewManager and reach into the native view indices and counts directly. [0]: #11962 (review)
|
There was an error while loading. Please reload this page.
|
@janicduplessis Rebased, if that helps. I noticed there was a three-way merge required for ReactViewGroup, so I went through the changes in master since and I don’t think there are any that would affect this. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
👍 Let's try landing it again @facebook-github-bot shipit |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@facebook-github-bot shipit |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
janicduplessis is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This pull request was closed by @lnikkila in 1f88a71. Once this commit is added to a release, you will see the corresponding version tag below the description at 1f88a71. If the commit has a single |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This change is getting reverted on master, as we found it to be the cause of the following exception when used in our own products: |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Summary: /cc janicduplessis mdvacca This addresses the same issue as react#18830 which was reverted since it didn’t handle `removeClippedSubviews` properly. When subview clipping is on, ReactViewGroup keeps track of its own children directly and accounts for the offset introduced by clipped views when calling ViewGroup methods that modify children. Instead of accounting for just clipped children (views with no parent), it should account for any children that aren’t in the ViewGroup which also includes children that are being transitioned. If you look at the ViewGroup source code, [it explicitly retains the view parent until the transition finishes](https://github.com/aosp-mirror/platform_frameworks_base/blob/oreo-release/core/java/android/view/ViewGroup.java#L5034-L5036) which caused the `getParent()` checks to pass, even though those views should be ignored. I added a new `isChildInViewGroup` method that handles both clipped and transitioning views to fix this. I reproduced the [earlier crash](react#18830 (comment)) by enabling clipping in [this test app](react#18830 (review)) and adding a “clear views” button that resets the state to an empty items array with an animation. - react#18830 [ANDROID] [BUGFIX] [LayoutAnimation] - Removal LayoutAnimations no longer remove adjacent views as well in certain cases. Pull Request resolved: react#19775 Differential Revision: D9105838 Pulled By: hramos fbshipit-source-id: 5ccb0957d1f46c36add960c0e4ef2a545cb03cbe
Summary: /cc janicduplessis mdvacca This addresses the same issue as react#18830 which was reverted since it didn’t handle `removeClippedSubviews` properly. When subview clipping is on, ReactViewGroup keeps track of its own children directly and accounts for the offset introduced by clipped views when calling ViewGroup methods that modify children. Instead of accounting for just clipped children (views with no parent), it should account for any children that aren’t in the ViewGroup which also includes children that are being transitioned. If you look at the ViewGroup source code, [it explicitly retains the view parent until the transition finishes](https://github.com/aosp-mirror/platform_frameworks_base/blob/oreo-release/core/java/android/view/ViewGroup.java#L5034-L5036) which caused the `getParent()` checks to pass, even though those views should be ignored. I added a new `isChildInViewGroup` method that handles both clipped and transitioning views to fix this. I reproduced the [earlier crash](react#18830 (comment)) by enabling clipping in [this test app](react#18830 (review)) and adding a “clear views” button that resets the state to an empty items array with an animation. - react#18830 [ANDROID] [BUGFIX] [LayoutAnimation] - Removal LayoutAnimations no longer remove adjacent views as well in certain cases. Pull Request resolved: react#19775 Differential Revision: D9105838 Pulled By: hramos fbshipit-source-id: 5ccb0957d1f46c36add960c0e4ef2a545cb03cbe
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.