wordpress-mobile / WordPress-iOS

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

Media: Crash refreshing media library. #6030

Closed aerych closed 7 years ago

aerych commented 8 years ago

Caught this in the iOS 6s simulator when viewing the media library for a self-hosted blog. There were new items being synced from the blog. The list of thumbs started to refresh, I saw thumbs animate and reorder, I guess making room for a new thumb, then Xcode crashed.

When I tapped on the media library option it reported 10 items. When the crash occured after items reordered it looks like there are 12 counting one "blank" space.

simulator screen shot oct 3 2016 12 10 50 pm

Stacktrace:

2016-10-03 12:06:49.620 WordPress[2503:69964] *** Assertion failure in -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit-3599.6/UICollectionView.m:5392
2016-10-03 12:06:49.650 WordPress[2503:69964] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'attempt to perform an insert and a move to the same index path (<NSIndexPath: 0xc000000000c00016> {length = 2, path = 0 - 6})'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000113c0434b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000011366521e objc_exception_throw + 48
    2   CoreFoundation                      0x0000000113c08442 +[NSException raise:format:arguments:] + 98
    3   Foundation                          0x000000010dcd4edd -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
    4   UIKit                               0x000000010f5c3f9f -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:] + 7499
    5   UIKit                               0x000000010f5cf20a -[UICollectionView _endUpdatesWithInvalidationContext:tentativelyForReordering:animator:] + 71
    6   UIKit                               0x000000010f5cf54c -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:animator:] + 432
    7   UIKit                               0x000000010f5cf379 -[UICollectionView _performBatchUpdates:completion:invalidationContext:tentativelyForReordering:] + 91
    8   UIKit                               0x000000010f5cf2fb -[UICollectionView _performBatchUpdates:completion:invalidationContext:] + 74
    9   UIKit                               0x000000010f5cf250 -[UICollectionView performBatchUpdates:completion:] + 53
    10  WPMediaPicker                       0x00000001104ba268 __80-[WPMediaCollectionViewController updateDataWithRemoved:inserted:changed:moved:]_block_invoke.179 + 344
    11  UIKit                               0x000000010f5cf052 -[UICollectionView _updateAnimationDidStop:finished:context:] + 2084
    12  UIKit                               0x000000010f5ce58e __71-[UICollectionView _updateWithItems:tentativelyForReordering:animator:]_block_invoke_2 + 82
    13  UIKit                               0x000000010f5a2927 __47-[UICollectionViewAnimation startWithAnimator:]_block_invoke.225 + 295
    14  UIKit                               0x000000010ed23a9e -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 528
    15  UIKit                               0x000000010ecf6869 -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 222
    16  UIKit                               0x000000010ecf6dbe -[UIViewAnimationState animationDidStop:finished:] + 136
    17  QuartzCore                          0x000000010e6a29a8 _ZN2CA5Layer23run_animation_callbacksEPv + 316
    18  libdispatch.dylib                   0x0000000114ae00cd _dispatch_client_callout + 8
    19  libdispatch.dylib                   0x0000000114ac08d6 _dispatch_main_queue_callback_4CF + 406
    20  CoreFoundation                      0x0000000113bc84f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    21  CoreFoundation                      0x0000000113b8df8d __CFRunLoopRun + 2205
    22  CoreFoundation                      0x0000000113b8d494 CFRunLoopRunSpecific + 420
    23  GraphicsServices                    0x000000011666ea6f GSEventRunModal + 161
    24  UIKit                               0x000000010ec69f34 UIApplicationMain + 159
    25  WordPress                           0x000000010aea17de main + 62
    26  libdyld.dylib                       0x0000000114b2c68d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
aerych commented 8 years ago

After removing the blog, and adding it back I saw I had 13 items in the list. Also, the list is apparently haunted: https://cloudup.com/czT8FKz-UYM

aerych commented 8 years ago

Thinking back, I was trying to batch upload 5 images from the camera roll, then disabled wifi in the middle of the upload. Four of the images reported that the internet connection was unavailable, one did not. I assume the upload for the last one had not started. I re-enabled wifi and restarted the uploads for the four. The fifth was then showing a connection timed out message and I restarted it.

Wondering if the crash could be somehow related to the timeout.

kurzee commented 8 years ago

Looks like this is currently only in iOS 10 and is our top crash on Crashlytics.

kurzee commented 8 years ago

@SergioEstevao do you have any insight in to this crash? Since the crash has happened for a number of users, it seems there could be multiple cases of triggering a bad collection update.

SergioEstevao commented 8 years ago

@kurzee I can have a look it could be a bad thread use between the sync in Core Data and the updates in the collection view.

astralbodies commented 7 years ago

I'm been digging into this one further because the crashes continue to pile up. Primarily I think a bulk of the crashes are from calling reloadData in viewDidLoad since the VC itself will do that. May want to defer calling that until after the view appears. I also ran into a bunch of child threads crashing when the remote media library took a while to load and then you switched back to local media.

astralbodies commented 7 years ago

Still only in iOS 10 by the way.

astralbodies commented 7 years ago

Also reported in the Media Picker repo: https://github.com/wordpress-mobile/MediaPicker-iOS/issues/128

astralbodies commented 7 years ago

Closing as I believe this was fixed by #6735.