Messagekit: Crash trying to activate the keyboard

Created on 28 Mar 2018  Â·  10Comments  Â·  Source: MessageKit/MessageKit

General Information

  • MessageKit Version: 0.13.2

  • iOS Version(s): 11.x, 10.x

  • Swift Version: 4

What happened?

Always when I call messageInputBar.inputTextView.becomeFirstResponder() to activate the keyboard on viewDidAppear(), I got a crash in

public func scrollToBottom(animated: Bool = false) {
        let collectionViewContentHeight = collectionViewLayout.collectionViewContentSize.height
        performBatchUpdates(nil) { _ in
            self.scrollRectToVisible(CGRect(0.0, collectionViewContentHeight - 1.0, 1.0, 1.0), animated: animated)
        }
    }

with this error stack
API error: <_UIKBCompatInputView: 0x139615760; frame = (0 0; 0 0); layer = <CALayer: 0x139615b90>> returned 0 width, assuming UIViewNoIntrinsicMetric API error: <_UIKBCompatInputView: 0x139615760; frame = (0 0; 0 0); layer = <CALayer: 0x139615b90>> returned 0 width, assuming UIViewNoIntrinsicMetric *** Assertion failure in -[MessageKit.MessagesCollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3698.34.4/UICollectionView.m:6011
I notice this happens only when I have one message

What did you expect to happen?

The keyboard open when I enter in the viewController

bug? question

All 10 comments

@BrenoVin , Could you provide backtrace stack and can reproduce in Example project? The error you posted is maybe Apple Internal error,see SR-5484

captura de tela 2018-04-03 as 12 11 47

`â–¿ 43 elements

  • 0 : "0 ??? 0x000000010af4ca10 0x0 + 4478781968"
  • 1 : "1 ??? 0x000000010af4cae4 0x0 + 4478782180"
  • 2 : "2 Poppin 0x0000000100cbccc8 main + 0"
  • 3 : "3 Foundation 0x000000018220afa0 + 112"
  • 4 : "4 UIKit 0x000000018b535a50 + 12036"
  • 5 : "5 UIKit 0x000000018b532b38 + 92"
  • 6 : "6 UIKit 0x000000018b531cc4 + 388"
  • 7 : "7 UIKit 0x000000018b531b20 + 96"
  • 8 : "8 UIKit 0x000000018b531aa4 + 84"
  • 9 : "9 UIKit 0x000000018b531a3c + 64"
  • 10 : "10 MessageKit 0x00000001028ffb5c _T010MessageKit22MessagesCollectionViewC14scrollToBottomySb8animated_tF + 712"
  • 11 : "11 MessageKit 0x0000000102915cd8 _T010MessageKit22MessagesViewControllerC010handleTextD15DidBeginEditing33_3555E0073CC8D4FD362C981DBD790D42LLy10Foundation12NotificationVF + 520"
  • 12 : "12 MessageKit 0x0000000102915e28 _T010MessageKit22MessagesViewControllerC010handleTextD15DidBeginEditing33_3555E0073CC8D4FD362C981DBD790D42LLy10Foundation12NotificationVFTo + 84"
  • 13 : "13 CoreFoundation 0x00000001817acc3c + 20"
  • 14 : "14 CoreFoundation 0x00000001817ac1b8 + 428"
  • 15 : "15 CoreFoundation 0x00000001817abf14 + 216"
  • 16 : "16 CoreFoundation 0x000000018182984c + 1408"
  • 17 : "17 CoreFoundation 0x00000001816e2f38 _CFXNotificationPost + 384"
  • 18 : "18 Foundation 0x0000000182153bbc + 68"
  • 19 : "19 UIKit 0x000000018b66b820 + 144"
  • 20 : "20 UIKit 0x000000018b66a58c + 780"
  • 21 : "21 Poppin 0x0000000100c48eec _T06Poppin26MessagesRoomViewControllerC13viewDidAppearySbF + 768"
  • 22 : "22 Poppin 0x0000000100c49f48 _T06Poppin26MessagesRoomViewControllerC13viewDidAppearySbFTo + 64"
  • 23 : "23 UIKit 0x000000018b4767b8 + 840"
  • 24 : "24 UIKit 0x000000018b4d3c54 + 228"
  • 25 : "25 UIKit 0x000000018b4a96e4 + 1272"
  • 26 : "26 UIKit 0x000000018b735bf0 + 252"
  • 27 : "27 UIKit 0x000000018b3e5c04 + 116"
  • 28 : "28 UIKit 0x000000018b7bea68 + 744"
  • 29 : "29 UIKit 0x000000018b3e57ac + 760"
  • 30 : "30 UIKit 0x000000018b3e5134 + 312"
  • 31 : "31 UIKit 0x000000018b4cf048 + 296"
  • 32 : "32 UIKit 0x000000018b4cf0e8 + 456"
  • 33 : "33 QuartzCore 0x00000001859a0774 + 284"
  • 34 : "34 libdispatch.dylib 0x0000000103f71220 _dispatch_client_callout + 16"
  • 35 : "35 libdispatch.dylib 0x0000000103f75db0 _dispatch_main_queue_callback_4CF + 1180"
  • 36 : "36 CoreFoundation 0x00000001817c3070 + 12"
  • 37 : "37 CoreFoundation 0x00000001817c0bc8 + 2272"
  • 38 : "38 CoreFoundation 0x00000001816e0da8 CFRunLoopRunSpecific + 552"
  • 39 : "39 GraphicsServices 0x00000001836c3020 GSEventRunModal + 100"
  • 40 : "40 UIKit 0x000000018b6c178c UIApplicationMain + 236"
  • 41 : "41 Poppin 0x0000000100cbcd14 main + 76"
  • 42 : "42 libdyld.dylib 0x0000000181171fc0 + 4"`

@BrenoVin , Thanks for your crash log, I fount that it is a uncaught exception, can you provide the exception name and reason part?

ex:

* Assertion failure in -[CollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3512.60.7/UICollectionView.m:4625 * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (76) must be equal to the number of items contained in that section before the update (70), plus or minus the number of items inserted or deleted from that section (5 inserted, 2 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'

Of course I can @zhongwuzw

captura de tela 2018-04-04 as 10 29 26

captura de tela 2018-04-04 as 10 29 10

*** Assertion failure in -[MessageKit.MessagesCollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3698.52.10/UICollectionView.m:6015

@BrenoVin , 😂, maybe I didn't state clearly, I mean uncaught exception's name and reason, ex:
image

Sorry @zhongwuzw 😞:

2018-04-04 21:27:34.551002-0300 Poppin[3447:844158] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the collection view after the update (2) must be equal to the number of sections contained in the collection view before the update (1), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'

@zhongwuzw did you can see this bug?

@BrenoVin This looks like a bit of a red herring to me. Can you show me how you're inserting new messages/sections and reloading your view?

@BrenoVin , sorry for my ignore. scrollTobottom method uses performBatchUpdates, it would leads to dataSource assertion. Refer to your log, the reason is the dataSource operation, can you post dataSource related code? or Example project can reproduce?

Thanks about the answers.. I was looking at my code and found some shit stuff 👎There's no problem/bug with the library.

thank's again! :D

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChandraPrakashJangid picture ChandraPrakashJangid  Â·  3Comments

nitrag picture nitrag  Â·  3Comments

yspreen picture yspreen  Â·  3Comments

Leon12345679 picture Leon12345679  Â·  3Comments

NiklasWilson picture NiklasWilson  Â·  4Comments