TTURLRequestLoader crashed when there are a lot request going on

Skip to first unread message

Steven Nieh

Mar 11, 2010, 9:40:14 PM3/11/10
to Three20
Hi everyone, I'm working on a application which based on the three 20
library. Everything is perfect except my app crash when there are a
lot networking calls going on.

For example,

When user tap a button in my application, I will cancel all the url
requests in the current view controller(Around 7 requests). Then I
will create the corresponding new network requests in the view

Now If I do this slowly(push->pop->push->pop view controllers),
everything works perfectly! However, if I do it faster, my application
will crash in this method:

- (void)loader:(TTRequestLoader*)loader didLoadResponse:
(NSHTTPURLResponse*)response data:(id)data {
[loader retain];
[self removeLoader:loader];

NSError* error = [loader processResponse:response data:data];
if (error) {
[loader dispatchError:error];
} else {
if (!(loader.cachePolicy & TTURLRequestCachePolicyNoCache)) {
[[TTURLCache sharedCache] storeData:data forKey:loader.cacheKey];

[loader dispatchLoaded:[NSDate date]];
[loader release];

[self loadNextInQueue];

I believe something is wrong in the loader queue. I got "EXEC BAD
ACCESS" in this method.

Any help?



Steven Nieh

Mar 11, 2010, 10:23:21 PM3/11/10
to Three20
#0 0x913c8ed7 in objc_msgSend
#1 0xbfffe488 in ??
#2 0x0009208a in -[TTURLRequestQueue loader:didLoadResponse:data:] at
#3 0x0310287d in __invoking___
#4 0x03102768 in -[NSInvocation invoke]
#5 0x000af9c9 in -[NSObject(TTAdditions)
performSelector:withObject:withObject:withObject:] at
#6 0x00090370 in -[TTRequestLoader connectionDidFinishLoading:] at
#7 0x00469514 in -[NSURLConnection(NSURLConnectionReallyInternal)
#8 0x00469483 in _NSURLConnectionDidFinishLoading
#9 0x02d53ded in URLConnectionClient::_clientDidFinishLoading
#10 0x02dc71aa in
#11 0x02d47ef4 in URLConnectionClient::processEvents
#12 0x02d47d7e in MultiplexerSource::perform
#13 0x030d3d9a in CFRunLoopRunSpecific
#14 0x030d3048 in CFRunLoopRunInMode
#15 0x034e4859 in GSEventRunModal
#16 0x034e491e in GSEventRun
#17 0x006c3342 in UIApplicationMain
#18 0x0000258c in main at main.m:14

Here's the stack!

Steven Nieh

Mar 11, 2010, 11:23:18 PM3/11/10
to Three20
Okay. I somehow fixed this problem by cleaning the delegates array in
the cancel method.

Raphaël Agneau de Selve

Apr 25, 2012, 4:43:35 AM4/25/12
Not sure this is a clean fix.

I encountered the same issue and found out that it was due to one of my delegates being deallocated without cancelling the request.

Two ways of correcting this in the dealloc method of your delegates :
- You know the request you need to cancel : [request cancel]
- You dont't have a reference to the request : [[TTURLRequestQueue mainQueue] cancelRequestsWithDelegate:self];
Reply all
Reply to author
0 new messages