Getting Objective-C exception thrown when reloading a ShinobiDataGrid in Xamarin


#1

I have a reoccuring issue in my application using Shinobi Controls but have been unable to isolate the root of the issue and the stack trace has not been very useful.  Hopefully someone here has either seem a similar issue or know more about what the cause of error could be.

In one of my ShinobiDataGrids, the users have the ability to filter their data which basically looks at the source data, clears the grid’s datalist and adds each item that fits the filter from the source to the datalist.  This works extremely well most of the time.  However, if they user has scrolled down several screens, and then filters, and exception is thrown on ShinobiDataGrid.Reload():

Objective-C exception thrown.  Name: Row Search Reason: Something went wrong when finding next row

MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.  Name: Row Search Reason: Something went wrong when finding next row  at at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper (intptr,intptr)  at ShinobiGrids.ShinobiDataGrid.Reload () [0x00000] in <filename unknown>:0  at IosGold.EmbeddedViewGrid.ApplyClientSideFilter () [0x0021d] in …

Based on the error, it looks like the error is caused by either the datagrid or its mapping with Xamarin, but it could easily be something that my code mangles early on and the grid just doesn’t know the proper way to report it.

Does anyone know what this error actually means?


#2

The problem only seems to occur when I have a very small amount of results (such as 2 or 3).

 15 results works fine.  Managed to collect more stack trace information; Looks like the error may be occuring in [ShinobiGrid findRowAfterRow:]  

 

mono-rt: 

Native stacktrace:

mono-rt: 0   IosGold                             0x003d167c mono_handle_native_sigsegv + 300

mono-rt: 1   IosGold                             0x003dd92a sigabrt_signal_handler + 122

mono-rt: 2   libsystem_platform.dylib            0x05c85deb _sigtramp + 43

mono-rt: 3   ???                                 0xffffffff 0x0 + 4294967295

mono-rt: 4   libsystem_sim_c.dylib               0x05ad99c9 abort + 127

mono-rt: 5   IosGold                             0x0055edb3 monotouch_unhandled_exception_handler + 291

mono-rt: 6   IosGold                             0x003d1eeb mono_invoke_unhandled_exception_hook + 91

mono-rt: 7   IosGold                             0x003d0edc mono_handle_exception_internal + 6620

mono-rt: 8   IosGold                             0x003cf4f9 mono_handle_exception + 41

mono-rt: 9   IosGold                             0x00367f39 mono_x86_throw_exception + 137

mono-rt: 10  ???                                 0x1012ae57 0x0 + 269659735

mono-rt: 11  IosGold                             0x0054e1e1 monotouch_exception_handler + 177

mono-rt: 12  CoreFoundation                      0x055b035d __handleUncaughtException + 749

mono-rt: 13  libobjc.A.dylib                     0x05777b8b _ZL15_objc_terminatev + 100

mono-rt: 14  libc++abi.dylib                     0x05958f60 _ZSt11__terminatePFvvE + 14

mono-rt: 15  libc++abi.dylib                     0x0595897d _ZN10__cxxabiv1L22exception_cleanup_funcE19_Unwind_Reason_CodeP17_Unwind_Exception + 0

mono-rt: 16  libobjc.A.dylib                     0x057779fc _ZL26_objc_exception_destructorPv + 0

mono-rt: 17  IosGold                             0x0011341a -[ShinobiGrid findRowAfterRow:] + 362

mono-rt: 18  IosGold                             0x00133361 -[ShinobiGrid bottomCellToBeAddedForCol:] + 129

mono-rt: 19  IosGold                             0x001337b6 -[ShinobiGrid addNewBottomRowToGrid] + 390

mono-rt: 20  IosGold                             0x00134408 -[ShinobiGrid removeRowsFromTopAddToBottomIfNeeded] + 1256

mono-rt: 21  IosGold                             0x0013188b -[ShinobiGrid tidyRowAndColEdges] + 187

mono-rt: 22  IosGold                             0x0011bd78 -[ShinobiGrid reloadInternal:] + 616

mono-rt: 23  IosGold                             0x00112f4e -[ShinobiGrid reload] + 62

mono-rt: 24  IosGold                             0x0015266a -[ShinobiDataGrid reload] + 202

#3

Hi Canderson,

Thanks for getting in touch!

Is there any chance you could manipulate one of the sample apps to replicate your crash and send that to us at info@shinobicontrols.com?

This would really help us identify the source of the issue.

Kind Regards,
Andrew Polkinghorn


#4
//
// ViewController.m
// DataGridDataSourceHelper
//
// Copyright (c) 2013 Scott Logic. All rights reserved.
//

#import "ViewController.h"
#import "PersonDataSource.h"
#import "PersonDataObject.h"

@implementation ViewController
{
    ShinobiDataGrid* _shinobiDataGrid;
    SDataGridDataSourceHelper* _datasourceHelper;
    NSMutableArray* _data;
    NSMutableArray* _allPersons;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [ShinobiDataGrids setLicenseKey:@"your license key"]; // TODO: add your trial license key here!
    
    // create a grid - with 50 pixel padding
    _shinobiDataGrid = [[ShinobiDataGrid alloc] initWithFrame:CGRectInset(self.view.bounds, 50, 50)];
    
    
    
    // add to the view
    [self.view addSubview:_shinobiDataGrid];
    
    // add a name column
    SDataGridColumn* surnameColumn = [[SDataGridColumn alloc] initWithTitle:@"Surname" forProperty:@"surname"];
    surnameColumn.width = @200;
    surnameColumn.sortMode = SDataGridColumnSortModeTriState;
    [_shinobiDataGrid addColumn:surnameColumn];
    
    // add a name column
    SDataGridColumn* forenameColumn = [[SDataGridColumn alloc] initWithTitle:@"Forename" forProperty:@"forename"];
    forenameColumn.width = @200;
    forenameColumn.sortMode = SDataGridColumnSortModeTriState;
    [_shinobiDataGrid addColumn:forenameColumn];
    
    // add an age column
    SDataGridColumn* ageColumn = [[SDataGridColumn alloc] initWithTitle:@"Age" forProperty:@"age"];
    ageColumn.sortMode = SDataGridColumnSortModeTriState;
    [_shinobiDataGrid addColumn:ageColumn];
    
    // create some data to populate the grid
    _data = [PersonDataSource generatePeople:50];
    
    _allPersons = [NSMutableArray new];
    [_allPersons addObjectsFromArray:_data];
    // create the helper
    _datasourceHelper = [[SDataGridDataSourceHelper alloc] initWithDataGrid:_shinobiDataGrid];
    
    // group by the 'surname-first-letter' property - which is a 'virtual' property. 
    _datasourceHelper.groupedPropertyKey = @"surname-first-letter";
    _datasourceHelper.groupedPropertySortOrder = SDataGridColumnSortOrderAscending;
    
    // set the delegate for the helper
    _datasourceHelper.delegate = self;
    
    // finally - supply the data to the helper
    _datasourceHelper.data = _data;
}

#pragma mark - SDataGridDataSourceHelperDelegate methods

- (void)dataGridDataSourceHelper:(SDataGridDataSourceHelper *)helper didUpdateSelectedItems:(NSArray *)selectedItems
{
    NSLog(@"Selected items: %@", _datasourceHelper.selectedItems);
}

- (id)dataGridDataSourceHelper:(SDataGridDataSourceHelper *)helper
         groupValueForProperty:(NSString *)propertyKey
              withSourceObject:(id)object
{
    // for the 'surname-first-letter' property, extract the first letter of the surname
    if ([propertyKey isEqualToString:@"surname-first-letter"])
    {
        PersonDataObject* person = (PersonDataObject*)object;
        return [person.surname substringToIndex:1];
    }
    
    // for any other property, return nil, which will result in the default behaviour being applied.
    return nil;
}

- (id)dataGridDataSourceHelper:(SDataGridDataSourceHelper *)helper
       displayValueForProperty:(NSString *)propertyKey
              withSourceObject:(id)object
{
    if ([propertyKey isEqualToString:@"age"])
    {
        PersonDataObject* person = (PersonDataObject*)object;
        return [NSString stringWithFormat:@"%@ yrs", person.age];
    }
    
    // for any other property, return nil, which will result in the default behaviour being applied.
    return nil;
}

#pragma mark - UIViewController methods
// < iOS6
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    if (interfaceOrientation==UIInterfaceOrientationPortrait ) {
        return YES;
    } else {
        return NO;
    }
}

// >= iOS6
- (BOOL)shouldAutorotate {
    return NO;
}


#pragma mark - UISearchBarDelegate - THIS DEMONSTRATES ERROR FOR ""

-(void) searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText{
    if (!searchText || ![searchText length]){
        [_data removeAllObjects];
        [_data addObjectsFromArray: _allPersons];
        NSLog(@"There are %lu items in _data",[_data count]);
        [_datasourceHelper reloadData];
        
    }else{
        NSPredicate * predicate = [NSPredicate predicateWithFormat:@"SELF.surname CONTAINS[cd] %@ or SELF.forename CONTAINS[cd] %@", searchText, searchText];
        [_data removeAllObjects];
        [_data addObjectsFromArray: [_allPersons filteredArrayUsingPredicate:predicate]];
        NSLog(@"There are %lu items in _data",[_data count]);
        [_datasourceHelper reloadData];
    }
}


@end

#5

#6

Add UISearchBar to XIB, wire delegate
Using sample code posted:

  1. Scroll Down to end of grid.  
  2. Search “Hi”

