UIWebView is crashing at the end of loading a page that contains embedded YouTube clips in iOS 4.0x

0

When I load a page that contains embedded YouTube clips in a UIWebView managed by a modal UIViewController then I crash out with this stack trace:

OS Version:      iPhone OS 4.0.2 (8A400)
Report Version:  104

Exception Type:  EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x00000000
Crashed Thread:  0

Thread 0 Crashed:
0   YouTube                         0x00002bac -[NSData(YTBase64) webSafeBase64Data] + 76
1   YouTube                         0x000026aa -[YTDeviceAuthenticator _authenticate2] + 662
2   YouTube                         0x00002a54 -[YTDeviceAuthenticator connectionDidFinishLoading:] + 504
3   Foundation                      0x0003d422 -[NSURLConnection(NSURLConnectionReallyInternal) sendDidFinishLoading] + 62
4   Foundation                      0x0003d3a4 _NSURLConnectionDidFinishLoading + 72
5   CFNetwork                       0x00010e74 URLConnectionClient::_clientDidFinishLoading(URLConnectionClient::ClientConnectionEventQueue*) + 160
6   CFNetwork                       0x00004b70 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo*, long) + 96
7   CFNetwork                       0x00004e62 URLConnectionClient::ClientConnectionEventQueue::processAllEventsAndConsumePayload(XConnectionEventInfo*, long) + 850
8   CFNetwork                       0x00004a60 URLConnectionClient::processEvents() + 64
9   CFNetwork                       0x00004a12 URLConnection::multiplexerClientPerform(RunLoopMultiplexer*) + 30
10  CFNetwork                       0x00004990 MultiplexerSource::perform() + 120
11  CFNetwork                       0x0000490e MultiplexerSource::_perform(void*) + 2
12  CoreFoundation                  0x00071a86 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
13  CoreFoundation                  0x00073768 __CFRunLoopDoSources0 + 376
14  CoreFoundation                  0x00074504 __CFRunLoopRun + 224
15  CoreFoundation                  0x0001d8e4 CFRunLoopRunSpecific + 224
16  CoreFoundation                  0x0001d7ec CFRunLoopRunInMode + 52
17  GraphicsServices                0x000036e8 GSEventRunModal + 108
18  GraphicsServices                0x00003794 GSEventRun + 56
19  UIKit                           0x000062a0 -[UIApplication _run] + 396
20  UIKit                           0x00004e10 UIApplicationMain + 664
21  MyApp                           0x00002e94 main (main.m:13)
22  MyApp                           0x00002e30 start + 44

This is not limited to one specific URL; it seems to happen whenever the page contains embedded YouTube clips, eg this one.

Other web pages load fine without a crash.

The crash happens before I can even get to clicking on the actual YouTube clip; it happens as the page containing the embedded clip finishes loading, before the webViewDidFinishLoad: delegate method is called (if I set a delegate).

I stripped out all my extra code, including removing all UIWebViewDelegate references and it still crashes in the same way when running as part of my app.

Strangely, when I extract the code into a new app, the new app works fine.

I also only see this on an iPhone 3GS running iOS 4.02 and an iPod Touch running iOS 4.0.

I do not see this crash on an iOS 3.1.3 original iPhone, nor do I see a crash on the emulator.

Thank you for any help.

iphone
uiwebview
ios4
youtube
asked on Stack Overflow Sep 5, 2010 by David Jacobson • edited Sep 7, 2010 by David Jacobson

2 Answers

0

Is your view controller (or another class) a UIWebViewDelegate for your UIWebView? If so, can you show the code for the delegate methods you implemented?

answered on Stack Overflow Sep 5, 2010 by Shaggy Frog
0

OK, I solved this myself.

I had a category of NSData in my code that defined the method:

- (NSString*)base64Encoding

Unfortunately, the YouTube plugin in iOS 4 appears to use a hidden method (of a category?) of NSData:

- (NSData*)base64Encoding

Needless to say, my category was overriding this method, causing the problem.

answered on Stack Overflow Oct 8, 2010 by David Jacobson

User contributions licensed under CC BY-SA 3.0