Status Update
Comments
ry...@google.com <ry...@google.com> #2
Branch: androidx-master-dev
commit fb1c82582399043b149eb2630f524c75de9c88dc
Author: Jelle Fresen <jellefresen@google.com>
Date: Thu Aug 15 11:34:36 2019
Disallow intercept, touch slop and canScroll in nestedPreScroll
* Disallow intercept (requestDisallowInterceptTouchEvent(true))
When scroll delta is consumed by dispatchNestedPreScroll, the parent
should be requested not to intercept subsequent touch events, just as
when scroll is consumed by the widget itself or dispatchNestedScroll.
* Touch slop
NestedScrollingChild implementations should only call
dispatchNestedPreScroll after the delta x/y has exceeded the touch slop.
* canScroll (canScrollHorizontally/canScrollVertically)
The dx/dy values passed to dispatchNestedPreScroll should be zero if the
child can't scroll in that direction.
Fixed in:
- RecyclerView
- NestedScrollView
Bug: 138668210
Bug: 139530818
Test: ./gradlew connectedCheck
Change-Id: I85b327ad096fbbd204adb92f630770ec7fad5990
M core/core/src/androidTest/java/androidx/core/widget/NestedScrollViewNestedScrollingChildTest.java
M core/core/src/main/java/androidx/core/widget/NestedScrollView.java
M recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewNestedScrolling3RequestDisallowInterceptTouchTest.java
M recyclerview/recyclerview/src/androidTest/java/androidx/recyclerview/widget/RecyclerViewNestedScrollingChildTest.java
M recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java
ap...@google.com <ap...@google.com> #3
Branch: androidx-main
commit ed0e0d25ef93ae87ee6e5910364d902d755b9330
Author: Ryan Mentley <ryanmentley@google.com>
Date: Tue Dec 13 00:20:00 2022
Temporarily re-attach temp-detached views for binding, add validation of various intended invariants
Test: Existing test suite should not fail with added invalidation (it does fail very hard without the fix)
Fixes: 258144648
Fixes: 265347515
Change-Id: I7244f2c749238c7241f36e57fdec155b1bea77cf
M recyclerview/recyclerview/src/main/java/androidx/recyclerview/widget/RecyclerView.java
hu...@google.com <hu...@google.com> #4
For AndroidX, the Design assumption violated.
in
As of 2023-03-06,
@Override
public final void onBindViewHolder(final @NonNull FragmentViewHolder holder, int position) {
final long itemId = holder.getItemId();
final int viewHolderId = holder.getContainer().getId();
final Long boundItemId = itemForViewHolder(viewHolderId); // item currently bound to the VH
if (boundItemId != null && boundItemId != itemId) {
removeFragment(boundItemId);
mItemIdToViewHolder.remove(boundItemId);
}
mItemIdToViewHolder.put(itemId, viewHolderId); // this might overwrite an existing entry
ensureFragment(position);
/** Special case when {@link RecyclerView} decides to keep the {@link container}
* attached to the window, but not to the view hierarchy (i.e. parent is null) */
final FrameLayout container = holder.getContainer();
if (ViewCompat.isAttachedToWindow(container)) {
if (container.getParent() != null) {
throw new IllegalStateException("Design assumption violated."); // <================ FAILS HERE
}
container.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
if (container.getParent() != null) {
container.removeOnLayoutChangeListener(this);
placeFragmentInViewHolder(holder);
}
}
});
}
gcFragments();
}
The error has shown up
I don't know whether the original AndroidX was making bad assumptions on Android, or that
Note that this is impacting Chrome autoroll for AndroidX (
hu...@google.com <hu...@google.com> #5
Hmm I cannot CC jgielzak@ (but I can still add comment?!). Pinging him directly instead.
ry...@google.com <ry...@google.com> #6
It looks like this code in ViewPager2 is a workaround for the bug that's fixed in this change.
Specifically, it looks to be working around the fact that onBindViewHolder
was previously called with temporarily detached views, and using this listener to wait for it to be properly attached so that it can perform operations that rely on it being properly attached.
The previous state was bad precisely because it forced hacky workarounds like this due to the lack of a proper way to listen for changes in temp-detached state (there are listeners, but they don't work, and would likely require changes in both RecyclerView and framework to make them work...it's a very flawed design). Until seeing this workaround, I wasn't aware it was even possible at all to figure it out (and even this has some limitations that probably aren't really relevant to VP2's use-case).
I think the correct solution here is to remove this workaround in ViewPager2 and release new RecyclerView and ViewPager2 versions in parallel to address this, with release notes advising users to upgrade. Jakub, what do you think?
(also, I think I vaguely recall hearing that it's possible to do some sort of Gradle module metadata thing where we can also add the information that VP2 should be at least a certain version if being used with a given RV version? I'm not sure if/how we could do that, though)
hu...@google.com <hu...@google.com> #7
Thanks for the explanation!
I'm wondering if there will be versioning issues re. Android platform support vs. AndroidX? (NVM, this is all AndroidX).
ap...@google.com <ap...@google.com> #8
Branch: androidx-main
commit e8d8836df99cf5e0d1d4bc318947d89d4103c569
Author: Ryan Mentley <ryanmentley@google.com>
Date: Wed Mar 08 18:26:56 2023
Ensure that ViewPager2 is on the latest version when used with an updated recyclerview
As discussed at
ViewPager2 had a workaround for that bug that now crashes when the bug is
not present. To fix this, we need to ensure that ViewPager2 is on a
version containing the corresponding fix in ViewPager2.
Bug: 265347515
Bug: 271618925
Test: None (TBD?)
Change-Id: I18a5140755c15a0c93e2647207152b679e463233
M recyclerview/recyclerview/build.gradle
ju...@google.com <ju...@google.com> #9
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.recyclerview:recyclerview:1.3.1-rc01
pr...@google.com <pr...@google.com> #10
The following release(s) address this bug.It is possible this bug has only been partially addressed:
androidx.recyclerview:recyclerview:1.4.0-alpha01
Description
Quoting Adam Powell on an internal issue: