MortimerGoro / MGSwipeTableCell

An easy to use UITableViewCell subclass that allows to display swippable buttons with a variety of transitions.
MIT License
6.97k stars 1.08k forks source link

[iOS 13] Crash in `hideSwipeOverlayIfNeeded` #334

Closed novkostya closed 4 years ago

novkostya commented 4 years ago

Our users report crashes on iOS 13 beta. See stacktrace below

Exception Type:  EXC_CRASH (SIGKILL)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note:  EXC_CORPSE_NOTIFY
Termination Reason: Namespace OBJC, Code 0x1
Triggered by Thread:  0

Thread 0 name:
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x00000001918fb870 __terminate_with_payload + 8
1   libsystem_kernel.dylib          0x00000001918fdf80 abort_with_payload_wrapper_internal + 136 (terminate_with_reason.c:76)
2   libsystem_kernel.dylib          0x00000001918fdef8 abort_with_reason + 32 (terminate_with_reason.c:86)
3   libobjc.A.dylib                 0x00000001918465f8 _objc_fatalv(unsigned long long, unsigned long long, char const*, char*) + 108 (objc-errors.mm:202)
4   libobjc.A.dylib                 0x000000019184658c _objc_fatal(char const*, ...) + 32 (objc-errors.mm:218)
5   libobjc.A.dylib                 0x0000000191842ac8 weak_register_no_lock + 320 (objc-weak.mm:418)
6   libobjc.A.dylib                 0x00000001918445cc objc_storeWeak + 336 (NSObject.mm:335)
7   UIKitCore                       0x0000000195ca60d4 -[UITableViewCell _tableView] + 268 (UITableViewCell.m:3866)
8   UIKitCore                       0x0000000195ca8900 -[UITableViewCell _selectedBackgroundView:] + 96 (UITableViewCell.m:4414)
9   UIKitCore                       0x0000000195ca1444 -[UITableViewCell _setSelectionStyle:selectionTintColor:] + 172 (UITableViewCell.m:2379)
10  MGSwipeTableCell                0x00000001032f32cc -[MGSwipeTableCell hideSwipeOverlayIfNeeded] + 252 (MGSwipeTableCell.m:925)
11  UIKitCore                       0x0000000195faa270 __UIViewWillBeRemovedFromSuperview + 284 (UIView.m:10702)
12  UIKitCore                       0x0000000195fa9ff8 -[UIView(Hierarchy) removeFromSuperview] + 96 (UIView.m:10798)
13  UIKitCore                       0x0000000195ca470c -[UITableViewCell removeFromSuperview] + 148 (UITableViewCell.m:3509)
14  UIKitCore                       0x0000000195f92eec -[UIView dealloc] + 396 (UIView.m:4525)
15  UIKitCore                       0x0000000195f37e80 -[UIScrollView dealloc] + 844 (UIScrollView.m:1308)
16  UIKitCore                       0x0000000195ce575c -[UITableView dealloc] + 368 (UITableView.m:5561)
17  libobjc.A.dylib                 0x0000000191844438 objc_release + 136 (objc-object.h:0)
18  CoreFoundation                  0x0000000191a54f64 __RELEASE_OBJECTS_IN_THE_ARRAY__ + 116 (NSCollectionAux.h:70)
19  CoreFoundation                  0x00000001919dfe74 -[__NSArrayM dealloc] + 172 (NSArrayM.m:473)
20  libobjc.A.dylib                 0x0000000191844438 objc_release + 136 (objc-object.h:0)
21  libobjc.A.dylib                 0x0000000191845a08 AutoreleasePoolPage::releaseUntil(objc_object**) + 184 (NSObject.mm:777)
22  libobjc.A.dylib                 0x00000001918458f4 objc_autoreleasePoolPop + 232 (NSObject.mm:1037)
23  UIKitCore                       0x0000000195f930b0 -[UIView dealloc] + 848 (UIView.m:4557)
24  libobjc.A.dylib                 0x0000000191844438 objc_release + 136 (objc-object.h:0)
25  libobjc.A.dylib                 0x0000000191845a08 AutoreleasePoolPage::releaseUntil(objc_object**) + 184 (NSObject.mm:777)
26  libobjc.A.dylib                 0x00000001918458f4 objc_autoreleasePoolPop + 232 (NSObject.mm:1037)
27  CoreFoundation                  0x0000000191b1be68 _CFAutoreleasePoolPop + 32 (NSObject.m:790)
28  CoreFoundation                  0x0000000191a8539c __CFRunLoopRun + 1988 (CFRunLoop.c:3063)
29  CoreFoundation                  0x0000000191a848b0 CFRunLoopRunSpecific + 480 (CFRunLoop.c:3183)
30  GraphicsServices                0x000000019c05e534 GSEventRunModal + 108 (GSEvent.c:2246)
31  UIKitCore                       0x0000000195b24d34 UIApplicationMain + 1940 (UIApplication.m:4684)
32  R                               0x0000000100082564 main + 104 (main.m:16)
33  libdyld.dylib                   0x0000000191905764 start + 4
cokodude commented 4 years ago

Getting the same issue with our users in iOS 13

MortimerGoro commented 4 years ago

Thanks for the info. I'll look into it soon.

cokodude commented 4 years ago

Thank you! If it helps, here is an error message I get in the debugger:

objc[576]: Cannot form weak reference to instance (0x10806a800) of class UITableView. It is possible that this object was over-released, or is in the process of deallocation.

privezentsev commented 4 years ago

Getting same issues only on iOS 13

privezentsev commented 4 years ago

Managed to get temporary workaround We can hide swipe buttons on visible cells while tableView is moving from superview so buttons will be hidden before dealloc call on UITableView instance

public class MyTableViewSubclass: UITableView {

    public override func willMove(toSuperview newSuperview: UIView?) {
        super.willMove(toSuperview: newSuperview)
        if newSuperview == nil {
            visibleCells.forEach { (cell) in
                if let swipeCell = cell as? MGSwipeTableCell {
                    swipeCell.hideSwipe(animated: false)
                }
            }
        }
    }
}
privezentsev commented 4 years ago

Previous workaround seems to be not good enough because it can lead to other crashes on iOS 13 https://forums.developer.apple.com/thread/117537

joelmbell commented 4 years ago

Anyone have any info on how this was reproducible? We are seeing a small number of crash reports from iOS 13 beta users, but haven't been able to repro ourselves. We're still on 1.6.7.

novkostya commented 4 years ago

Anyone have any info on how this was reproducible? We are seeing a small number of crash reports from iOS 13 beta users, but haven't been able to repro ourselves. We're still on 1.6.7.

It happens when table view gets deallocated when there's a cell in swiped state. So try to

  1. Push a view controller into navigation stack
  2. Swipe a cell to make buttons visible
  3. Pop back
novkostya commented 4 years ago

Fixed in 1.6.9