簡體   English   中英

<Application>有超出允許時間的主動斷言 - 僅適用於iPhone 5S,適用於iPhone 5,4和4

[英]<Application> has active assertions beyond permitted time - iPhone 5S only, fine on iPhone 5, 4s and 4

我收到以下崩潰報告,該應用程序在后台與NSURLconnection進行后台通信,超時時間為7秒:

Incident Identifier: 3C862AC5-4226-461B-ACC8-6F080D2FDFDB
CrashReporter Key:   119b92a02f2002d19cf9f0b80d48362ac24a5d3e
Hardware Model:      iPhone6,2
Process:             xxx [1971]
Path:                /var/mobile/Applications/33D1EAC9-8D24-4E40-805B-BD7C4FCD96FD/xxx.app/xxx
Identifier:          com.xx.xxx
Version:             1.0.0 (1.0.0)
Code Type:           ARM (Native)
Parent Process:      launchd [1]

Date/Time:           2013-10-30 19:50:38.812 +1000
OS Version:          iOS 7.0.3 (11B511)
Report Version:      104

Exception Type:  00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread:  2

Application Specific Information:
xxx[1971] has active assertions beyond permitted time: 
{(
    <BKProcessAssertion: 0x17046ad40> identifier: Called by xxx, from unknown method process: xxx[1971] permittedBackgroundDuration: 180.000000 reason: finishTask owner pid:1971 preventSuspend  preventIdleSleep  preventSuspendOnSleep 
)}

Elapsed total CPU time (seconds): 0.440 (user 0.440, system 0.000), 4% CPU 
Elapsed application CPU time (seconds): 0.000, 0% CPU

嘗試使用以下代碼時會發生這種情況:

+(NSURLRequest*)updateLocation4SampleRequest_withUserId:(NSString*)userId userAPIToken:(NSString*)userAPIToken p1:(CLLocation*)p1 p2:(CLLocation*)p2 p3:(CLLocation*)p3 p4:(CLLocation*)p4 accuracy:(CLLocationAccuracy)accuracy
{
//    return [NSURLRequest requestWithURL: [[NSURL alloc] initWithString:[[NSString stringWithFormat: updateLocation4SampleRequestURL, OTNRequestURL, userId, userAPIToken, p1.coordinate.latitude, p1.coordinate.longitude, p2.coordinate.latitude, p2.coordinate.longitude, p3.coordinate.latitude, p3.coordinate.longitude, p4.coordinate.latitude, p4.coordinate.longitude, accuracy] stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]];

    NSString *post = [NSString stringWithFormat: updateLocation4SampleRequestURL, userId, userAPIToken, p1.coordinate.latitude, p1.coordinate.longitude, p2.coordinate.latitude, p2.coordinate.longitude, p3.coordinate.latitude, p3.coordinate.longitude, p4.coordinate.latitude, p4.coordinate.longitude, accuracy];

    NSLog(@"%@",post);
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

    NSString *postLength = [NSString stringWithFormat:@"%d",[postData length]];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL: [[NSURL alloc] initWithString:OTNRequestURL] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:7];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Current-Type"];
    [request setHTTPBody:postData];

    return request;
}

並且調用它並啟動asyncrequest的函數。

// start the Link Maker search
        NSURLRequest* request = [OTNUtil updateLocation4SampleRequest_withUserId:userId     userAPIToken:user_api_token p1:p1 p2:p2 p3:p3 p4:p4     accuracy:OTNDataManager.app.currentLocation.horizontalAccuracy];
        NSLog(@"%@, (UPDATELOCATION) user id: %@",[request URL], userId);


        [NSURLConnection sendAsynchronousRequest:request queue:_requestOperationQueue completionHandler:^(NSURLResponse* response, NSData* data, NSError* error) {
            //The first checkin has occurred bool is used to skip the splash screen.
            self.firstCheckinHasOccurred = YES;

            // Save the downloaded data
            NSError* jsonError = nil;
            NSDictionary* resultDictionary = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&jsonError];
            if(jsonError != nil) {
                // do something with the error here
                NSLog(@"JSON Error: %@", jsonError);
                //    callback(nil, jsonError);
                if (OTNDataManager.shared.settingsAutoCheckin) {
                    dispatch_async(dispatch_get_main_queue(), ^{
                        [OTNDataManager.app setLocationUpdateInterval:15.0 * 60.0];
                    });
                }

            } else if (resultDictionary != nil) {
              <SNIP....>
            }
          }];

要確認......我只在運行7.0.3的iPhone 5S上看到這個,但沒有兩個單獨的iPhone 5,一個運行7.0.3,另一個運行6.1.4。 它還在開發運行7.0.2的iPhone 4S。 此外,如果在綁定到Xcode時運行代碼,只有在發布模式下運行應用程序的編譯版本時才會發生這種情況。

如果有人知道這里發生了什么,請告訴我。

這個問題很煩人,很難通過斷點調試,我建議你嘗試一些技巧,當應用程序辭職活動如下,從系統申請更多時間:

    __block UIBackgroundTaskIdentifier backgroundTaskIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{


        [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskIdentifier];
        backgroundTaskIdentifier = backgroundTaskIdentifier;
    }];

這些是看門狗超時崩潰報告,您可以通過臭名昭着的“吃不好的食物”(0x8badf00d)異常代碼識別出來。 有關如何破譯崩潰日志和潛在解決方案的更多信息,請訪問:

https://developer.apple.com/library/ios/qa/qa1693/_index.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM