DataGrid crashes when collapsing sections


#1

We are using a shinobi data grid with 7 sections to display our data. Since the grid doesn’t have a collapse all functionality, we wrote a loop to close each index. This seems to work fine as long as none of the sections have 13 or more items and you don’t scroll. If this happens, shinobi causes a crash. But this only happens after you scroll for a while. We have 1 section with over 900 items and 1 section with exactly 13. It fails if we don’t include the 900 items as well.

The code we use to collapse all:

  • (IBAction)collapseAll:(id)sender {
    for (int i = 0; i < self.shinobiDataGrid.numberOfSections; i++)
    [self.shinobiDataGrid setSectionAtIndex:i asCollapsed:YES];
    }

The stack trace from the console is:

From: <ShinobiGrid: 0x7fe91386c400; baseClass = UIScrollView; frame = (0 0; 294 292); clipsToBounds = YES; autoresize = W+H; autoresizesSubviews = NO; gestureRecognizers = <NSArray: 0x6040002574f0>; layer = <CALayer: 0x60400022eae0>; contentOffset: {0, 0}; contentSize: {718, 284}; adjustedContentInset: {0, 0, 0, 0}>
2017-10-26 12:15:24.535760-0400 GTMobile[10357:1634263] *** Terminating app due to uncaught exception ‘ShinobiGridsException’, reason: ‘The method -[ShinobiGrid assertSectionIndexValid:] cannot take an index that does not exist in the ShinobiGrid - section at index 9 does not exist in this ShinobiGrid.
From: <ShinobiGrid: 0x7fe91386c400; baseClass = UIScrollView; frame = (0 0; 294 292); clipsToBounds = YES; autoresize = W+H; autoresizesSubviews = NO; gestureRecognizers = <NSArray: 0x6040002574f0>; layer = <CALayer: 0x60400022eae0>; contentOffset: {0, 0}; contentSize: {718, 284}; adjustedContentInset: {0, 0, 0, 0}>’
*** First throw call stack:
(
0 CoreFoundation 0x000000010fcc61cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010f1e2f41 objc_exception_throw + 48
2 GTMobile 0x000000010a18f04d +[ShinobiGridLog fatalLogMessage:fromSource:] + 189
3 GTMobile 0x000000010a148f60 -[ShinobiGrid assertSectionIndexValid:] + 160
4 GTMobile 0x000000010a14940e -[ShinobiGrid sectionAtIndexIsCollapsed:] + 62
5 GTMobile 0x000000010a168b66 -[ShinobiGrid topRowNeedsAddedToVisibleGrid] + 374
6 GTMobile 0x000000010a16a90c -[ShinobiGrid removeRowsFromBottomAddToTopIfNeeded] + 1100
7 GTMobile 0x000000010a1674e6 -[ShinobiGrid tidyRowAndColEdges] + 150
8 GTMobile 0x000000010a154f66 -[ShinobiGrid reloadInternal:] + 486
9 GTMobile 0x000000010a1740ab -[SGridSection tidyAfterCollapseOrExpand] + 59
10 GTMobile 0x000000010a173f04 __60-[SGridSection collapseOrExpandProgrammatic:withCompletion:]_block_invoke.148 + 68
11 GTMobile 0x000000010a174b05 __39-[SGridSection collapseWithCompletion:]_block_invoke.213 + 85
12 UIKit 0x000000010c5bcc31 -[UIViewAnimationBlockDelegate _didEndBlockAnimation:finished:context:] + 859
13 UIKit 0x000000010c58f82d -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 354
14 UIKit 0x000000010c58fe6e -[UIViewAnimationState animationDidStop:finished:] + 293
15 QuartzCore 0x000000010bc35ad7 _ZN2CA5Layer23run_animation_callbacksEPv + 323
16 libdispatch.dylib 0x000000011175e43c _dispatch_client_callout + 8
17 libdispatch.dylib 0x00000001117696f0 _dispatch_main_queue_callback_4CF + 628
18 CoreFoundation 0x000000010fc88ef9 CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9
19 CoreFoundation 0x000000010fc4d662 __CFRunLoopRun + 2402
20 CoreFoundation 0x000000010fc4ca89 CFRunLoopRunSpecific + 409
21 GraphicsServices 0x00000001110f69c6 GSEventRunModal + 62
22 UIKit 0x000000010c4f923c UIApplicationMain + 159
23 GTMobile 0x0000000109f664e7 main + 151
24 libdyld.dylib 0x00000001117dad81 start + 1
25 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)


#2

Hi,
Just to let you know that our iOS dev team are investigating this ticket. We will be back in touch (via the ticket and this forum) when we have some further information for you.
Thanks,
Kai.


#3

Hi GST_Dev,

I’ve replied to your support ticket now, but in case it helps anyone else I’ll repeat my reply here.

It looks like the reported crash is caused by a bug in the shinobigrids framework. The bug has been logged but we don’t currently have an estimate on when it will be fixed.

There is a workaround, however: add the following call to the top of your collapseAll method:

[_grid setContentOffset:CGPointMake(0, 0)];

This scrolls back to the top of the grid before collapsing the sections, and avoids the call which causes the bug.

I hope that helps.

Kind regards,

Alison