3

I have a uitableviewcontroller and im loading a uiwebview as viewForFooterInSection for the tableview

This webview has some html content being loaded. The app crashes whenever I try to do

[self.tableView beginUpdates];
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationTop];
    [self.tableView endUpdates];

Crash log attached

Incident Identifier: DA08DEDA-3566-4A56-938A-57F4BCDF64F1
CrashReporter Key:   ef8a5122f6b5431e4b29802596ec279644f97bd4
Hardware Model:      iPod4,1
Process:         sample [955]
Path:            /var/mobile/Applications/A0B6D2C6-AA93-4D24-9C7F-666B8C7F94B4/sample.app/sample
Identifier:      sample
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2012-07-24 13:07:10.396 +0530
OS Version:      iPhone OS 4.3.5 (8L1)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x0000000c
Crashed Thread:  0

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   WebCore                         0x35fbc900 WebCore::TileCache::doLayoutTiles() + 24
1   WebCore                         0x3609bed8 -[TileHostLayer renderInContext:] + 28
2   QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
3   QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
4   QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
5   QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
6   QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
7   QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
8   QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
9   QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
10  QuartzCore                      0x336cc948 -[CALayer _renderSublayersInContext:] + 220
11  QuartzCore                      0x336cbada -[CALayer renderInContext:] + 1086
12  UIKit                           0x35b6b2dc -[_UITableViewUpdateSupport(Private) _imageViewForView:] + 68
13  UIKit                           0x35b6a66a -[_UITableViewUpdateSupport(Private) _setupDeleteAnimationForFooterInSection:withTargetRect:forUpdateItem:] + 370
14  UIKit                           0x35a7f91a -[_UITableViewUpdateSupport(Private) _setupAnimationsForDeletedHeadersAndFooters] + 1862
15  UIKit                           0x35a78be6 -[_UITableViewUpdateSupport initWithTableView:updateItems:oldRowData:newRowData:oldRowRange:newRowRange:context:] + 398
16  UIKit                           0x35a77dba -[UITableView(_UITableViewPrivate) _updateWithItems:withOldRowData:oldRowRange:newRowRange:context:] + 966
17  UIKit                           0x35a7746c -[UITableView(_UITableViewPrivate) _endCellAnimationsWithContext:] + 4744
18  UIKit                           0x35a812f2 -[UITableView endUpdatesWithContext:] + 22
19  UIKit                           0x35a812ce -[UITableView endUpdates] + 10
20  sample                      0x00007574 -[TableViewController tableView:didSelectRowAtIndexPath:] (TableViewController.m:188)
21  UIKit                           0x3599c514 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 656
22  UIKit                           0x35a000e4 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 124
23  Foundation                      0x307ee6ce __NSFireDelayedPerform + 362
24  CoreFoundation                  0x34e69a40 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 8
25  CoreFoundation                  0x34e6bec4 __CFRunLoopDoTimer + 844
26  CoreFoundation                  0x34e6c83e __CFRunLoopRun + 1082
27  CoreFoundation                  0x34dfcebc CFRunLoopRunSpecific + 224
28  CoreFoundation                  0x34dfcdc4 CFRunLoopRunInMode + 52
29  GraphicsServices                0x30de0418 GSEventRunModal + 108
30  GraphicsServices                0x30de04c4 GSEventRun + 56
31  UIKit                           0x35976d62 -[UIApplication _run] + 398
32  UIKit                           0x35974800 UIApplicationMain + 664
33  sample                      0x000024ac main (main.m:16)
34  sample                      0x00002440 start + 32

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x36906fbc kevent + 24
1   libdispatch.dylib               0x36aa5032 _dispatch_mgr_invoke + 706
2   libdispatch.dylib               0x36aa603a _dispatch_queue_invoke + 86
3   libdispatch.dylib               0x36aa55ea _dispatch_worker_thread2 + 186
4   libsystem_c.dylib               0x3663558a _pthread_wqthread + 258
5   libsystem_c.dylib               0x36635bbc start_wqthread + 0

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x36903c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x36903758 mach_msg + 44
2   CoreFoundation                  0x34e6a2b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x34e6c562 __CFRunLoopRun + 350
4   CoreFoundation                  0x34dfcebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x34dfcdc4 CFRunLoopRunInMode + 52
6   WebCore                         0x35f1a27e _ZL12RunWebThreadPv + 382
7   libsystem_c.dylib               0x3663430a _pthread_start + 242
8   libsystem_c.dylib               0x36635bb4 thread_start + 0

