Click here to Skip to main content
15,889,808 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
I have a button in the UIView. when This button is clicked a hit to the server is initiated. During this time, if we force the application to go in Background. and then coming back to Foreground The application Crashes.

The Log i have received is :-

Jun 26 18:41:26 unknown SpringBoard[50] <Warning>: JAYPORE failed to resume in time
Jun 26 18:41:26 unknown SpringBoard[50] <Warning>: Forcing crash report of JAYPORE[1323]...
Jun 26 18:41:26 unknown SpringBoard[50] <Warning>: Finished crash reporting.
Jun 26 18:41:26 unknown com.apple.launchd[1] <Notice>: (UIKitApplication:JAYPORE[0xcbe2]) Exited: Killed: 9
Jun 26 18:41:26 unknown SpringBoard[50] <Warning>: Application 'JAYPORE' exited abnormally with signal 9: Killed: 9
Jun 26 18:41:27 unknown ReportCrash[1335] <Notice>: Saved crashreport to /var/mobile/Library/Logs/CrashReporter/JAYPORE_2012-06-26-184126_Sameers-iPad.plist using uid: 0 gid: 0, synthetic_euid: 501 egid: 0


I have googling for this but with no success.

I have a Timer which delays the hit to server for 1ms Thats because we show a progress indicator which works when the server hit is delayed.

Thanks in Advance for the support...
Posted
Updated 28-Jun-12 0:20am
v5

1 solution

I guess I will need to check the code which runs when you click on the button. If it is instantiating a new thread then that can be problem. I can help more after looking at your code so please post your code here.
 
Share this answer
 
Comments
Amit._saini 29-Jun-12 5:47am    
Thanks for the concern. Below is the code when i click the button:-


if(tblYearMonth)
{
[tblYearMonth removeFromSuperview];
tblYearMonth=nil;
}
if(txtCmon)
{
[txtCmon resignFirstResponder];
}
MethodNo = 2;
if([self validate])
{
[self ShowProgressIndicator];
NSMutableDictionary *encryptedParams;
encryptedParams = [[NSMutableDictionary alloc]init];

if([IsNew isEqualToString:@"1"])
{
encryptedParams = [self encryptFormData:[self getFormData]];
CardTokenstr = @"";
}

else
{
encryptedParams = [self getFormData];
}

CardNOstr = [encryptedParams valueForKey:@"cc_number"];
CardExpDatestr = [encryptedParams valueForKey:@"cc_exp_date"];
CardCVVstr = [encryptedParams valueForKey:@"CVV"];

ShippingFirstNamestr = txtShippingFirstName.text;
ShippingLastNamestr = txtShippingLastName.text;
ShippingAddressstr = txtShippingAddress.text;
ShippingCitystr=txtShippingCity.text;
ShippingZipCodestr=txtShippingZipCode.text;
ShippingStatestr=lblState.text;
ShippingCountrystr=@"US";

BillingFirstNamestr=txtBillingFirstName.text;
BillingLastNamestr=txtBillingLastName.text;
BillingAddressstr = txtBillingAddress.text;
BillingCitystr = txtBillingCity.text;
BillingZipCodestr = txtBillingZipCode.text;
BillingStatestr=lblState1.text;
BillingCountrystr=@"US";


UserIDstr = [NSString stringWithFormat:@"%d",[[UserDetails sharedUserDetails] getUserID]];


timer=[NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(MakePaymentServiceHit) userInfo:nil repeats:NO];
Aqueel 29-Jun-12 7:42am    
Ok now send me code for MakePaymentServiceHit method as well. If you look into the log, it says,"JAYPORE failed to resume in time". It looks like app was not able to exit applicationDidBecomeActive in timely manner. It happens when some operation was in progress and it did not finish within specified time and iOS purged your app from the memory. Remember that when your app enters background, applicationDidEnterBackground and applicationWillResignActive are called. This method is defined in AppDelegate class of your project. And when app comes to foreground, applicationDidBecomeActive is called.

According to iOS programming guidelines,

Your delegate’s applicationDidEnterBackground: method has approximately 5 seconds to finish any tasks and return. In practice, this method should return as quickly as possible. If the method does not return before time runs out, your application is killed and purged from memory. If you still need more time to perform tasks, call the beginBackgroundTaskWithExpirationHandler: method to request background execution time and then start any long-running tasks in a secondary thread. Regardless of whether you start any background tasks, the applicationDidEnterBackground: method must still exit within 5 seconds.

So make sure, when your app enters applicationWillResignActive method, it finishes all its tasks within 5 seconds and if the task is big enough to not to finish within this time, you should kill such thread or cancel that timer.

For more information, please read the documentation at
http://developer.apple.com/library/ios/#DOCUMENTATION/iPhone/Conceptual/iPhoneOSProgrammingGuide/ManagingYourApplicationsFlow/ManagingYourApplicationsFlow.html
I hope that helps
Amit._saini 29-Jun-12 9:07am    
This is the method


-(void)MakePaymentServiceHit
{
@try
{
NSMutableURLRequest *_urlRequest;
_urlRequest = [RequestBuilder MakePayment:ShippingFirstNamestr :ShippingLastNamestr :ShippingAddressstr :ShippingCitystr :ShippingZipCodestr :ShippingStatestr:ShippingRegionID:ShippingCountrystr:BillingFirstNamestr :BillingLastNamestr :BillingAddressstr :BillingCitystr :BillingZipCodestr :BillingStatestr :BillingRegionID:BillingCountrystr:UserIDstr:CartIDstr:CardTokenstr:IsNew:@"":@"":@"":CardNOstr:CardExpDatestr:CardCVVstr:strUserCredit];
[[ServerRequest shared] processServerRequest:_urlRequest atDelegate:self];

}
@catch (NSException *e) {
//[CommonFunctions showConfirmAlert:e.description];
}
}

This Post the data to the server. and then the response is cached in the delegate methods.
Aqueel 2-Jul-12 1:12am    
So have you tried my solution? How is it going now?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900