3 Replies
      Latest reply on Feb 13, 2020 7:28 AM by jw732
      fcorneli Level 1 Level 1 (0 points)

        On MacOS 10.13 we could display an NSPanel from within SFSafariExtensionHandler as follows:

        func showPanel(_ message:String) -> NSPanel {
                let panel:NSPanel = NSPanel()
                panel.level = .floating
                var frame:NSRect = panel.frame
                frame.size = NSSize(width: 400, height:60)
                panel.setFrame(frame, display: true)
                let font:NSFont = NSFont.systemFont(ofSize: 20)
                let attributes:[NSAttributedString.Key:Any] = [NSAttributedString.Key.font:font]
                let attributedString:NSAttributedString = NSAttributedString(string: message, attributes:attributes)
                let textField:NSTextField = NSTextField(labelWithAttributedString: attributedString)
                panel.contentView = textField
                let application:NSApplication = NSApplication.shared
                application.activate(ignoringOtherApps: true)
                return panel


        However, on MacOS Mojave 10.14 this no longer works. Instead we receive within the Console the following message:

        warning: attempt to begin free window rendezvous for <NSPanel: 0x600002767100> failed due to 
        Error Domain=com.apple.ViewBridge Code=10 "(null)" 
        UserInfo={com.apple.ViewBridge.error.hint=no host-and-service pairs, 


        Anyone knows how to display NSPanel (or NSWindow) from within a Safari App Extension?

        • Re: Display NSPanel from within SFSafariExtensionHandler
          OCS1 Level 1 Level 1 (0 points)

          Lately bumped into the same problem. It looks like panels can be open in the extension

          (a) if it happens to have a toolbar popover;

          (b) after the popover has been opened at least once.


          It looks like Apple does not initialize some important infrasctructure for windows in the extension process before opening the popover. Not sure whether it's a bug or an intentional limitation.


          Incidentally: although our panel (after opening the popover) seems to work normally, it does not seem to be resizable. Pretty darn weird.


          Am afraid it did not help much; anyone from Apple who understands this stuff to rescue? We would actually need to be able to open windows and panels from an extension (even without a popover) pretty badly to co-operate with our injected scripts.

            • Re: Display NSPanel from within SFSafariExtensionHandler
              OCS1 Level 1 Level 1 (0 points)

              Lately, I have found even a plain NSAlert would not work in an extension (unless the popover has been already opened): an attempt to runModal one causes the extension to crash reporting “no service marshals available for modal session”.


              We would really need to show transient panels/popovers/pop-up menus (task-specific ones, not just extra items in the generic context menu) from our extension code, to overlay them above the browser window and allow the user thus to control the extension (and through it, the injected JS code).


              Is there a way to do that? And if not, is there a chance for it to be added in future versions?


              Thanks a big lot!

            • Re: Display NSPanel from within SFSafariExtensionHandler
              jw732 Level 1 Level 1 (20 points)

              Can we get some clarification here?


              Is there any way to display a NSPanel, NSAlert, NSSavePanel, etc... from within SFSafariExtensionHandler?