UIWebview received memory warning and crash

1.9k views Asked by At

I locally stored 5 nos of .html files and 2 nos of .js files in application.

Created 2 UIWebview in the name of webviewone and webviewtwo. In the webviewone loaded the 1st html file.

In the webviewone is visible to userscreen in the device. When ever user UIButton action increase the webviewoneindex++

and

call the [self Loadhtminwebviewone]; method.

At same time I generate method([self Loadhtminwebviewtwo]). To calculate the total length after justify.

-(void)Loadhtminwebviewone
{

    NSString *pagesPath=[array4htmlpath objectAtIndex:webviewoneindex];
    NSURL *url=[NSURL fileURLWithPath:pagesPath];

    webviewone.delegate=self;
    webviewone.scrollView.delegate=self;
    webviewone.scrollView.bounces=NO;
    webviewone.scrollView.scrollEnabled=NO;
    [webviewone loadRequest:[NSURLRequest requestWithURL:url]];

}

-(void)Loadhtminwebviewtwo
{
    if(webviewtwoindex==array4htmlpath.count-1)
    {
        return;
    }
    NSString *pagesPath=[array4htmlpath objectAtIndex:webviewtwoindex];
    NSURL *url=[NSURL fileURLWithPath:pagesPath];

    webviewtwo.delegate=self;
    webviewtwo.scrollView.delegate=self;
    webviewtwo.scrollView.bounces=NO;
    webviewtwo.scrollView.scrollEnabled=NO;
    [webviewtwo loadRequest:[NSURLRequest requestWithURL:url]];

}



#pragma mark UIWebview handlers



-(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebViewNavigationType)inType {

    NSString *req = [inRequest.URL absoluteString];
    NSArray *components = [req componentsSeparatedByString:@"~ios~"];


    if (components.count<2) {
        return YES;
    }
    // Check for your protocol
    if ([components count] > 1 && [(NSString *)[components objectAtIndex:1] isEqualToString:@"finishjustify:"])
    {
        NSString *para1 = [(NSString *)[components objectAtIndex:2] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
        NSString *para2 = [(NSString *)[components objectAtIndex:3] stringByReplacingPercentEscapesUsingEncoding: NSUTF8StringEncoding];

        if (inWeb== webviewone) {
            [self finishjustify:para1 :para2 Webtest:inWeb];
        }
        else if (inWeb== webviewtwo) {
            [self finishjustify:para1 :para2 Webtest:inWeb];
        }


        return NO;
    }


    return YES;
}

-(void)finishjustify:(NSString *)chap :(NSString *)contheight Webtest:(UIWebView *)inWeb
{
    if (inWeb== webviewone) {
        [self Loadhtminwebviewone];
    }
    else if (inWeb== webviewtwo) {

        webviewtwoindex++;
        [self Loadhtminwebviewtwo];
    }

}

- (void)webViewDidStartLoad:(UIWebView *)webView
{


    // addrule
    [self injectJavascript:@"addRule" Web:webView];

}

- (void)injectJavascript:(NSString *)resource Web:(UIWebView *)webView {
    NSString *jsPath = [[NSBundle mainBundle] pathForResource:resource ofType:@"js"];
    NSString *js = [NSString stringWithContentsOfFile:jsPath encoding:NSUTF8StringEncoding error:NULL];


    if (webView==webviewone) {
        [webviewone stringByEvaluatingJavaScriptFromString:js];
    }
    else if (webView==webviewtwo) {
        [webviewtwo stringByEvaluatingJavaScriptFromString:js];
    }


}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{


    if ([(webView.loading?@"NO":@"YES")isEqualToString:@"YES"]) {


        [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"javascript:addCSSRule('p', 'text-align: justify;')"]];// align justify paragraphs

        if (webView==webviewone) {
            [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"javascript:finishjustify(%d)",webviewoneindex]];
        }
        else if (webView== webviewtwo) {
            [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"javascript:finishjustify(%d)",webviewtwoindex]];
            // java script page scroll check and page calculation end
        }


    }



}

- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    NSLog(@"\n\n\n didFail:== %@\n\n ",error); 


        return;

    }

}

This working fine in the simulator. While run the device I received memory warning.

my device logs are bellow:

<Warning>: -[PFUbiquitySwitchboardEntryMetadata setUseLocalStorage:](754): CoreData: Ubiquity:  mobile~B4C61A20-19F8-5E88-ABCB-6571A614B4A4:UserDictionary

<Notice>: (com.apple.sbd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 <Error>: (com.apple.sbd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

(UIKitApplication:com.feetan.wireshare[0x7963][2908]) <Notice>: (UIKitApplication:com.feetan.wireshare[0x7963]) Exited: Killed: 9


(UIKitApplication:com.tenderpixel.WatkinsBooks[0xcdcf][2911]) <Notice>: (UIKitApplication:com.tenderpixel.WatkinsBooks[0xcdcf]) Exited: Killed: 9


(UIKitApplication:com.apple.iBooks[0x59e9][2910]) <Notice>: (UIKitApplication:com.apple.iBooks[0x59e9]) Exited: Killed: 9


Application 'UIKitApplication:com.feetan.wireshare[0x7963]' exited abnormally with signal 9: Killed: 9


backboardd[29] <Warning>: Application 'UIKitApplication:com.tenderpixel.WatkinsBooks[0xcdcf]' exited abnormally with signal 9: Killed: 9


backboardd[29] <Warning>: Application 'UIKitApplication:com.apple.iBooks[0x59e9]' exited abnormally with signal 9: Killed: 9


medialibraryd[2906] <Warning>: {MediaLibrary} [MediaLibraryService] Cancelling any active or suspended import operations in progress for process <unknown process> (process ID = 2910)


medialibraryd[2906] <Warning>: {MediaLibrary} [MLWriter] Cleaning up any remaining transactions for ended process <unknown process> (process ID = 2910)



com.apple.launchd[1] (com.apple.iad.limitadtrackingd[2923]) <Notice>: (com.apple.iad.limitadtrackingd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

com.apple.launchd[1] (com.apple.iad.limitadtrackingd[2923]) <Error>: (com.apple.iad.limitadtrackingd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9�com.apple.launchd[1] (com.apple.itunescloudd[2922]) <Notice>: (com.apple.itunescloudd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

com.apple.launchd[1] (com.apple.itunescloudd[2922]) <Error>: (com.apple.itunescloudd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

com.apple.launchd[1] (UIKitApplication:com.apple.mobileslideshow[0x2858][2916]) <Notice>: (UIKitApplication:com.apple.mobileslideshow[0x2858]) Exited: Killed: 9

backboardd[29] <Warning>: Application 'UIKitApplication:com.apple.mobileslideshow[0x2858]' exited abnormally with signal 9: Killed: 9

medialibraryd[2906] <Warning>: {MediaLibrary} [MediaLibraryService] Cancelling any active or suspended import operations in progress for process <unknown process> (process ID = 2922)

medialibraryd[2906] <Warning>: {MediaLibrary} [MLWriter] Cleaning up any remaining transactions for ended process <unknown process> (process ID = 2922)

 com.apple.launchd[1] (com.apple.xpcd.F5010000-0000-0000-0000-000000000000[2928]) <Notice>: (com.apple.xpcd.F5010000-0000-0000-0000-000000000000) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.xpcd.F5010000-0000-0000-0000-000000000000[2928]) <Error>: (com.apple.xpcd.F5010000-0000-0000-0000-000000000000) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.timed[2914]) <Notice>: (com.apple.timed) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.timed[2914]) <Error>: (com.apple.timed) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (UIKitApplication:com.apple.Music[0xdb62][2920]) <Notice>: (UIKitApplication:com.apple.Music[0xdb62]) Exited: Killed: 9

 com.apple.launchd[1] (com.apple.adid[2973]) <Notice>: (com.apple.adid) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.adid[2973]) <Error>: (com.apple.adid) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.crashreportcopymobile[2941]) <Notice>: (com.apple.crashreportcopymobile) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.crashreportcopymobile[2941]) <Error>: (com.apple.crashreportcopymobile) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.AOSNotification[2972]) <Notice>: (com.apple.AOSNotification) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.AOSNotification[2972]) <Error>: (com.apple.AOSNotification) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.accountsd[2898]) <Notice>: (com.apple.accountsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.accountsd[2898]) <Error>: (com.apple.accountsd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 backboardd[29] <Warning>: Application 'UIKitApplication:com.apple.Music[0xdb62]' exited abnormally with signal 9: Killed: 9

 MobileMail[2902] <Notice>: 2013-11-29 19:29:03.517 MobileMail[2902:24415]: The connection to ACDAccountStore was interrupted.

 MobileMail[2902] <Notice>: 2013-11-29 19:29:03.526 MobileMail[2902:7283]: The connection to ACDAccountStore was interrupted.

 com.apple.launchd[1] (UIKitApplication:com.ebooks.ebookreader[0xbac7][2924]) <Notice>: (UIKitApplication:com.ebooks.ebookreader[0xbac7]) Exited: Killed: 9

 backboardd[29] <Warning>: Application 'UIKitApplication:com.ebooks.ebookreader[0xbac7]' exited abnormally with signal 9: Killed: 9

 medialibraryd[2906] <Warning>: {MediaLibrary} [MediaLibraryService] Cancelling any active or suspended import operations in progress for process <unknown process> (process ID = 2920)

 medialibraryd[2906] <Warning>: {MediaLibrary} [MLWriter] Cleaning up any remaining transactions for ended process <unknown process> (process ID = 2920)

 librariand[2897] <Notice>: 2013-11-29 19:29:03.578 librariand[2897:20275]: The connection to ACDAccountStore was interrupted.

 syncdefaultsd[2984] <Notice>: 2013-11-29 19:29:03.578 syncdefaultsd[2984:6919]: The connection to ACDAccountStore was interrupted.



[2991] <Warning>: Received memory warning.



 com.apple.launchd[1] (com.apple.storebookkeeperd[2960]) <Notice>: (com.apple.storebookkeeperd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.storebookkeeperd[2960]) <Error>: (com.apple.storebookkeeperd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.geod[2919]) <Notice>: (com.apple.geod) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.geod[2919]) <Error>: (com.apple.geod) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.mobileassetd[2894]) <Notice>: (com.apple.mobileassetd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.mobileassetd[2894]) <Error>: (com.apple.mobileassetd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.assetsd[2917]) <Notice>: (com.apple.assetsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.assetsd[2917]) <Error>: (com.apple.assetsd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.medialibraryd[2906]) <Notice>: (com.apple.medialibraryd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.medialibraryd[2906]) <Error>: (com.apple.medialibraryd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.mobile.deleted[2939]) <Notice>: (com.apple.mobile.deleted) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.mobile.deleted[2939]) <Error>: (com.apple.mobile.deleted) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.mobile.installd[2895]) <Notice>: (com.apple.mobile.installd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.mobile.installd[2895]) <Error>: (com.apple.mobile.installd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.mobile.installation_proxy[2932]) <Notice>: (com.apple.mobile.installation_proxy) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.mobile.installation_proxy[2932]) <Error>: (com.apple.mobile.installation_proxy) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.mobile.assertion_agent[2931]) <Notice>: (com.apple.mobile.assertion_agent) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.mobile.assertion_agent[2931]) <Error>: (com.apple.mobile.assertion_agent) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.DuetLST[2883]) <Notice>: (com.apple.DuetLST) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.DuetLST[2883]) <Error>: (com.apple.DuetLST) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.networkd_privileged[2889]) <Notice>: (com.apple.networkd_privileged) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.networkd_privileged[2889]) <Error>: (com.apple.networkd_privileged) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.mobile.keybagd[2886]) <Notice>: (com.apple.mobile.keybagd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.mobile.keybagd[2886]) <Error>: (com.apple.mobile.keybagd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.mediaremoted[2918]) <Notice>: (com.apple.mediaremoted) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.mediaremoted[2918]) <Error>: (com.apple.mediaremoted) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.itunesstored[2907]) <Notice>: (com.apple.itunesstored) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.itunesstored[2907]) <Error>: (com.apple.itunesstored) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.sandboxd[2884]) <Notice>: (com.apple.sandboxd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.sandboxd[2884]) <Error>: (com.apple.sandboxd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.mobilegestalt.xpc[2885]) <Notice>: (com.apple.mobilegestalt.xpc) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.mobilegestalt.xpc[2885]) <Error>: (com.apple.mobilegestalt.xpc) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.lsd[2900]) <Notice>: (com.apple.lsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.lsd[2900]) <Error>: (com.apple.lsd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.syncdefaultsd[2984]) <Notice>: (com.apple.syncdefaultsd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.syncdefaultsd[2984]) <Error>: (com.apple.syncdefaultsd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9

 com.apple.launchd[1] (com.apple.securityd[2890]) <Notice>: (com.apple.securityd) Idle-exit job was jettisoned. Will bypass throttle interval for next on-demand launch.

 com.apple.launchd[1] (com.apple.securityd[2890]) <Error>: (com.apple.securityd) assertion failed: 11A465: launchd + 35765 [C04CBC4A-F11B-3F42-8619-D512726C6533]: 0x9
0

There are 0 answers