[epoxy-paging] Crash in the PagedListEpoxyController when trying to invoke `addTo` on a null model
See original GitHub issueWhile trying to implement paged list + paged controller, I run into a crash that’s not reliably reproducible. The crash seems to happen around 1 in 7 times, completely anecdotally.
I’m attaching the stack trace: note how my custom controller (that extends PagedListEpoxyController
) is not in the stack trace because the crash happens in PagedListEpoxyController
internals.
I will try to get a small sample app with a reliable reproducible test case. In the meantime, some information that could be useful:
- In
MyImplementationPagedListController
, I have these two params:modelBuildingHandler = EpoxyAsyncUtil.getAsyncBackgroundHandler()
diffingHandler = EpoxyAsyncUtil.getAsyncBackgroundHandler()
- I’m using an
RxPagedListBuilder
withsetFetchScheduler(Schedulers.io())
- The problem reproduces more frequently with a very small page size: I used size 4 on a total list size 22
I noticed that PagedListModelCache
holds null
models, I am guessing one of those is likely mistakenly being passed through in getModels()
.
java.lang.NullPointerException: Attempt to invoke virtual method 'void com.airbnb.epoxy.EpoxyModel.addTo(com.airbnb.epoxy.EpoxyController)' on a null object reference
at com.airbnb.epoxy.EpoxyController.add(EpoxyController.java:465)
at com.airbnb.epoxy.paging.PagedListEpoxyController.addModels(PagedListEpoxyController.kt:78)
at com.airbnb.epoxy.paging.PagedListEpoxyController.buildModels(PagedListEpoxyController.kt:70)
at com.airbnb.epoxy.EpoxyController$1.run(EpoxyController.java:267)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.os.HandlerThread.run(HandlerThread.java:61)
Issue Analytics
- State:
- Created 5 years ago
- Comments:23 (15 by maintainers)
Top Results From Across the Web
Advanced Pagination With Epoxy & Datasources • Kaan Köşe
First we need to implement a Datasource from the architecture components, which will help us later to load our data as a PagedList....
Read more >Timeline : try to get a better PagedList/Epoxy integration. Still ...
implementation "com.airbnb.android:epoxy-paging:$epoxy_version" ... Internally, it caches the model for each item in the [PagedList]. You should override.
Read more >Epoxy is an Android library for building ... - AndroidRepo
[epoxy-paging] Crash in the PagedListEpoxyController when trying to invoke `addTo` on a null model. While trying to implement paged list + ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@AdamMc331 That’s very likely as we only see crashes in controllers where we add additional models. However your proposed solution won’t work for us as the additional models we add can’t be delayed otherwise the screens get weird.
We are delaying the submitList instead. But this is just a band-aid. I’m not sure where to start to solve the race condition.
Yeah, that’s the reason why I made the attempt to use RxJava to check out whether it will crash or not after applying the hint from @rohandhruva . And it indeed turns out to be good.