TWTRTimelineViewController Possible bug with some tweet types?



Has anyone else noticed this?

I am using a TWTRTimelineViewController with version 1.15.2 of TwitterKit (Swift/iOS) and the app is crashing when loading some tweets.
It seems like a certain type of tweet is probably causing the crash because if I create a new application on a new device with only a Search timeline view controller the app crashes at the same point in the timeline.
If new tweets come in the app still crashes showing the same tweet further down the timeline. The first time I noticed the crash it was the 4th tweet so it crashed right away. Now it’s 50 or more down so i have to scroll down a bit before the crash.

If I load up an old version with TwitterKit (not sure what the number is maybe 1.13) I am able to scroll past where the offending tweet is. In two different cases it’s images which is the next visible tweet after where it would have crashed. But other images had loaded fine previously in the Timeline.

I setup an app with no other code than the default SearchTimelineViewController and I see the same issue.

Here is the full crashlog:

*** Terminating app due to uncaught exception ‘NSRangeException’, reason: ‘*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray’
*** First throw call stack:
0 CoreFoundation 0x000000010b163e65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010d7bddeb objc_exception_throw + 48
2 CoreFoundation 0x000000010b112395 -[__NSArray0 objectAtIndex:] + 101
3 trial 0x000000010a7cc435 +[TWTRViewUtil bestMatchSizeFromMediaEntity:fittingWidth:] + 363
4 trial 0x000000010a796f8d -[TWTRMediaEntityDisplayConfiguration initWithMediaEntity:targetWidth:] + 112
5 trial 0x000000010a7cb0ca -[TWTRTweetImageView configureWithMediaEntity:style:widthHint:] + 176
6 trial 0x000000010a7cbccd -[TWTRTweetMediaView configureWithMediaEntity:style:widthHint:] + 137
7 trial 0x000000010a7c7d30 -[TWTRTweetView configureWithTweet:] + 1684
8 trial 0x000000010a7bc1be -[TWTRTweetTableViewCell configureWithTweet:] + 79
9 trial 0x000000010a7a2f8f -[TWTRTimelineViewController tableView:cellForRowAtIndexPath:] + 223
10 UIKit 0x000000010c3f3e43 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 766
11 UIKit 0x000000010c3f3f7b -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 74
12 UIKit 0x000000010c3c8a39 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2996
13 UIKit 0x000000010c3fd01c -[UITableView _performWithCachedTraitCollection:] + 92
14 UIKit 0x000000010c3e3edc -[UITableView layoutSubviews] + 224
15 UIKit 0x000000010c3514a3 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
16 QuartzCore 0x000000010bf6a59a -[CALayer layoutSublayers] + 146
17 QuartzCore 0x000000010bf5ee70 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
18 QuartzCore 0x000000010bf5ecee _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
19 QuartzCore 0x000000010bf53475 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
20 QuartzCore 0x000000010bf80c0a _ZN2CA11Transaction6commitEv + 486
21 QuartzCore 0x000000010bf8f9f4 _ZN2CA7Display11DisplayLink14dispatch_itemsEyyy + 576
22 CoreFoundation 0x000000010b0c3c84 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20
23 CoreFoundation 0x000000010b0c3831 __CFRunLoopDoTimer + 1089
24 CoreFoundation 0x000000010b085241 __CFRunLoopRun + 1937
25 CoreFoundation 0x000000010b084828 CFRunLoopRunSpecific + 488
26 GraphicsServices 0x000000010fce0ad2 GSEventRunModal + 161
27 UIKit 0x000000010c29a610 UIApplicationMain + 171
28 trial 0x000000010a7598ad main + 109
29 libdyld.dylib 0x000000010e2cf92d start + 1
30 ??? 0x0000000000000001 0x0 + 1
libc++abi.dylib: terminating with uncaught exception of type NSException


Hi, thanks for the report!

Could you buy chance share the Tweet which is crashing?


I am not a 100% sure that this is the tweet because I am not sure if maybe it’s loading more than the next tweet but when I switch back to v1.13.1 this is the next tweet:

This is using a searchViewController for #DWTS

Using a TimelineListViewController for this list: DancingABC -> lists -> season-22
on v1.13.1 this is the next tweet that is displayed:

So with v1.15.2 these are the last tweets that display correctly, if I try to scroll at all to see the next cell the app crashes:
Search DWTS:
can’t post more links… DWTSGossip -> 708005951945646080

can’t post more links… ralphmacchio -> 707211857828954112


Maybe gifs are a part of it?
This tweet crashed it which should have showed up as a retweet in the list timeline view:

if I change to the sample code for displaying static tweets and only put single ID’s in it also crashes with a similar error.


Thanks again for the reports. This was an issue with the image selection when the largest image was smaller than 300 pixels.

I’ve implemented a fix and release a 1.15.3 minor version. You can test with this Tweet ID to confirm you have the latest version: 708394322140377088