<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic signal=11 crash on opening cocoa webview in Archicad C++ API</title>
    <link>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293685#M3866</link>
    <description>&lt;DIV class="actalk-migrated-content"&gt;Hello again &lt;IMG style="display: inline;" src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" border="0" /&gt;&lt;BR /&gt;&lt;BR /&gt;I'm trying to open an cocoa webview into my Archicad add-on and after it opens its possible to browse a web page for a little, and after e few random clicks on links the whole Archicad crashes just like it hits some memory limit or something.. I get this errors in the console.app:&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;Jun 27 11:56:25 Julians-iMac Archicad 20.app[20357]: ====&amp;gt;GeneralSignalHandler received signal=11

Jun 27 11:56:25 Julians-iMac Archicad 20.app[20357]: ====&amp;gt;GeneralSignalHandler calling OOP handler

Jun 27 11:56:26 Julians-iMac Archicad 20.app[20357]: Archicad [20357] crashed with signal 11. Report written to: /Users/ivan/Library/Application Support/Graphisoft/BugReporting-20/Archicad-20170627(08-49-05)-[20357]-FATAL.rpt

Jun 27 11:56:27 Julians-iMac Archicad 20.app[20357]: ====&amp;gt;GeneralSignalHandler restoring previous handlers

Jun 27 11:56:27 Julians-iMac com.apple.xpc.launchd[1] 
(com.Graphisoft.Archicad.17352[20357]): Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]
&lt;/PRE&gt;
&lt;BR /&gt;Basically all what I'm doing is creating an instance of nswindow and adding a webview into, all done programatically (all seems to work fine without crash on a simple c++ project, but crashes after a while with Archicad API included):&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;void openWindowAndWebView(void)
{

    
    NSWindow *window =
    [[NSWindow alloc]
     initWithContentRect:NSMakeRect(0, 0, 800, 600) styleMask: NSWindowStyleMaskClosable backing: NSBackingStoreBuffered defer: YES];
    
    [window center];
    window.title = @"Hello World";
    [window makeKeyAndOrderFront:window];
    [window setStyleMask:[window styleMask] | NSWindowStyleMaskTitled | NSWindowStyleMaskResizable];
//
//    Window_delegate *d = [Window_delegate new];
//    window.delegate = d;
//    
    WebView *wb = [[WebView alloc] initWithFrame:window.contentView.frame];
    wb.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
    
    [window.contentView addSubview:wb];
    
    [[wb mainFrame]
     loadRequest:[NSURLRequest
     requestWithURL:[NSURL URLWithString:@"http://www.cars.bg"]]];
    
}

#endif

void openWebView(void){
    WriteReport("Open web view");
#ifdef __OBJC__
    WriteReport("it is OBJC!");
    @autoreleasepool {
        openWindowAndWebView();
    }
#endif
}
&lt;/PRE&gt;
I will be very helpful if you can help me, or just guide me how to debug it.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Julian&lt;/DIV&gt;</description>
    <pubDate>Tue, 06 Dec 2022 13:03:41 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-12-06T13:03:41Z</dc:date>
    <item>
      <title>signal=11 crash on opening cocoa webview</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293685#M3866</link>
      <description>&lt;DIV class="actalk-migrated-content"&gt;Hello again &lt;IMG style="display: inline;" src="https://community.graphisoft.com/legacyfs/online/emojis/icon_smile.gif" border="0" /&gt;&lt;BR /&gt;&lt;BR /&gt;I'm trying to open an cocoa webview into my Archicad add-on and after it opens its possible to browse a web page for a little, and after e few random clicks on links the whole Archicad crashes just like it hits some memory limit or something.. I get this errors in the console.app:&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;Jun 27 11:56:25 Julians-iMac Archicad 20.app[20357]: ====&amp;gt;GeneralSignalHandler received signal=11

Jun 27 11:56:25 Julians-iMac Archicad 20.app[20357]: ====&amp;gt;GeneralSignalHandler calling OOP handler

Jun 27 11:56:26 Julians-iMac Archicad 20.app[20357]: Archicad [20357] crashed with signal 11. Report written to: /Users/ivan/Library/Application Support/Graphisoft/BugReporting-20/Archicad-20170627(08-49-05)-[20357]-FATAL.rpt

Jun 27 11:56:27 Julians-iMac Archicad 20.app[20357]: ====&amp;gt;GeneralSignalHandler restoring previous handlers

Jun 27 11:56:27 Julians-iMac com.apple.xpc.launchd[1] 
(com.Graphisoft.Archicad.17352[20357]): Service exited due to signal: Segmentation fault: 11 sent by exc handler[0]
&lt;/PRE&gt;
&lt;BR /&gt;Basically all what I'm doing is creating an instance of nswindow and adding a webview into, all done programatically (all seems to work fine without crash on a simple c++ project, but crashes after a while with Archicad API included):&lt;BR /&gt;
&lt;PRE&gt;&lt;I&gt;
&lt;/I&gt;void openWindowAndWebView(void)
{

    
    NSWindow *window =
    [[NSWindow alloc]
     initWithContentRect:NSMakeRect(0, 0, 800, 600) styleMask: NSWindowStyleMaskClosable backing: NSBackingStoreBuffered defer: YES];
    
    [window center];
    window.title = @"Hello World";
    [window makeKeyAndOrderFront:window];
    [window setStyleMask:[window styleMask] | NSWindowStyleMaskTitled | NSWindowStyleMaskResizable];
//
//    Window_delegate *d = [Window_delegate new];
//    window.delegate = d;
//    
    WebView *wb = [[WebView alloc] initWithFrame:window.contentView.frame];
    wb.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
    
    [window.contentView addSubview:wb];
    
    [[wb mainFrame]
     loadRequest:[NSURLRequest
     requestWithURL:[NSURL URLWithString:@"http://www.cars.bg"]]];
    
}

#endif

void openWebView(void){
    WriteReport("Open web view");
#ifdef __OBJC__
    WriteReport("it is OBJC!");
    @autoreleasepool {
        openWindowAndWebView();
    }
#endif
}
&lt;/PRE&gt;
I will be very helpful if you can help me, or just guide me how to debug it.&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Julian&lt;/DIV&gt;</description>
      <pubDate>Tue, 06 Dec 2022 13:03:41 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293685#M3866</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-12-06T13:03:41Z</dc:date>
    </item>
    <item>
      <title>Re: signal=11 crash on opening cocoa webview</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293686#M3867</link>
      <description>&lt;BLOCKQUOTE&gt;jcimentarov wrote:&lt;BR /&gt;I'm trying to open an cocoa webview into my archicad add-on and after it opens its possible to browse a web page for a little, and after e few random clicks on links the whole archicad crashes just like it hits some memory limit or something.&lt;/BLOCKQUOTE&gt;
Some more information about the context you're opening the webview into would be useful, e.g. are running this in a separate process to ARCHICAD?&lt;BR /&gt;
&lt;BR /&gt;
If you're running this in the same thread as the add-on, I'm not surprised it's crashing – I'd only be surprised it worked at all. I think it would play havoc with ARCHICAD's event-handling, memory and window management.</description>
      <pubDate>Tue, 27 Jun 2017 15:20:34 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293686#M3867</guid>
      <dc:creator>Ralph Wessel</dc:creator>
      <dc:date>2017-06-27T15:20:34Z</dc:date>
    </item>
    <item>
      <title>Re: signal=11 crash on opening cocoa webview</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293687#M3868</link>
      <description>&lt;PRE&gt;GSErrCode __ACENV_CALL MenuCommandHandler (const API_MenuParams *menuParams)
{
    
    
    if (menuParams-&amp;gt;menuItemRef.menuResID == 32500) {
        GSErrCode errorCode = ACAPI_CallUndoableCommand ("Importer",
         [&amp;amp;] () -&amp;gt; GSErrCode {
             switch (menuParams-&amp;gt;menuItemRef.itemIndex) {
                case  1: openFileDialog(); break;
                case  2: openWebView();break;
                
                default: return NoError;
             }
         });
        
        return errorCode;
    }
    return NoError;
}&lt;/PRE&gt;

This is where I'm calling my method which is opening the window with the webview. I'm still a newbie to c++ and I'm not pretty sure if it runs in a different thread than the add-on. How can I check that, and if it doesn't run in a separate threat how could I fix it?</description>
      <pubDate>Wed, 28 Jun 2017 07:00:08 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293687#M3868</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-28T07:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: signal=11 crash on opening cocoa webview</title>
      <link>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293688#M3869</link>
      <description>&lt;BLOCKQUOTE&gt;jcimentarov wrote:&lt;BR /&gt;&lt;PRE&gt;GSErrCode __ACENV_CALL MenuCommandHandler (const API_MenuParams *menuParams)
{
    
    
    if (menuParams-&amp;gt;menuItemRef.menuResID == 32500) {
        GSErrCode errorCode = ACAPI_CallUndoableCommand ("Importer",
         [&amp;amp;] () -&amp;gt; GSErrCode {
             switch (menuParams-&amp;gt;menuItemRef.itemIndex) {
                case  1: openFileDialog(); break;
                case  2: openWebView();break;
                
                default: return NoError;
             }
         });
        
        return errorCode;
    }
    return NoError;
}&lt;/PRE&gt;

This is where I'm calling my method which is opening the window with the webview. I'm still a newbie to c++ and I'm not pretty sure if it runs in a different thread than the add-on. How can I check that, and if it doesn't run in a separate threat how could I fix it?&lt;/BLOCKQUOTE&gt;

The menu command handler runs on the main thread.&lt;BR /&gt;
My guess that here the add-on is unloaded very soon after you call the menu command, so try to call ACAPI_KeepInMemory (true); at the beginning of the MenuCommandHandler.&lt;BR /&gt;
&lt;BR /&gt;
Best, Akos</description>
      <pubDate>Fri, 30 Jun 2017 10:49:00 GMT</pubDate>
      <guid>https://community.graphisoft.com/t5/Archicad-C-API/signal-11-crash-on-opening-cocoa-webview/m-p/293688#M3869</guid>
      <dc:creator>Akos Somorjai</dc:creator>
      <dc:date>2017-06-30T10:49:00Z</dc:date>
    </item>
  </channel>
</rss>

