xmartlabs/XLForm

Crash on XLFormTextFieldCell.m line 102

liraz opened this issue · 2 comments

liraz commented

Seems like memory for UITextfield delegate and target selector is not released.
Causing in the following crash:

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x198edbdac object_isClass + 16
1  Foundation                     0x19a784928 KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 68
2  Foundation                     0x19a7820bc NSKeyValueWillChangeWithPerThreadPendingNotifications.llvm.16432713543580414412 + 304
3  UIKitCore                      0x1c71a2934 -[UITextField setDelegate:] + 120
4  XLForm                         0x1021da718 -[XLFormTextFieldCell update] (XLFormTextFieldCell.m:102)
5  XLForm                         0x1021e2bd0 -[XLFormViewController configureCell:] (XLFormViewController.m:587)
6  XLForm                         0x1021e2b6c -[XLFormViewController updateFormRow:] (XLFormViewController.m:579)
7  XLForm                         0x1021e3134 -[XLFormViewController tableView:cellForRowAtIndexPath:] (XLFormViewController.m:616)
8  UIKitCore                      0x1c70ccde4 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 684
9  UIKitCore                      0x1c70cd32c -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
10 UIKitCore                      0x1c7098a04 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2256
11 UIKitCore                      0x1c70b68f0 -[UITableView layoutSubviews] + 140
12 UIKitCore                      0x1c734b7dc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1380
13 QuartzCore                     0x19e309b74 -[CALayer layoutSublayers] + 184
14 QuartzCore                     0x19e30eb2c CA::Layer::layout_if_needed(CA::Transaction*) + 324
15 QuartzCore                     0x19e26d44c CA::Context::commit_transaction(CA::Transaction*) + 340
16 QuartzCore                     0x19e29bd7c CA::Transaction::commit() + 608
17 UIKitCore                      0x1c6ecba3c _afterCACommitHandler + 256
18 CoreFoundation                 0x199c9c7cc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
19 CoreFoundation                 0x199c97460 __CFRunLoopDoObservers + 412
20 CoreFoundation                 0x199c97a00 __CFRunLoopRun + 1264
21 CoreFoundation                 0x199c971f0 CFRunLoopRunSpecific + 436
22 GraphicsServices               0x19bf10584 GSEventRunModal + 100
23 UIKitCore                      0x1c6ea2d40 UIApplicationMain + 212
24 EVgo                           0x100945e2c main (main.m:26)
25 libdyld.dylib                  0x199756bb4 start + 4

The KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED happens after few times of allocation and release of the XLForm rows.
and at some point the delegate still points to an older object and target listener is still there.

Hi @liraz could you make a pull request with that fix?

liraz commented

We had another similar crash that we can reproduce every day:

Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x234b03dac object_isClass + 16
1  Foundation                     0x2363ac928 KVO_IS_RETAINING_ALL_OBSERVERS_OF_THIS_OBJECT_IF_IT_CRASHES_AN_OBSERVER_WAS_OVERRELEASED_OR_SMASHED + 68
2  Foundation                     0x2363aa0bc NSKeyValueWillChangeWithPerThreadPendingNotifications.llvm.16432713543580414412 + 304
3  UIKitCore                      0x262dca934 -[UITextField setDelegate:] + 120
4  XLForm                         0x10409e668 -[XLFormTextFieldCell update] (XLFormTextFieldCell.m:105)
5  XLForm                         0x1040a6b08 -[XLFormViewController configureCell:] (XLFormViewController.m:593)
6  XLForm                         0x1040a6aa8 -[XLFormViewController updateFormRow:] (XLFormViewController.m:583)
7  XLForm                         0x1040a70e0 -[XLFormViewController tableView:cellForRowAtIndexPath:] (XLFormViewController.m:625)
8  UIKitCore                      0x262cf4de4 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 684
9  UIKitCore                      0x262cf532c -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
10 UIKitCore                      0x262cc0a04 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2256
11 UIKitCore                      0x262cde8f0 -[UITableView layoutSubviews] + 140
12 UIKitCore                      0x262f737dc -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1380
13 QuartzCore                     0x239f31b74 -[CALayer layoutSublayers] + 184
14 QuartzCore                     0x239f36b2c CA::Layer::layout_if_needed(CA::Transaction*) + 324
15 QuartzCore                     0x239e9544c CA::Context::commit_transaction(CA::Transaction*) + 340
16 QuartzCore                     0x239ec3d7c CA::Transaction::commit() + 608
17 UIKitCore                      0x262af3a3c _afterCACommitHandler + 256
18 CoreFoundation                 0x2358c47cc __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
19 CoreFoundation                 0x2358bf460 __CFRunLoopDoObservers + 412
20 CoreFoundation                 0x2358bfa00 __CFRunLoopRun + 1264
21 CoreFoundation                 0x2358bf1f0 CFRunLoopRunSpecific + 436
22 GraphicsServices               0x237b38584 GSEventRunModal + 100
23 UIKitCore                      0x262acad40 UIApplicationMain + 212
24 *****                           0x10285199c main (main.m:26)
25 libdyld.dylib                  0x23537ebb4 start + 4

As stated before, the viewDidDisappear is not called sometimes due to some weird release.
Currently we could reproduce this only on one device with ios 12.1.0.

I hope my fix will solve this.
pull request already contains this commit: #1045