PDA

View Full Version : Trying to use WebView --> CRASH




harry65
Jun 9, 2009, 10:42 PM
I'm trying to use a WebView object to display a web page, but my program ends up crashing (The Debugger has exited due to signal 2 (SIGINT)) while the page is loading. Here's what my .h and .m files look like...


#import <Cocoa/Cocoa.h>
#import <WebKit/WebView.h>


@interface AppController : NSObject {
IBOutlet WebView *webView;
}

- (IBAction)setupView:(id)sender;

@end



#import "AppController.h"

@implementation AppController

- (id)init
{
[super init];
webView = [[WebView alloc] init];
return self;
}

- (IBAction)setupView:(id)sender
{
NSString *urlString = @"http://www.nba.com";
// NSString *urlString = @"http://google.com";
[webView setMainFrameURL:urlString];
}

@end


My UI consists of a window with a scrollView in it, and a WebView inside the scroll view. I also have a single button that will call 'setupView' when clicked, and my program crashes when I try and load something like nba.com. If I try to load google.com, though, it works fine.

I ran this in the debugger and put a breakpoint at the 'setMainFrameURL' line. When I get there and 'continue', the program crashes and gives me this message:


(gdb) c
Continuing.
Current language: auto; currently objective-c
=shlibs-removed,shlib-info=[num="101",name="JavaPluginCocoa",kind="B",dyld-addr="0x15eea000",reason="dyld",requested-state="E",state="E",path="/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Resources/JavaPluginCocoa.bundle/Contents/MacOS/JavaPluginCocoa",description="/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Resources/JavaPluginCocoa.bundle/Contents/MacOS/JavaPluginCocoa",loaded_addr="0x15eea000",slide="0x15eea000",prefix=""]
Debugger() was called!
(gdb)


I have added the WebKit.framework and JavaVM.framework into my project, but I still get the error above.

I checked, and the /System/Library/Fr..../JavaPluginCocoa file does exist on my machine.

Another funny thing I don't quite understand... If I run this in the debugger with the breakpoint described above, hit 'c' at the breakpoint, I get the message above. The debugger is now at the '(gdb)' prompt, and if I hit 'c' again, I get the 'Continuing' message in the debugger and my page finishes loading and my program seems to work fine. However, whenever I run it without debugging, it will crash.

Anybody know what I'm doing wrong here? Any help would be greatly appreciated.

Thanks.



kainjow
Jun 10, 2009, 02:07 AM
Not sure about the crash, but why are you recreating the webview? That is unneeded since the nib creates it for you.

harry65
Jun 10, 2009, 09:48 PM
Thanks kainjow. I'm fairly new to ObjC/Cocoa/Xcode/etc. and am still figuring out IB and so forth. I appreciate the feedback.

However, I took out the constructor and my program still crashes. I assume it has something to do with Java in the page I am loading (since something like google.com works fine), but I'm not sure what I need to add to my project to fix this. Or, is it something like what LD_LIBRARY_PATH does on Linux? I'm not sure if OS X has an equivalent, or if I even need something like that.

I'm wondering if this would work on someone else's machine or if it's something weird with my setup... Any takers?

Any other ides?

Thanks.

kainjow
Jun 11, 2009, 04:45 PM
You could disable plugins in the WebView (there's a checkbox in IB for that) and see if that helps.

harry65
Jun 12, 2009, 02:32 AM
Thanks again. Disabling the plugins helped - my program no longer crashes. Though, the web page does not load fully (I get a message about needing to download the Flash player). Not sure what exactly this tells me... :confused:

dleber
Jul 6, 2009, 06:00 PM
This is a known issue. You can blame Adobe. There is a call to Debugger() in the Flash 10 (and it's been there a while).

There is a blog post here (http://www.stinkbot.com/blog/archives/69) that outlines the workaround.

harry65
Jul 8, 2009, 01:00 AM
This is a known issue. You can blame Adobe. There is a call to Debugger() in the Flash 10 (and it's been there a while).

There is a blog post here (http://www.stinkbot.com/blog/archives/69) that outlines the workaround.

Thanks dleber!! I'll definitely have to check that out when I get a chance. I've since abandoned the little example I was working on but I'm curious now to see if turning off the debug stuff would work.

[edit]
Works just as advertised now... Thanks!!