Same exception.  If you only search “Hi” without scrolling, no exception is thrown.  Searching “Hi” reduces the rowcount to 8 total.


#7

Per Andrew Polkinghorn: set the contentOffset of your grid to (0,0) before filtering.  Hopefully this resolves to the issue for you canderson.


#8

Hello, I’m getting the same exception, very annoying, I need to release a version for my client, but grid doesn’t work. I’m working in Xamarin, crash happens during focus in any text field.

Crash:

Row Search: Something went wrong when finding next row
	0 CoreFoundation 0x0755edf6 __exceptionPreprocess + 182
	1 libobjc.A.dylib 0x07930a97 objc_exception_throw + 44
	2 AbleMobile 0x0021160a -[ShinobiGrid findRowAfterRow:] + 362
	3 AbleMobile 0x00231551 -[ShinobiGrid bottomCellToBeAddedForCol:] + 129
	4 AbleMobile 0x002319a6 -[ShinobiGrid addNewBottomRowToGrid] + 390
	5 AbleMobile 0x002325f8 -[ShinobiGrid removeRowsFromTopAddToBottomIfNeeded] + 1256
	6 AbleMobile 0x00233788 -[ShinobiGrid manageTopAndBottomEdgeCells] + 648
	7 AbleMobile 0x0020d0e0 -[ShinobiGrid scrollViewDidScroll:] + 1776
	8 UIKit 0x0236ffdc -[UIScrollView(UIScrollViewInternal) _notifyDidScroll] + 64
	9 UIKit 0x0235a3b6 -[UIScrollView setContentOffset:] + 806
	10 AbleMobile 0x00206abb -[SGridLayer setContentInset:] + 363
	11 AbleMobile 0x0022ea3c -[ShinobiGrid animateLiquidLayerWithEdgeInsets:orKeyboardNotification:] + 620
	12 AbleMobile 0x0022e6e4 -[ShinobiGrid keyboardWillShow:] + 2756
	13 Foundation 0x01e5e929 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke + 40
	14 CoreFoundation 0x07529974 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 20
	15 CoreFoundation 0x0741761b _CFXNotificationPost + 3051
	16 Foundation 0x01e4df26 -[NSNotificationCenter postNotificationName:object:userInfo:] + 98
	17 UIKit 0x02a93446 -[UIInputWindowController postStartNotifications:withInfo:] + 396
	18 UIKit 0x02a94d9e __77-[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:]_block_invoke556 + 440
	19 UIKit 0x023452c6 +[UIView(UIViewAnimationWithBlocks) _setupAnimationWithDuration:delay:view:options:factory:animations:start:animationStateGenerator:completion:] + 494
	20 UIKit 0x02345611 +[UIView(UIViewAnimationWithBlocks) _animateWithDuration:delay:options:animations:start:completion:] + 110
	21 UIKit 0x0283cd35 -[UIInputViewAnimationStyle launchAnimation:afterStarted:completion:forHost:fromCurrentPosition:] + 199
	22 UIKit 0x02a94a58 -[UIInputWindowController moveFromPlacement:toPlacement:starting:completion:] + 1071
	23 UIKit 0x02a99932 -[UIInputWindowController setPlacement:starting:completion:] + 70
	24 UIKit 0x02a9914c -[UIInputWindowController setInputViewSet:] + 806
	25 UIKit 0x02836101 __64-[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:]_block_invoke1459 + 43
	26 UIKit 0x02a943af -[UIInputWindowController performOperations:withAnimationStyle:] + 56
	27 UIKit 0x02836006 -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 1242
	28 UIKit 0x028361df -[UIPeripheralHost(UIKitInternal) setInputViews:animated:] + 73
	29 UIKit 0x0283622b -[UIPeripheralHost(UIKitInternal) setInputViews:] + 68
	30 UIKit 0x0282e478 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 1803
	31 UIKit 0x02478e95 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 316
	32 UIKit 0x024781dc -[UIResponder becomeFirstResponder] + 562
	33 UIKit 0x0233ede0 -[UIView(Hierarchy) becomeFirstResponder] + 114
	34 UIKit 0x02b04ffb -[UITextField becomeFirstResponder] + 51
	35 UIKit 0x0270ae8f -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 200
	36 UIKit 0x0270d4b6 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2762
	37 UIKit 0x02700d27 _UIGestureRecognizerSendActions + 327
	38 UIKit 0x026ff5a4 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 561
	39 UIKit 0x027015ed -[UIGestureRecognizer _delayedUpdateGesture] + 60
	40 UIKit 0x02704f6a ___UIGestureRecognizerUpdate_block_invoke661 + 57
	41 UIKit 0x02704e2d _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
	42 UIKit 0x026f8d36 _UIGestureRecognizerUpdate + 3720
	43 UIKit 0x0231471b -[UIWindow _sendGesturesForEvent:] + 1356
	44 UIKit 0x0231557f -[UIWindow sendEvent:] + 769
	45 UIKit 0x022daaa9 -[UIApplication sendEvent:] + 242
	46 UIKit 0x022ea8de _UIApplicationHandleEventFromQueueEvent + 20690
	47 UIKit 0x022bf079 _UIApplicationHandleEventQueue + 2206
	48 CoreFoundation 0x074827bf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
	49 CoreFoundation 0x074782cd __CFRunLoopDoSources0 + 253
	50 CoreFoundation 0x07477828 __CFRunLoopRun + 952
	51 CoreFoundation 0x074771ab CFRunLoopRunSpecific + 443
	52 CoreFoundation 0x07476fdb CFRunLoopRunInMode + 123
	53 GraphicsServices 0x088b624f GSEventRunModal + 192
	54 GraphicsServices 0x088b608c GSEventRun + 104
	55 UIKit 0x022c2e16 UIApplicationMain + 1526
	56 ??? 0x16904e60 0x0 + 378556000
	57 ??? 0x16904c70 0x0 + 378555504
	58 ??? 0x16902fe8 0x0 + 378548200
	59 ??? 0x169025d8 0x0 + 378545624
	60 ??? 0x16902863 0x0 + 378546275
	61 AbleMobile 0x003b2cd5 mono_jit_runtime_invoke + 725
	62 AbleMobile 0x0045403f mono_runtime_invoke + 127
	63 AbleMobile 0x00459c11 mono_runtime_exec_main + 401
	64 AbleMobile 0x004599ba mono_runtime_run_main + 682
	65 AbleMobile 0x0030d49d mono_jit_exec + 93
	66 AbleMobile 0x00527485 monotouch_main + 2741
	67 AbleMobile 0x002b6545 main + 117
	68 libdyld.dylib 0x07c6eac9 start + 1

#9

Guys, anyone? Really stack with that issue.


#10

Thanks Matt,  I had put a temporary workaround in my code to deal with it and just now got a chance to revisit this. The solution you posted does indeed work for me.

INs, are you refreshing your table when a text field is selected?


#11

No, considering stakctrace the problem is in keyboardwillshow method. I have a hardware keyboard, and app work fine with plugged in keyboard.


#12

Hi INs,

Sorry to hear you are having issues with ShinobiGrids.

Is there any chance you could manipulate one of our sample apps that replicates your crash and send it to us at info@shinobicontrols.com?

If you could also provide the following information in your email it would really help us identify the source of your issue:

  • ShinobiGrids Version
  • Xamarin.iOS Version
  • Devices/iOS versions that produce the crash.

Kind regards,
Andrew Polkinghorn


#13

Hi INs,

Could you let us know what version of ShinobiGrids you are using and what version of iOS you’re seeing this issue on? This sounds like it could be related to a bug we’ve already fixed.

Also, if you could send in a cut down sample in to info@shinobicontrols.com we can take a look first hand and get back to you.

Best regards,
Jan Akerman


#14

Hi,

I’m using 2.7.2 on iOS 8.0. On iOS 8.1 i’m observing the same situation. Unfortunatelly can’t extract sample from working app :(. App is written using Xamarin.


#15

I’m encountering the same issue again on a different screen,  it might be similar to the bug INs is having as well.  I’m working on making a test project to isolate the problem, but it may take some time and I don’t know for certain I will be able accomplish it.

A brief explaination might help though.  I have a dynamically built screen that has a grid within a scrollview.  The grid takes up the top half of the screen.  Beneith the grid are some other components (including buttons and other grids.)  If there are multiple grids on the screen, and it is enough to make the scrollview contain a scrollbar, it seems that I get a crash when I try to edit a cell in the top grid. It works fine in the simulator, but crashes (hard) on hardware devices. ShouldBeginEditingCell is called and completes fine, but the crash hits before DidTapCell is called.

The error message is not very helpful:

MonoTouch.Foundation.MonoTouchException: Objective-C Exception thrown.
Name: Row Search
Reason: Something went wrong when finding next row

Is there any indication that more information on this issue has been found?


#16

I managed to recreate the crash in a sample project.  This one seems to crash in the simulator where my production error only occured on a physical device.  I’m emailed info@shinobicontrols.com with the project.  Hopefully we can find the solution to the issue.


#17

Hi Canderson,

We really appreciate you putting the the time into creating a sample application. We’ll take a look at the sample and get back to you in due course.

Thanks,
Jan


#18

Curious as to if any progress has been made in this investigation.  I tested it with the most recent charts library and the issue still exists.


#19

Hi Canderson,

We’ve taken a look at the sample project and we’ve managed to replicate it on our side. We plan to include a fix in Januaray in our next release. If you’ve got any questions before then, please feel free to get in touch and we’d be happy to help.

Thanks,
Jan Akerman