question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[epoxy-paging] Crash in the PagedListEpoxyController when trying to invoke `addTo` on a null model

See original GitHub issue

While 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 with setFetchScheduler(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:closed
  • Created 5 years ago
  • Comments:23 (15 by maintainers)

github_iconTop GitHub Comments

1reaction
kakai248commented, Dec 14, 2018

@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.

1reaction
TonyTangAndroidcommented, Nov 21, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found