Thread 3:
0   libsystem_kernel.dylib          0x36903c00 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x36903758 mach_msg + 44
2   CoreFoundation                  0x34e6a2b8 __CFRunLoopServiceMachPort + 88
3   CoreFoundation                  0x34e6c562 __CFRunLoopRun + 350
4   CoreFoundation                  0x34dfcebc CFRunLoopRunSpecific + 224
5   CoreFoundation                  0x34dfcdc4 CFRunLoopRunInMode + 52
6   Foundation                      0x307937f6 +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] + 206
7   Foundation                      0x30786382 -[NSThread main] + 38
8   Foundation                      0x307f85c6 __NSThread__main__ + 966
9   libsystem_c.dylib               0x3663430a _pthread_start + 242
10  libsystem_c.dylib               0x36635bb4 thread_start + 0

Thread 4 name:  com.apple.CFSocket.private
Thread 4:
0   libsystem_kernel.dylib          0x36905c60 __select + 20
1   CoreFoundation                  0x34e6f8f2 __CFSocketManager + 582
2   libsystem_c.dylib               0x3663430a _pthread_start + 242
3   libsystem_c.dylib               0x36635bb4 thread_start + 0

Thread 5:
0   libsystem_kernel.dylib          0x369063ec __workq_kernreturn + 8
1   libsystem_c.dylib               0x366356d8 _pthread_wqthread + 592
2   libsystem_c.dylib               0x36635bbc start_wqthread + 0

Thread 0 crashed with ARM Thread State:
    r0: 0x00000000    r1: 0x3ef7c298      r2: 0x00562ab2      r3: 0x00000000
    r4: 0x001f8c70    r5: 0x00164f80      r6: 0x2fdfd718      r7: 0x2fdfd68c
    r8: 0x2fdfd6e8    r9: 0x001fc0a0     r10: 0x001f8c70     r11: 0x00164f80
    ip: 0x3f05e428    sp: 0x2fdfd5f4      lr: 0x3609bedf      pc: 0x35fbc900
  cpsr: 0x60000030

UPDATE 1:

Ive digged deeper into this and it seems to be some bug with apple unless I've missed something obvious

I tried creating a fresh Master Detail iphone app and added a UIWebView property in the MasterViewController(UITableViewController) and initialized it

@interface MasterViewController () {
    NSMutableArray *_objects;
}

@property(nonatomic, strong) UIWebView *webView;

@end

@implementation MasterViewController

@synthesize detailViewController = _detailViewController;
@synthesize webView;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.title = NSLocalizedString(@"Master", @"Master");
        webView = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 50.0)];
    }
    return self;
}

now I have set this webview as the view for footer for the section in the tableview

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    return webView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 50.0;
}

and in the didSelectRowAtIndexPath I have done the following

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.tableView beginUpdates];
    [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationTop];
    [self.tableView endUpdates];
}

Now whenever I touch a row I get the same crash and I have no Idea why this is happening.

This is a totally fresh app with default code in it. I have only added the webView as the footer for the tableview.

Jefferson
  • 1,457
  • 2
  • 11
  • 13
  • how many sections do you have? – sergio Jul 25 '12 at 15:50
  • the tableview has one section and 10 rows – Jefferson Jul 26 '12 at 07:35
  • Just ran into the exact same problem. Tried to set a webview as a footer. The problem seems to be coming from the fact that we are reusing the webview. It works fine if you create a new webview every time viewForFooterInSection is called, but that's inefficient. /: – Ayaka Nonaka Jun 05 '13 at 22:56

1 Answers1

0

This is pretty puzzling. Would you try removing the begin/endUpdates:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   [self.tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationTop];
}

I see that the crash is happening in endUpdates, so all the rest that has been executed up to that point has gone flawlessly.

Another thing you might try is reloading the whole table by calling reloadData instead of only reloading the sections through reloadSections. This is not as optimized, but since you have few rows it should not matter actually (if it works better)...

OLD ANSWER:

It seems that one of the objects in your table view is being deallocated and then accessed again. This is a typical "zombie" issue.

You can get some clues at what is happening by enabling zombie detection in Xcode.

Here you can find out how to enable zombies.

If you do, then the error message you get in the console log will offer more information as to which object was deallocated prematurely.

I understand that you are attaching a crash log because the crash happens in the field. In this case, you have two options: either reproducing the issue at your side (and fix it with the help of zombies detection); or inspect carefully your memory management to find out any issue with objects displayed in the table view.

Community
  • 1
  • 1
sergio
  • 68,819
  • 11
  • 102
  • 123
  • Along the same lines: It might also be a good idea to check for issues with the XCode Clang Analyzer `Product -> Analyze` (if you have not already done this) – Buzzy Jul 24 '12 at 11:26
  • I have updated my question. unfortunately, enabling zombie detection and analyzing the project did not help – Jefferson Jul 25 '12 at 09:38
  • Please, see my edit. I cannot find an explanation, but I have proposed two kind of workarounds. – sergio Jul 26 '12 at 07:51
  • reloadData does work. The problem is with reloadSection I've tried removing beingUpdates and endUpdates, still crashes. And I need reloadSection to work – Jefferson Jul 26 '12 at 11:21