[MonoTouch] Did Threading change a lot in 5.2.latest?

Nic Wise nicw at fastchicken.co.nz
Thu Mar 15 10:53:25 UTC 2012


It's not (I think!) that TF is catching the error - its that the app
crashes if I use TFLog (which is async under the hood)

But it could be the ContinueWith thats throwing an exception, which is
tearing down the initially created thread, and possibly the
(TFLog-create) child thread, too....

I'll post the TF-generated crash report once TF is back up....



On Thu, Mar 15, 2012 at 10:49, Rolf Bjarne Kvinge <rolf at xamarin.com> wrote:
> Hi,
>
> These issues might be related. Have in mind that TestFlight will handle
> NullReferenceExceptions as crashes (and won't let you catch them).
>
> Rolf
>
> On Thu, Mar 15, 2012 at 11:39 AM, Nic Wise <nicw at fastchicken.co.nz> wrote:
>>
>> Hi there
>>
>> I'm having a few issues in the newest versions of MT, mostly around
>> Threading (ok, ALL around threading).
>>
>> this one is a fairly major, but easy to work around, one for me:
>>
>> https://bugzilla.xamarin.com/show_bug.cgi?id=3676
>>
>> I'm getting it when I use NewtonSoft Json.net from a thread. I worked
>> around it by using it from the UI thread, and caching the resulting
>> object (not a big deal at all in this case). The DLL I'm using hasn't
>> changed for a long time.....
>>
>>
>>
>> However, I'm also having an issue with TestFlight's logging. If I log
>> in a thread, sometimes, I get a segfault. Not every time, but always
>> in the same place, and ALWAYS in a thread. The thread code is like
>> this:
>>
>> Task.Factory.StartNew(() => {
>>                                CalculateSummary ();
>>                        }).ContinueWith(t => {
>>                                if (oncomplete != null) oncomplete();
>>                        }, new UIKitScheduler());
>>
>> (UIKitScheduler is this: https://gist.github.com/1431457 )
>> CalculateSummary loads a bunch of stuff from SQLite, then the last line
>> is:
>>
>> Util.Log ("recalculating took {0}ms".Fmt (sw.ElapsedMilliseconds));
>>
>> It is possible that the oncomplete is throwing an error, which I need
>> to check out - I've had issues with threading disappearing if the
>> continue throws an uncaught exception.
>>
>> Anywho, Util.Log does a Debug.WriteLine (or Console.WriteLine, same
>> result), and a TestFlight.Log. The first works always. The latter
>> crashes _sometimes_, usually if he app is busy - ie, I'm moving
>> between screens (which triggers calculations) etc. But sometimes just
>> if it's sitting idle. I've tried putting the logging into a
>> InvokeOnMainThread, but with the same result.
>>
>> I wasn't using TF before, but I've not had the Json problem in
>> previous versions (I have a lot of production code out there which is
>> working doing this). That said, I wasn't using Tasks before (I was
>> using the threadpool), which may also be it!
>>
>> Any ideas? did this change after 5.2.4 (I'm on 5.2.8 I think at the
>> moment)
>>
>> I have a semi-stacktrace thing, but it has almost no actual info in
>> it. I'm going to try a debug build tonight, and see if I can get more
>> info out. console just shows that the app segfaulted (error 11 I
>> think??)
>>
>>  Outside of that, everything is exceptionally delicious with iOS5, the
>> appearance API's, and the Task API's :)
>>
>> N
>>
>> --
>> Nic Wise
>> t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
>> b. http://www.fastchicken.co.nz/
>>
>> Nearest Bus: find when the next bus is coming to your stop.
>> http://goo.gl/Vcz1p
>> mobileAgent (for FreeAgent): get your accounts in your pocket.
>> http://goo.gl/IuBU
>> Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
>> London Bike App: Find the nearest Boris Bike, and get riding!
>> http://goo.gl/Icp2
>> _______________________________________________
>> MonoTouch mailing list
>> MonoTouch at lists.ximian.com
>> http://lists.ximian.com/mailman/listinfo/monotouch
>
>



-- 
Nic Wise
t.  +44 7788 592 806 | @fastchicken | http://www.linkedin.com/in/nicwise
b. http://www.fastchicken.co.nz/

Nearest Bus: find when the next bus is coming to your stop. http://goo.gl/Vcz1p
mobileAgent (for FreeAgent): get your accounts in your pocket.
http://goo.gl/IuBU
Trip Wallet: Keep track of your budget on the go: http://goo.gl/ePhKa
London Bike App: Find the nearest Boris Bike, and get riding! http://goo.gl/Icp2


More information about the MonoTouch mailing list