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

BlogListDataSource: crash when logging out of app, after a while. #7206

Closed kurzee closed 4 years ago

kurzee commented 7 years ago

@koke there is a crash that randomly occurred to both me and @SergioEstevao while at our meetup here in Amsterdam. We've been unable to reproduce, but the stack points to BlogListDataSource.swift. I'm at a loss here for nailing this down, but perhaps you'll know a bit more.

To produce, each of us did the following:

  1. Opened up the latest WP internal 7.6.
  2. Tapped to the Me tab.
  3. Logged out > crash.
  4. Upon re-opening the app, a broken NUX was presented with a navbar. (a whole separate thing)
  5. Both of us had self-hosted sites added while logging out of our .com accounts.

The crash in the 7.6 internal build, and in Fabric as #33 is:

Crashed: com.apple.main-thread
0  WordPress                      0x10032d4bc specialized BlogListDataSource.tableView(UITableView, cellForRowAt : IndexPath) -> UITableViewCell (BlogListDataSource.swift)
1  WordPress                      0x100329ec8 @objc BlogListDataSource.tableView(UITableView, cellForRowAt : IndexPath) -> UITableViewCell (BlogListDataSource.swift)
2  UIKit                          0x18a3cb114 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 688
3  UIKit                          0x18a3cb32c -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
4  UIKit                          0x18a3b8a30 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2152
5  UIKit                          0x18a3d031c -[UITableView _performWithCachedTraitCollection:] + 120
6  UIKit                          0x18a16892c -[UITableView layoutSubviews] + 176
7  UIKit                          0x18a083158 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1200
8  QuartzCore                     0x187273274 -[CALayer layoutSublayers] + 148
9  QuartzCore                     0x187267de8 CA::Layer::layout_if_needed(CA::Transaction*) + 292
10 UIKit                          0x18a0978f0 -[UIView(Hierarchy) layoutBelowIfNeeded] + 548
11 UIKit                          0x18a13e558 -[UINavigationController _layoutViewController:] + 1244
12 UIKit                          0x18a13bdd4 -[UINavigationController _layoutTopViewController] + 228
13 UIKit                          0x18a154b84 -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 744
14 UIKit                          0x18a154860 -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 420
15 UIKit                          0x18a154430 -[UINavigationTransitionView _cleanupTransition] + 608
16 UIKit                          0x18a0be4f8 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
17 UIKit                          0x18a0bc6a4 +[UIViewAnimationState popAnimationState] + 320
18 UIKit                          0x18a147c6c -[UINavigationTransitionView transition:fromView:toView:] + 1860
19 UIKit                          0x18a13dbf4 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2488
20 UIKit                          0x18a13cd00 -[UINavigationController _startDeferredTransitionIfNeeded:] + 856
21 UIKit                          0x18a408a88 -[UINavigationController _setViewControllers_7_0:transition:animated:operation:] + 3004
22 UIKit                          0x18a407af0 -[UINavigationController _setViewControllers:transition:animated:operation:] + 752
23 UIKit                          0x18a410a34 __57-[UINavigationController popToViewController:transition:]_block_invoke + 708
24 UIKit                          0x18a410d4c __57-[UINavigationController popToViewController:transition:]_block_invoke.1847 + 28
25 UIKit                          0x18a3f39a4 +[UIViewController _performWithoutDeferringTransitions:] + 128
26 UIKit                          0x18a157fe4 -[UINavigationController popToViewController:transition:] + 812
27 UIKit                          0x18a176a8c -[UINavigationController popToRootViewControllerWithTransition:] + 124
28 WordPress                      0x10017e978 -[BlogDetailsViewController handleDataModelChange:] (BlogDetailsViewController.m:944)
29 CoreFoundation                 0x183ef15ec __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
30 CoreFoundation                 0x183ef0d00 _CFXRegistrationPost + 400
31 CoreFoundation                 0x183ef0a7c ___CFXNotificationPost_block_invoke + 60
32 CoreFoundation                 0x183f5f7a8 -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1412
33 CoreFoundation                 0x183e3494c _CFXNotificationPost + 376
34 Foundation                     0x184946920 -[NSNotificationCenter postNotificationName:object:userInfo:] + 68
35 CoreData                       0x1862d77a0 -[NSManagedObjectContext(_NSInternalChangeProcessing) _createAndPostChangeNotification:deletions:updates:refreshes:deferrals:wasMerge:] + 1268
36 CoreData                       0x186250384 -[NSManagedObjectContext(_NSInternalChangeProcessing) _processRecentChanges:] + 1660
37 CoreData                       0x18624f124 -[NSManagedObjectContext save:] + 412
38 WordPress                      0x1000d3524 -[ContextManager internalSaveContext:] (ContextManager.m:312)
39 CoreData                       0x1862d2214 developerSubmittedBlockToNSManagedObjectContextPerform + 152
40 CoreData                       0x1862d20ec -[NSManagedObjectContext performBlockAndWait:] + 256
41 WordPress                      0x1000d246c -[ContextManager saveContextAndWait:] (ContextManager.m:145)
42 WordPress                      0x10017f808 -[AccountService removeDefaultWordPressComAccount] (AccountService.m:111)
43 WordPress                      0x10045c458 MeViewController.(confirmLogout() -> (ImmuTableRow) -> ()).(closure #1).(closure #1) (MeViewController.swift)
44 UIKit                          0x18a525678 -[UIAlertController _invokeHandlersForAction:] + 108
45 UIKit                          0x18a525f94 __85-[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:]_block_invoke.454 + 28
46 UIKit                          0x18a3d35ec -[UIPresentationController transitionDidFinish:] + 1316
47 UIKit                          0x18a3d6ddc __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 188
48 UIKit                          0x18a1aaa1c -[_UIViewControllerTransitionContext completeTransition:] + 116
49 UIKit                          0x18a0be9d0 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 492
50 UIKit                          0x18a0be4f8 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 312
51 UIKit                          0x18a0be314 -[UIViewAnimationState animationDidStop:finished:] + 160
52 QuartzCore                     0x18726f0d4 CA::Layer::run_animation_callbacks(void*) + 260
53 libdispatch.dylib              0x182e0e9a0 _dispatch_client_callout + 16
54 libdispatch.dylib              0x182e135e8 _dispatch_main_queue_callback_4CF + 996
55 CoreFoundation                 0x183f050c0 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
56 CoreFoundation                 0x183f02cdc __CFRunLoopRun + 1572
57 CoreFoundation                 0x183e32d94 CFRunLoopRunSpecific + 424
58 GraphicsServices               0x18589c074 GSEventRunModal + 100
59 UIKit                          0x18a0eb130 UIApplicationMain + 208
60 WordPress                      0x1000d3d54 main (main.m:11)
61 libdyld.dylib                  0x182e4159c start + 4

I also believe the source of this to similarly produce a 7.5 crash, in Fabric as #24610:

1  WordPress                      0x1000eeaf8 -[BlogListViewController tableView:editActionsForRowAtIndexPath:] (BlogListViewController.m:579)
2  UIKit                          0x18db8046c -[UITableView _swipeActionButtonsForRowAtIndexPath:] + 124
3  UIKit                          0x18db803cc -[UITableView _swipeActionButtons] + 92

Scratching my head here points to a nil blog at: https://github.com/wordpress-mobile/WordPress-iOS/blob/develop/WordPress/Classes/ViewRelated/Blog/BlogListDataSource.swift#L293

@koke any ideas how a nil blog could be produced here if a blog were deleted (i.e. logged out)?

cc @aerych, @nheagy I'll create a separate issue for the NUX bug, which cannot be recovered from after force-quitting the app, only after reinstalling. šŸ˜¬

cc @astralbodies this would be an unrecoverable crash in 7.6 or earlier, given above.

koke commented 7 years ago

I can't reproduce either, but my partial guess at what's going on:

My guess is that the problem happens if the second happens before the first, and the blog list tries to redraw cells for deleted blogs, before the data source gets a chance to reload its data.

I'm still not sure why the blog would be nil and not a faulted object, @astralbodies any ideas?

yaelirub commented 5 years ago

I think this issue still rarely occurs: https://sentry.io/share/issue/12b4173dfe0b48f58636f1f277403c1d/

aerych commented 5 years ago

I've noticed a crash similar to this when quickly logging out of the simulator (but not a device) after it launches. In the cases I've seen it appeared that the call to sync blogs was finishing after logging out. Basically:

I thought we had a separate issue opened for it but maybe I was just thinking of this one. šŸ¤”

designsimply commented 5 years ago

I noticed a crash after log out while beta testing 12.8 today (WP Internal 12.8.0.20190701).

Here are some possibly relevant lines from my app logs at the time of the crash. The part about autofill and Safari looks suspicious to me but I am not 100% sure it's related.

2019-07-08 14:25:11:613 Unable to unregister push for Device ID 30842580: Error Domain=NSURLErrorDomain Code=-999 "cancelled" UserInfo={NSErrorFailingURLStringKey=https://public-api.wordpress.com/rest/v1.1/devices/30842580/delete?locale=en, NSErrorFailingURLKey=https://public-api.wordpress.com/rest/v1.1/devices/30842580/delete?locale=en, _NSURLErrorRelatedURLSessionTaskErrorKey=(
    "LocalDataTask <AC36D6F2-6C08-47B4-8205-59A7F07336E0>.<89>"
), _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <AC36D6F2-6C08-47B4-8205-59A7F07336E0>.<89>, NSLocalizedDescription=cancelled}
2019-07-08 14:25:11:633 Could not sync sites: Optional(Error Domain=WordPressKit.WordPressComRestApiError Code=2 "An active access token must be used to query information about the current user." UserInfo={WordPressComRestApiErrorMessageKey=An active access token must be used to query information about the current user., NSLocalizedDescription=An active access token must be used to query information about the current user., WordPressComRestApiErrorCodeKey=authorization_required})
2019-07-08 14:25:19:805 Completed requesting shared web credentials
2019-07-08 14:25:19:805 Error requesting shared web credentials: Optional("The operation couldnā€™t be completed. (OSStatus error -909 - Autofill is not enabled in Safari settings)")
2019-07-08 14:25:31:334 <WordPress.WordPressAppDelegate: 0x280aff980> applicationWillResignActive(_:)
2019-07-08 14:25:33:373 <WordPress.WordPressAppDelegate: 0x280aff980> applicationDidBecomeActive(_:)
2019-07-08 14:25:44:147 <WordPress.WordPressAppDelegate: 0x280aff980> applicationWillResignActive(_:)
2019-07-08 14:25:44:902 <WordPress.WordPressAppDelegate: 0x280aff980> applicationDidEnterBackground(_:)
2019-07-08 14:26:02:678 <WordPress.WordPressAppDelegate: 0x280aff980> applicationWillEnterForeground(_:)
2019-07-08 14:26:02:697 App launched with authentication link
2019-07-08 14:26:03:056 Error while retrieving WordPressComOAuthKeychainServiceName token: Error Domain=SFHFKeychainUtilsErrorDomain Code=-2000 "(null)"
2019-07-08 14:26:03:056 Error while deleting WordPressComOAuthKeychainServiceName token: Error Domain=SFHFKeychainUtilsErrorDomain Code=-2000 "(null)"
2019-07-08 14:26:03:058 Error while deleting WordPressComOAuthKeychainServiceName token: Error Domain=SFHFKeychainUtilsErrorDomain Code=-25300 "(null)"

Tested with WP Internal 12.8.0.20190701 on iPhone 6S iOS 12.3.1.

designsimply commented 4 years ago

I tried replicating this crash using the following steps:

  1. Log in.
  2. Add a self-hosted site by going to My Sites > Switch Site > + > Add self-hosted site.
  3. Tap the Me tap.
  4. Log out.
  5. Repeat steps 1-4 a few more times (with our without step 2).

Result: no crash and the log out step always worked normally for me.

IMG_3602

Tested with WPiOS 14.4 App Store version and WP Internal 14.5.0.20200323 on iPhone 11 iOS 13.3.1.

fwiw, the only result that comes up in Sentry in a search for BlogListDataSource returned a crash which was recorded 4 times total for 2 different users in the past 90 days. I can't quite tell if it's the same crash though. See https://sentry.io/share/issue/d6934099caaa4eedb3cb80a07ff6771b/.

Because a lot has changed in the app since this was first filedā€”including the tool we are using to track crash reportsā€”and because I have been unable to replicate the crash in testing, I would like to close this issue and either re-open it if a new case comes up or let a new issue get created and track it in a new issue from that point on.