badoo / Chatto

A lightweight framework to build chat applications, made in Swift
MIT License
4.49k stars 596 forks source link

How to Solved Assertion failed: Invalid cell given to presenter issue #505

Open bhorvinayak opened 6 years ago

bhorvinayak commented 6 years ago

I populated API data on chat view controller. Not able to receive photo messages. When someone send a photo message then app crash in BaseMessagePresenter's configure cell function.

Error in line no 88 :Assertion failed: Invalid cell given to presenter issue

`

public final override func configureCell(_ cell: UICollectionViewCell, decorationAttributes: 

 ChatItemDecorationAttributesProtocol?) 

 {
    guard let cell1 = cell as? CellT else {
        assert(false, "Invalid cell given to presenter")
        return
    }

    guard let decorationAttributes = decorationAttributes as? ChatItemDecorationAttributes else {
        assert(false, "Expecting decoration attributes")
        return
    }

     print("print cell cellT  :\(type(of:cell1))")
    self.decorationAttributes = decorationAttributes
    self.configureCell(cell1, decorationAttributes: decorationAttributes, animated: false, additionalConfiguration: nil)
}`
AntonPalich commented 6 years ago

@bhorvinayak Can you check that message with a specific uid never changes it's type value? Currently, it's not supported.

bhorvinayak commented 6 years ago

@AntonPalich Yes I checked uid is a string type but still getting crash.

bhorvinayak commented 6 years ago

@AntonPalich and also getting warning Cast from 'UICollectionViewCell' to unrelated type 'BaseMessageCollectionViewCell' always fails on assigning cell as cellT type

  guard let cell1 = cell as? CellT else {
        assert(false, "Invalid cell given to presenter")
        return
}
bhorvinayak commented 6 years ago

@AntonPalich dynamic API text messages working fine but populating images create an issue. Otherwise it works Great and awesome, responsive.

AntonPalich commented 6 years ago

@bhorvinayak Could you post a full stack trace when assertion happens and your createPresenterBuilders function implementation? Also, check that all messages uid are unique.

bhorvinayak commented 6 years ago

screen shot 2018-08-07 at 6 37 48 pm

I never change anything from the createPresenter function also related class. Actually, I populated two images like stickers for 7-8 times. That's not unique. Is that reason behind crashing?