ios - UIWebView crashes when app resumes from background -
i've noticed constant reproducible crash occurs in uiwebview: here stack trace:
incident identifier: 4729da31-a946-436d-97ac-eb3c8746e0ff crashreporter key: 92eabebd7d2b07f27dde132a3c28d6bb7cf92df4 hardware model: ipad3,6 process: ... [3120] path: /var/mobile/applications/10173a06-48d0-48f7-a832-9ac6961b045d/...app/... identifier: ... version: ??? (???) code type: arm (native) parent process: launchd [1] date/time: 2013-05-09 19:07:31.997 +0100 os version: ios 6.1.3 (10b329) report version: 104 exception type: exc_bad_access (sigsegv) exception codes: kern_invalid_address @ 0x00000008 crashed thread: 2 ... thread 2 name: webthread thread 2 crashed: 0 webcore 0x3772a03a webcore::threadtimers::sharedtimerfiredinternal() + 130 1 webcore 0x37729f86 webcore::timerfired(__cfrunlooptimer*, void*) + 62 2 corefoundation 0x31741854 __cfrunloop_is_calling_out_to_a_timer_callback_function__ + 12 3 corefoundation 0x317414fe __cfrunloopdotimer + 270 4 corefoundation 0x31740172 __cfrunlooprun + 1226 5 corefoundation 0x316b3238 cfrunlooprunspecific + 352 6 corefoundation 0x316b30c4 cfrunloopruninmode + 100 7 webcore 0x37697390 runwebthread(void*) + 440 8 libsystem_c.dylib 0x39a530de _pthread_start + 306 9 libsystem_c.dylib 0x39a52fa4 thread_start + 4 occurs following steps:
- make uiwebview load request (nsurlrequest)
- send app background before request loaded
- wait few minutes
- resuming app background crash exemplified stack trace information.
does know why happening? appreciated!
edit: code used perform request
- (void)viewdidload { [super viewdidload]; nsurlrequest *urlrequest = [nsurlrequest requestwithurl:[nsurl urlwithstring:url]]; [self.webview loadrequest:urlrequest]; } my uiviewcontroller delegate of uiwebview , implement following methods:
-(void)webview:(uiwebview *)webview didfailloadwitherror:(nserror *)error -(void)webviewdidfinishload:(uiwebview *)webview the app crashed before of methods invoked.
for resolving 1 can add notification , when app going background process @ time pass nil value web view.
[[nsnotificationcenter defaultcenter] addobserver: self selector: @selector(handleenteredbackground:) name: uiapplicationdidenterbackgroundnotification object: nil]; or place below code in applicationdidenterbackground method freezes tasks untill comes foreground process.
uiapplication *app = application; [app beginbackgroundtaskwithexpirationhandler:^{ // synchronize cleanup call on main thread in case // task finishes @ around same time. dispatch_async(dispatch_get_main_queue(), ^{ // if (bgtask != uibackgroundtaskinvalid) // { // // [app endbackgroundtask:bgtask]; // // bgtask = uibackgroundtaskinvalid; // } }); }]; // start long-running task , return immediately. dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ // work associated task. // synchronize cleanup call on main thread in case // expiration handler fired @ same time. dispatch_async(dispatch_get_main_queue(), ^{ }); });
Comments
Post a Comment