epoxy icon indicating copy to clipboard operation
epoxy copied to clipboard

Can only call this when inside the `buildModels` method ?

Open chihung93 opened this issue 3 years ago • 1 comments

Hello everyone, I am facing a problem with my chat application.

Epoxy: 4.2.0

Reported from Firebase crashlytics

Fatal Exception: com.airbnb.epoxy.IllegalEpoxyUsage
Can only call this when inside the `buildModels` method

com.airbnb.epoxy.EpoxyController.assertIsBuildingModels (EpoxyController.java:463)
com.airbnb.epoxy.EpoxyController.addInternal (EpoxyController.java:510)
com.airbnb.epoxy.EpoxyModel.addTo (EpoxyModel.java:350)

I have used RxKotlin with 2 threads ( IO and Main Thread ) for calling update Models ( requestModelBuild or requestDelayedModelBuild(delayMs) )

Case 1: 
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())

Case 2
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())

I have called cancelPendingModelBuild() before requestModelBuild or requestDelayedModelBuild(delayMs)

private fun requestBuild(delayMs: Int = 0) {
       cancelPendingModelBuild()
       try {
           if (!isBuildingModels) {
               if (delayMs <= 0) {
                   requestModelBuild()
               } else {
                   requestDelayedModelBuild(delayMs)
               }
           }
       } catch (e: Exception) {
           Timber.e(e)
       }
   }

How to resolve this fatal/crash in Epoxy ?

chihung93 avatar Sep 20 '21 05:09 chihung93

Have you solved it?

dev-weiqi avatar Jul 12 '22 07:07 dev-weiqi