Bug 6177 - BubbleCell sample crash while scrolling
Summary: BubbleCell sample crash while scrolling
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.3.x
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-07-18 10:39 UTC by Sebastien Pouliot
Modified: 2012-07-18 15:56 UTC (History)
3 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FIXED

Description Sebastien Pouliot 2012-07-18 10:39:02 UTC
Issue related to
* http://stackoverflow.com/q/11525894/220643
* https://xamarin.desk.com/agent/case/14123

Apply the following patch to the BubbleCell sample, login and scroll up and down a few fimes.


diff --git a/BubbleCell/BubbleCell/ChatViewController.cs b/BubbleCell/BubbleCell/ChatViewController.cs
index 7625076..1929cdc 100644
--- a/BubbleCell/BubbleCell/ChatViewController.cs
+++ b/BubbleCell/BubbleCell/ChatViewController.cs
@@ -118,7 +118,36 @@ namespace BubbleCell
                        ScrollToBottom (false);
                        // Track changes in the entry to resize the view accordingly
                        entry.Changed += HandleEntryChanged;
+                       
+                       foreach (string msg in msgs)
+                               discussion.Root [0].Add (new ChatBubble (true, msg));
                }
+
+               static string[] msgs = new string [] {
+                       "hello!",
+                       "hello!",
+                       "hello!",
+                       "hello!",
+                       "hello!",
+                       "test",
+                       "test",
+                       "test",
+                       "test",
+                       "test",
+                       "test2",
+                       "test2",
+                       "test2",
+                       "test2",
+                       "test2",
+                       "fghfdgh",
+                       "fghfdgh",
+                       "fghfdgh",
+                       "fghfdgh",
+                       "fghfdgh",
+                       " fg df dfs dsfdg dfgh fthfdh",
+                       " fg df dfs dsfdg dfgh fthfdh",
+                       " fg df dfs dsfdg dfgh fthfdh"
+               };
                
                public override void ViewDidUnload ()
                {

You will get the following crash:


Stacktrace:

  at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
  at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
  at BubbleCell.AppDelegate.Main (string[]) [0x00000] in /Users/sebastienpouliot/git/xamarin/monotouch-samples/BubbleCell/BubbleCell/AppDelegate.cs:26
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>

Native stacktrace:

	0   BubbleCell                          0x000903fc mono_handle_native_sigsegv + 284
	1   BubbleCell                          0x00005518 mono_sigsegv_signal_handler + 248
	2   libSystem.B.dylib                   0x94dd905b _sigtramp + 43
	3   ???                                 0xffffffff 0x0 + 4294967295
	4   Foundation                          0x0172bb03 probeGC + 71
	5   Foundation                          0x01740c58 -[NSConcreteMapTable removeObjectForKey:] + 57
	6   UIKit                               0x026af415 -[_UIImageViewPretiledImageWrapper dealloc] + 81
	7   libobjc.A.dylib                     0x036b7e4d _objc_rootRelease + 47
	8   libobjc.A.dylib                     0x036b7e10 objc_release + 48
	9   libobjc.A.dylib                     0x036b8c60 _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 528
	10  CoreFoundation                      0x010fbed8 _CFAutoreleasePoolPop + 24
	11  QuartzCore                          0x041f6385 _ZN2CA7Display11DisplayLink8dispatchEyy + 275
	12  QuartzCore                          0x041f61af _ZN2CA7Display16TimerDisplayLink8callbackEP16__CFRunLoopTimerPv + 161
	13  CoreFoundation                      0x0119b966 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 22
	14  CoreFoundation                      0x0119b407 __CFRunLoopDoTimer + 551
	15  CoreFoundation                      0x010fe7c0 __CFRunLoopRun + 1888
	16  CoreFoundation                      0x010fddb4 CFRunLoopRunSpecific + 212
	17  CoreFoundation                      0x010fdccb CFRunLoopRunInMode + 123
	18  GraphicsServices                    0x047f4879 GSEventRunModal + 207
	19  GraphicsServices                    0x047f493e GSEventRun + 114
	20  UIKit                               0x02231a9b UIApplicationMain + 1175
	21  ???                                 0x0d83eb05 0x0 + 226749189
	22  ???                                 0x0d83c668 0x0 + 226739816
	23  ???                                 0x0d83ba78 0x0 + 226736760
	24  ???                                 0x0d83bbce 0x0 + 226737102
	25  BubbleCell                          0x000098d2 mono_jit_runtime_invoke + 722
	26  BubbleCell                          0x0016a51e mono_runtime_invoke + 126
	27  BubbleCell                          0x0016e694 mono_runtime_exec_main + 420
	28  BubbleCell                          0x00173a85 mono_runtime_run_main + 725
	29  BubbleCell                          0x00066ad5 mono_jit_exec + 149
	30  BubbleCell                          0x00202b05 main + 2261
	31  BubbleCell                          0x000028d5 start + 53

=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================


Note that using an identical string for every message does not crash the sample.
Comment 1 Sebastien Pouliot 2012-07-18 11:45:44 UTC
It does look related to reusing the cells, i.e. creating new cells each time does not crash. At least creating more than 3000 cells did not crash (and take takes several minutes of scrolling up and down).

Ensuring the managed cells are not disposed (keeping a reference) makes it (much) harder to crash the BubbleCell sample but it does eventually crash (same stack trace).

Using sgen + newrefcount also "seems" to work, i.e. it will take a very long time but it will crash.

Alexey, what exact version of MonoTouch are you using ? (see [1])

OTOH it may not be MonoTouch related [2]. I'll try the suggestions...


[1] http://stackoverflow.com/q/11492745/220643
[2] http://openradar.appspot.com/11411000
Comment 2 Alexey Trizno 2012-07-18 11:49:03 UTC
Version information:

Runtime:
	Mono 2.10.9 (tarball)
	GTK 2.24.10
	GTK# (2.12.0.0)
	Package version: 210090011
Apple Developer Tools:
	 Xcode 4.3.2 (1177)
	 Build 4E2002
Monotouch: 5.3.4

Operating System:
	Mac OS X 10.7.4
Comment 3 Alexey Trizno 2012-07-18 11:56:57 UTC
The description in [2] a bit like our problem. If this is it, then it is understandable why the problem depends on the text in BubbleCell (different insets).
Comment 4 Alexey Trizno 2012-07-18 12:11:28 UTC
This hack solve the problem...

// left = bleft.CreateResizableImage (new UIEdgeInsets (10, 16, 18, 26));
// right = bright.CreateResizableImage (new UIEdgeInsets (11, 11, 17, 18));

left = bleft.StretchableImage(26, 16);
right = bright.StretchableImage(11, 11);

but what is the problem - while still not clear...
Comment 5 Sebastien Pouliot 2012-07-18 12:56:09 UTC
> This hack solve the problem...

It's not really an hack since CreateResizableImage, new in iOS5 [1], is replacing the (older) StretchableImage API, deprecated in iOS 5 [2] but still available.

> but what is the problem - while still not clear...

It does look like an Apple iOS bug in their new API. I'll try it in on the latest iOS release available to see if that was fixed (or if it still a bug there) and update the sample.

[1] http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/Reference/Reference.html#//apple_ref/occ/instm/UIImage/resizableImageWithCapInsets:
[2] http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/DeprecationAppendix/AppendixADeprecatedAPI.html#//apple_ref/occ/instm/UIImage/stretchableImageWithLeftCapWidth:topCapHeight:
Comment 6 Sebastien Pouliot 2012-07-18 15:48:42 UTC
monotouch-sample updated in 39d95da7bc8e39a709c853b4cce852165685acb4

The issue still exists in the latest iOS release available.
Comment 7 Alexey Trizno 2012-07-18 15:56:55 UTC
It is strange that on the Internet mentioning a little about this bug, but in fact it turns out that the old method can not be used, and the new is not working.

Thank you for your help!