Fixed
Status Update
Comments
du...@google.com <du...@google.com> #2
Note that RemoteMediator.load(LoadType.PREPEND, state)
isn't triggered by REFRESH
, but rather by a PagingSource.load
returning a page for PREPEND
or REFRESH
which has null
for prevKey
. Similar for APPEND
.
However the LoadState getting stuck on Loading definitely seems like a bug since a quick look at your app shows it persists through invalidate.
du...@google.com <du...@google.com>
ta...@gmail.com <ta...@gmail.com> #3
Maybe the word "trigger" was not fully appropriate in my initial post. However, what I meant is that a Refresh should be followed by an Append under the circumstances produced by the app under consideration, based on the Paging library docs and common sense. And as you can see, if that app uses version 3.0.0-alpha07 of the Paging library, the above statement does hold true in practice. So it looks like something is broken in the Paging library starting with version 3.0.0-alpha08 of it.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 3bafac069a856b0f6f226f88bac69b1fe95bebaf
Author: Dustin Lam <dustinlam@google.com>
Date: Mon Nov 23 23:14:12 2020
Allow remote to send NotLoading.Incomplete via LoadStateUpdate
Due to remote loads being completely async with local insert, it's no
longer possible to guarantee that local insert will finish after remote
load. This leads to situations where it's possible for remote load state
to get stuck in "Loading" state forever.
This change enables RemoteMediator to fire off LoadState events to
update to NotLoading.Incomplete, but comes with the caveat that
CombinedLoadState.mediator.refresh is now no longer
sufficient to check for displaying loadstate in UI as it may set
NotLoading before PagingSource.load finishes (and presents to the UI).
In previous versions this was worked around by resetting the Mediator
loadstate on new generations, but this is no longer accurate since those
calls don't necessarily get canceled.
Fixes: 173717820
Test: ./gradlew paging:paging-common:test
Change-Id: I2f1236fcb37777d059de3a53bbcd2a7aa038d479
M paging/common/src/main/kotlin/androidx/paging/PageEvent.kt
M paging/common/src/test/kotlin/androidx/paging/PageFetcherSnapshotTest.kt
M paging/common/src/test/kotlin/androidx/paging/RemoteMediatorAccessorTest.kt
https://android-review.googlesource.com/1509156
Branch: androidx-master-dev
commit 3bafac069a856b0f6f226f88bac69b1fe95bebaf
Author: Dustin Lam <dustinlam@google.com>
Date: Mon Nov 23 23:14:12 2020
Allow remote to send NotLoading.Incomplete via LoadStateUpdate
Due to remote loads being completely async with local insert, it's no
longer possible to guarantee that local insert will finish after remote
load. This leads to situations where it's possible for remote load state
to get stuck in "Loading" state forever.
This change enables RemoteMediator to fire off LoadState events to
update to NotLoading.Incomplete, but comes with the caveat that
CombinedLoadState.mediator.refresh is now no longer
sufficient to check for displaying loadstate in UI as it may set
NotLoading before PagingSource.load finishes (and presents to the UI).
In previous versions this was worked around by resetting the Mediator
loadstate on new generations, but this is no longer accurate since those
calls don't necessarily get canceled.
Fixes: 173717820
Test: ./gradlew paging:paging-common:test
Change-Id: I2f1236fcb37777d059de3a53bbcd2a7aa038d479
M paging/common/src/main/kotlin/androidx/paging/PageEvent.kt
M paging/common/src/test/kotlin/androidx/paging/PageFetcherSnapshotTest.kt
M paging/common/src/test/kotlin/androidx/paging/RemoteMediatorAccessorTest.kt
Description
Version used: 3.0.0-alpha08 or 3.0.0-alpha09
Devices/Android versions reproduced on: Samsung Galaxy S8 / Android 9
Starting with version 3.0.0-alpha08 of the Paging library, the MediatorResult.Success(false) value returned from a RemoteMediator.load(LoadType.REFRESH, state) call doesn’t trigger a RemoteMediator.load(LoadType.APPEND, state) call and doesn’t update PagingDataAdapter.loadStateFlow to notify that the refresh state has changed from LoadState.Loading to LoadState.NotLoading.
This bug can be reproduced by means of the following project, if you’ve changed the version of the Paging library it uses so that it’s equal to 3.0.0-alpha08 or 3.0.0-alpha09: