Question

I've noticed constant reproducible crash that occurs in a UIWebView: Here the 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 at 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 with following steps:

  1. Make UIWebView load the request (NSURLRequest)
  2. Send app to background before the request is loaded
  3. Wait a few minutes
  4. Resuming the app from background will crash with the exemplified stack trace information.

Does anyone know why this is happening? Any help is very much appreciated!

EDIT: Code used to perform the request

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURLRequest *urlRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:url]];
    [self.webView loadRequest:urlRequest];
}

My UIViewController is also a delegate of the UIWebView and I implement the following methods:

-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
-(void)webViewDidFinishLoad:(UIWebView *)webView

The app crashed before any of those methods is invoked.

Était-ce utile?

La solution

for resolving this one you can add notification and when app going to background process at that time pass the nil value to web view.

[[NSNotificationCenter defaultCenter] addObserver: self
                                         selector: @selector(handleEnteredBackground:) 
                                             name: UIApplicationDidEnterBackgroundNotification
                                           object: nil];

or place below code in applicationDidEnterBackground method it freezes the all the tasks untill comes to foreGround process.

UIApplication *app = application;


    [app beginBackgroundTaskWithExpirationHandler:^{
        // Synchronize the cleanup call on the main thread in case
        // the task actually finishes at around the same time.
        dispatch_async(dispatch_get_main_queue(), ^{

            //            if (bgTask != UIBackgroundTaskInvalid)
            //            {
            //               // [app endBackgroundTask:bgTask];
            //               // bgTask = UIBackgroundTaskInvalid;
            //            }
        });
    }];

    // Start the long-running task and return immediately.
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

        // Do the work associated with the task.


        // Synchronize the cleanup call on the main thread in case
        // the expiration handler is fired at the same time.
        dispatch_async(dispatch_get_main_queue(), ^{

        });
    });
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top