Christer Nordvik
Christer Nordvik

Reputation: 2528

Native stacktrace crash when using "Bubble messages" chat inside a MonoTouch app

I am using the sample provided here and have used the code inside a regular UITableView: http://tirania.org/monomac//archive/2012/Jan.html

I thought all was good until I added lots of messages. Then I see it crashes (seems like a cell reuse problem) when the messages are too many for the screen.

My main problem is that the stacktrace says almost nothing so anyone used this code in a regular UITableView and would like to share some code?

Here is my GetCell method and stacktrace below:

public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
    {
        ChatMessage msg = _items[indexPath.Row];
        bool isLeft = msg.User.UserId != _controller._gamebackend.GetLocalUser().UserId;
        var cell = tableView.DequeueReusableCell (isLeft ? BubbleCell.KeyLeft : BubbleCell.KeyRight) as BubbleCell;
        if (cell == null)
            cell = new BubbleCell (isLeft);

        cell.Update (GetBubbleText(msg));
        cell.SelectionStyle = UITableViewCellSelectionStyle.None;   
        return cell;
    }

2   libsystem_c.dylib                   0x31f247ed _sigtramp + 48
Jun 24 00:27:53 unknown     3   Foundation                          0x3716a137 probeGC + 62
Jun 24 00:27:53 unknown     4   Foundation                          0x3718983b -[NSConcreteMapTable removeObjectForKey:] + 34
Jun 24 00:27:53 unknown     5   UIKit                               0x353e13a1 -[_UIImageViewPretiledImageWrapper dealloc] + 80
Jun 24 00:27:53 unknown     6   libobjc.A.dylib                     0x34abe175 _objc_rootRelease + 36
Jun 24 00:27:53 unknown     7   libobjc.A.dylib                     0x34abfe57 objc_release + 38
Jun 24 00:27:53 unknown     8   libobjc.A.dylib                     0x34abeead _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 224
Jun 24 00:27:53 unknown     9   libobjc.A.dylib                     0x34abedc9 _objc_autoreleasePoolPop + 12
Jun 24 00:27:53 unknown     10  CoreFoundation                      0x32a6dcff _CFAutoreleasePoolPop + 18
Jun 24 00:27:53 unknown     11  QuartzCore                          0x31fba91d _ZN2CA7Display11DisplayLink8dispatchEyy + 340
Jun 24 00:27:53 unknown     12  QuartzCore                          0x31fba7c5 _ZN2CA7Display16IOMFBDisplayLink8callbackEP21__IOMobileFramebufferyyyPv + 60
Jun 24 00:27:53 unknown     13  IOMobileFramebuffer                 0x32ba8001 IOMobileFramebufferVsyncNotifyFunc + 156
Jun 24 00:27:53 unknown     14  IOKit                               0x34e3d60d IODispatchCalloutFromCFMessage + 188
Jun 24 00:27:53 unknown     15  CoreFoundation                      0x32ae6f13 __CFMachPortPerform + 362
Jun 24 00:27:53 unknown     16  CoreFoundation                      0x32af1523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38
Jun 24 00:27:53 unknown     17  CoreFoundation                      0x32af14c5 __CFRunLoopDoSource1 + 140
Jun 24 00:27:53 unknown     18  CoreFoundation                      0x32af0313 __CFRunLoopRun + 1370
Jun 24 00:27:53 unknown     19  CoreFoundation                      0x32a734a5 CFRunLoopRunSpecific + 300
Jun 24 00:27:53 unknown     20  CoreFoundation                      0x32a7336d CFRunLoopRunInMode + 104
Jun 24 00:27:53 unknown     21  GraphicsServices                    0x32bc0439 GSEventRunModal + 136
Jun 24 00:27:53 unknown     22  UIKit                               0x35052cd5 UIApplicationMain + 1080

Upvotes: 0

Views: 332

Answers (1)

Rolf Bjarne Kvinge
Rolf Bjarne Kvinge

Reputation: 19335

There is another workaround: store all the cells you create in a class-level list.

This should however not happen with types derived from UITableViewCells, so can you also file a bug at http://bugzilla.xamarin.com so that this can hopefully be prevented in the future?

Upvotes: 1

Related Questions