Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

KVO crash introduced in 7.3.0 / 7.3.1 (JSQMessagesKeyboardController) #1631

Closed
nickdowell opened this issue Jun 2, 2016 · 4 comments
Closed
Labels
Milestone

Comments

@nickdowell
Copy link

This crash appears to have been introduced in release 7.3.0.
I cannot reproduce the crash with release 7.2.0.

An exception is thrown when the app loses focus, for example due to swiping down on an incoming SMS banner;

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x13803c8e0 of class UIInputSetHostView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x13818c690> (
<NSKeyValueObservance 0x13818c660: Observer: 0x137e1e630, Key path: frame, Options: <New: YES, Old: YES, Prior: NO> Context: 0x1008e9218, Property: 0x138076f20>
)'

(lldb) po 0x137e1e630
<JSQMessagesKeyboardController: 0x137e1e630>

(lldb) po 0x138076f20
<NSKeyValueUnnestedProperty: Container class: UIInputSetHostView, Key: frame, isa for autonotifying: NSKVONotifying_UIInputSetHostView, Key paths of directly and indirectly affecting properties: none>

(lldb) bt
* thread #1: tid = 0x30631e, 0x00000001822b7f48 libobjc.A.dylib`objc_exception_throw, queue = 'com.apple.main-thread', stop reason = breakpoint 1.1
  * frame #0: 0x00000001822b7f48 libobjc.A.dylib`objc_exception_throw
    frame #1: 0x0000000182c52cf8 CoreFoundation`+[NSException raise:format:] + 120
    frame #2: 0x00000001835a6d80 Foundation`NSKVODeallocate + 300
    frame #3: 0x00000001822d1ae8 libobjc.A.dylib`(anonymous namespace)::AutoreleasePoolPage::pop(void*) + 508
    frame #4: 0x00000001845f37b4 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 44
    frame #5: 0x00000001845f3618 FrontBoardServices`-[FBSSerialQueue _performNext] + 168
    frame #6: 0x00000001845f39c8 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 56
    frame #7: 0x0000000182c0909c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
    frame #8: 0x0000000182c08b30 CoreFoundation`__CFRunLoopDoSources0 + 540
    frame #9: 0x0000000182c06830 CoreFoundation`__CFRunLoopRun + 724
    frame #10: 0x0000000182b30c50 CoreFoundation`CFRunLoopRunSpecific + 384
    frame #11: 0x0000000184418088 GraphicsServices`GSEventRunModal + 180
    frame #12: 0x0000000187e1a088 UIKit`UIApplicationMain + 204
    frame #13: 0x00000001000ca2a0 Test App`main(argc=1, argv=0x000000016fdb7ae8) + 144 at main.m:37
    frame #14: 0x00000001826ce8b8 libdyld.dylib`start + 4
@jessesquires
Copy link
Owner

Thanks @nixxcode !

To clarify:

You have to receive a notification banner while JSQMessagesViewController is the top-most controller?

@nickdowell
Copy link
Author

@jessesquires that appears to be the case; in my scenario JSQMessagesViewController was being used to send an SMS that was then immediately delivered to the phone, swiping down on the banner then triggered the crash. Hope that helps!

@jessesquires
Copy link
Owner

jessesquires commented Jun 2, 2016

👍

Possible fixes here:

Maybe we listen for app did background/foreground to add/remove observers. This assumes that these notifications fire when interacting with a notification. (Not sure if that's the case)

Or maybe better, we simply resignFirstResponder on the textView

@nickdowell
Copy link
Author

This crash was introduced by commit b7f487c

Specifically, -[JSQMessagesKeyboardController jsq_didReceiveKeyboardDidShowNotification:] now looks for a UIInputSetHostView - this is the deallocated object that was identified in the exception.

Changing JSQMessagesKeyboardController's keyboardView property to strong fixes the crash for me.

@jessesquires jessesquires added this to the 7.3.2 milestone Jun 5, 2016
jessesquires added a commit that referenced this issue Jun 5, 2016
Slessi pushed a commit to preeo/JSQMessagesViewController that referenced this issue Aug 22, 2016
AndriyVasyk pushed a commit to BluechipSystems/JSQMessagesViewController that referenced this issue Dec 7, 2016
pcoltau added a commit to TeletronicsDotAe/JSQMessagesViewController that referenced this issue Apr 16, 2017
…iewController

* 'master' of https://github.com/jessesquires/JSQMessagesViewController: (86 commits)
  ImageOptim on assets (jessesquires#1845)
  update changelog and spec for 7.3.4
  Fix issue jessesquires#1583: Don't highlight cell outside message bubble (when long press) (jessesquires#1744)
  update changelog and version for 7.3.3
  Updated `canPerformAction:withSender:` in `JSQMessagesComposerTextView` to call super (jessesquires#1664). Fixes jessesquires#1663.
  Update CHANGELOG and version nums for 7.3.2
  fix KVO crash. close jessesquires#1631
  formatting
  small fix regarding scrollToIndexPath (jessesquires#1642) close jessesquires#1640
  Update CHANGELOG.md
  update CHANGLOG. bump version numbers
  Reverted jessesquires#1588 to fix jessesquires#1602 and fix jessesquires#1604. (jessesquires#1623)
  bump version numbers
  Update CHANGELOG.md
  provide default init values for JSQMessagesCollectionViewLayoutAttributes to prevent assertion. fix jessesquires#1338
  follow up for jessesquires#1247 and jessesquires#1591. obfuscate private APIs. swizzle via +initialize
  copy attributes
  clean up
  fix keyboard hiding bug on iOS 9 (jessesquires#1307). fix jessesquires#1063
  - cleanup from PR jessesquires#1281 - fix menu actions, close jessesquires#1321 - make notification methods public - partially apply changes from PR jessesquires#1563
  ...
pcoltau added a commit to TeletronicsDotAe/JSQMessagesViewController that referenced this issue Apr 16, 2017
…nch3

* origin/master: (66 commits)
  ImageOptim on assets (jessesquires#1845)
  update changelog and spec for 7.3.4
  Fix issue jessesquires#1583: Don't highlight cell outside message bubble (when long press) (jessesquires#1744)
  update changelog and version for 7.3.3
  Updated `canPerformAction:withSender:` in `JSQMessagesComposerTextView` to call super (jessesquires#1664). Fixes jessesquires#1663.
  Update CHANGELOG and version nums for 7.3.2
  fix KVO crash. close jessesquires#1631
  formatting
  small fix regarding scrollToIndexPath (jessesquires#1642) close jessesquires#1640
  Update CHANGELOG.md
  update CHANGLOG. bump version numbers
  Reverted jessesquires#1588 to fix jessesquires#1602 and fix jessesquires#1604. (jessesquires#1623)
  bump version numbers
  Update CHANGELOG.md
  provide default init values for JSQMessagesCollectionViewLayoutAttributes to prevent assertion. fix jessesquires#1338
  follow up for jessesquires#1247 and jessesquires#1591. obfuscate private APIs. swizzle via +initialize
  copy attributes
  clean up
  fix keyboard hiding bug on iOS 9 (jessesquires#1307). fix jessesquires#1063
  - cleanup from PR jessesquires#1281 - fix menu actions, close jessesquires#1321 - make notification methods public - partially apply changes from PR jessesquires#1563
  ...
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants