Trying to use WebView --> CRASH

Discussion in 'Mac Programming' started by harry65, Jun 9, 2009.

  1. macrumors member

    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;
    #import "AppController.h"
    @implementation AppController
    - (id)init
    	[super init];
    	webView = [[WebView alloc] init];
    	return self;
    - (IBAction)setupView:(id)sender
    	NSString *urlString = @"";
    //	NSString *urlString = @"";
    	[webView setMainFrameURL:urlString];
    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 If I try to load, 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
    Current language:  auto; currently objective-c
    Debugger() was called!
    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.

  2. Moderator emeritus


    Not sure about the crash, but why are you recreating the webview? That is unneeded since the nib creates it for you.
  3. macrumors member

    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 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?

  4. Moderator emeritus


    You could disable plugins in the WebView (there's a checkbox in IB for that) and see if that helps.
  5. macrumors member

    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:
  6. macrumors newbie

    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 that outlines the workaround.
  7. macrumors member

    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.

    Works just as advertised now... Thanks!!

Share This Page