wordpress-mobile / WordPress-iOS

WordPress for iOS - Official repository
http://ios.wordpress.org/
GNU General Public License v2.0
3.69k stars 1.12k forks source link

My Site Dashboard: posts card always crash on iOS 13 and 14 #18224

Closed leandroalonso closed 2 years ago

leandroalonso commented 2 years ago

Expected behavior

The Dashboard should appear without any issues.

Actual behavior

The app crashes:

2022-03-28 10:40:19.535527-0300 WordPress[19823:112033] *** Assertion failure in -[_TtC9WordPressP33_802B839C3C12DC08AA85FBE243B5267217PostCardTableView _Bug_Detected_In_Client_Of_UITableView_Invalid_Number_Of_Sections:], /Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3920.31.102/UITableView.m:2439
2022-03-28 10:40:19.550078-0300 WordPress[19823:112033] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the table view after the update (1) must be equal to the number of sections contained in the table view before the update (1), plus or minus the number of sections inserted or deleted (1 inserted, 0 deleted).'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000128d77e6e __exceptionPreprocess + 350
    1   libobjc.A.dylib                     0x00000001289cf9b2 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000128d77be8 +[NSException raise:format:arguments:] + 88
    3   Foundation                          0x000000012276bbd2 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
    4   UIKitCore                           0x000000013c38d57e -[UITableView _Bug_Detected_In_Client_Of_UITableView_Invalid_Number_Of_Sections:] + 193
    5   UIKitCore                           0x000000013c38c692 -[UITableView _endCellAnimationsWithContext:] + 14516
    6   UIKitCore                           0x000000013c3a6aca -[UITableView endUpdatesWithContext:] + 112
    7   UIKitCore                           0x000000013c3a6c76 -[UITableView _performBatchUpdates:withContext:completion:] + 253
    8   UIKitCore                           0x000000013c3a6d8c -[UITableView performBatchUpdates:completion:] + 97
    9   UIKitCore                           0x000000013c3d5f4b -[UITableView _performDiffableUpdate:] + 43
    10  UIKitCore                           0x000000013b92cb7d -[_UIDiffableDataSourceViewUpdater _performUpdateWithCollectionViewUpdateItems:dataSourceSnapshotter:updateHandler:completion:] + 870
    11  UIKitCore                           0x000000013b925ab6 -[__UIDiffableDataSource _commitNewDataSource:withViewUpdates:completion:] + 246
    12  UIKitCore                           0x000000013b92049e __66-[__UIDiffableDataSource applyDifferencesFromSnapshot:completion:]_block_invoke.154 + 190
    13  UIKitCore                           0x000000013b92072d __66-[__UIDiffableDataSource applyDifferencesFromSnapshot:completion:]_block_invoke.180 + 107
    14  libdispatch.dylib                   0x000000012e755e8e _dispatch_client_callout + 8
    15  libdispatch.dylib                   0x000000012e764ae2 _dispatch_lane_barrier_sync_invoke_and_complete + 132
    16  UIKitCore                           0x000000013b91ffa7 -[__UIDiffableDataSource applyDifferencesFromSnapshot:completion:] + 952
    17  UIKitCore                           0x000000013b920fb9 -[__UIDiffableDataSource applyDifferencesFromSnapshot:animatingDifferences:completion:] + 71
    18  libswiftUIKit.dylib                 0x000000012e50aaf4 $s5UIKit34UICollectionViewDiffableDataSourceC5apply_20animatingDifferences10completionyAA010NSDiffableeF8SnapshotVyxq_G_SbyycSgtFTm + 212
    19  WordPress                           0x000000010100db53 $s9WordPress18PostsCardViewModelC10controller_20didChangeContentWithySo26NSFetchedResultsControllerCySo20NSFetchRequestResult_pG_So28NSDiffableDataSourceSnapshotCtF + 2515
    20  WordPress                           0x000000010100e487 $s9WordPress18PostsCardViewModelC10controller_20didChangeContentWithySo26NSFetchedResultsControllerCySo20NSFetchRequestResult_pG_So28NSDiffableDataSourceSnapshotCtFTo + 71
    21  CoreData                            0x00000001216ed0b5 -[NSFetchedResultsController(PrivateMethods) _conditionallyDispatchSnapshotToDelegate:] + 970
    22  CoreData                            0x00000001216e5072 -[NSFetchedResultsController performFetch:] + 317
    23  WordPress                           0x00000001010099a4 $s9WordPress18PostsCardViewModelC7refreshyyF + 212
    24  WordPress                           0x000000010051f7cd $s9WordPress23PostsCardViewControllerC13viewDidAppearyySbF + 637
    25  WordPress                           0x000000010051f822 $s9WordPress23PostsCardViewControllerC13viewDidAppearyySbFTo + 50
    26  UIKitCore                           0x000000013bb09807 -[UIViewController _setViewAppearState:isAnimating:] + 867
    27  UIKitCore                           0x000000013bb0bc65 __64-[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]_block_invoke + 42
    28  UIKitCore                           0x000000013bb0a8d5 -[UIViewController _executeAfterAppearanceBlock] + 75
    29  UIKitCore                           0x000000013c1b7cca _runAfterCACommitDeferredBlocks + 696
    30  UIKitCore                           0x000000013c1a8300 _cleanUpAfterCAFlushAndRunDeferredBlocks + 248
    31  UIKitCore                           0x000000013c1d8b09 _afterCACommitHandler + 85
    32  CoreFoundation                      0x0000000128cdb087 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    33  CoreFoundation                      0x0000000128cd5b3e __CFRunLoopDoObservers + 430
    34  CoreFoundation                      0x0000000128cd608a __CFRunLoopRun + 1226
    35  CoreFoundation                      0x0000000128cd58a4 CFRunLoopRunSpecific + 404
    36  GraphicsServices                    0x000000012f6f9bbe GSEventRunModal + 139
    37  UIKitCore                           0x000000013c1ae964 UIApplicationMain + 1605
    38  WordPress                           0x00000001013216eb main + 507
    39  ???                                 0x000000020c46851e 0x0 + 8795882782
    40  ???                                 0x000000020c463000 0x0 + 8795860992
)
libc++abi.dylib: terminating with uncaught exception of type NSException
terminating with uncaught exception of type NSException
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the table view after the update (1) must be equal to the number of sections contained in the table view before the update (1), plus or minus the number of sections inserted or deleted (1 inserted, 0 deleted).'
CoreSimulator 783.5 - Device: iPhone 11 (EEC1FC0B-B268-49FF-BFCE-D231F0EB5568) - Runtime: iOS 13.7 (17H22) - DeviceType: iPhone 11

Steps to reproduce the behavior

  1. Run the app on an iPhone with iOS 13.7
  2. Tap "Home"
  3. 💥 The app crashes
Tested on iPhone 11 simulator, iOS 13.7, WPiOS in trunk
leandroalonso commented 2 years ago

Tested on iOS 14.5 — same issue.