使用SWT死锁的macosx上的jxbrowser

时间:2016-10-06 14:46:53

标签: swt jxbrowser

我已经完成了对用于Windows和Linux的Eclipse的jxbrowser集成的评估。我的最后一个障碍是Mac。我在实例化浏览器时遇到死锁。我是cocoa编程的新手,所以任何指针都会受到高度赞赏。

我参加了示例项目并修改它以使用SWT。

import java.awt.BorderLayout;
import java.awt.Frame;

import org.eclipse.swt.SWT;
import org.eclipse.swt.awt.SWT_AWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;

public class JxBrowserApp {
    public static void main(String[] args) {

        final Display display = new Display();
        final Shell shell = new Shell(display);

        Composite composite = new Composite(shell, SWT.EMBEDDED | SWT.NO_BACKGROUND);
        Frame frame = SWT_AWT.new_Frame(composite);

        Browser browser = new Browser(); // deadlock here 
        BrowserView browserView = new BrowserView(browser);

        frame.add(browserView, BorderLayout.CENTER);
        frame.setLocationRelativeTo(null);
        frame.setFocusable(true);
        browser.loadURL("http://www.google.com");

        shell.pack();
        shell.open ();
        while (!shell.isDisposed ()) {
            if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
    }
}

这是callstack

JxBrowserApp at localhost:57970 
    Thread [main] (Suspended)   
        owns: IPC  (id=72)  
        Unsafe.park(boolean, long) line: not available [native method]  
        LockSupport.parkNanos(Object, long) line: 215   
        CountDownLatch$Sync(AbstractQueuedSynchronizer).doAcquireSharedNanos(int, long) line: 1037  
        CountDownLatch$Sync(AbstractQueuedSynchronizer).tryAcquireSharedNanos(int, long) line: 1328 
        CountDownLatch.await(long, TimeUnit) line: 277  
        LatchUtil.await(CountDownLatch, RuntimeException, int) line: 25 
        LatchUtil.await(CountDownLatch, RuntimeException) line: 20  
        IPC.a(boolean) line: 159    
        IPC.start() line: 128   
        Browser.<init>(BrowserType, BrowserContext, Channel) line: 195  
        Browser.<init>(BrowserType, BrowserContext) line: 172   
        Browser.<init>(BrowserContext) line: 139    
        Browser.<init>() line: 125  
        JxBrowserApp.main(String[]) line: 27    
    Thread [AWT-EventQueue-0] (Suspended)   
        CPlatformView.nativeCreateView(int, int, int, int, long) line: not available [native method]    
        CPlatformView.initialize(LWWindowPeer, CPlatformResponder) line: 61 
        CViewPlatformEmbeddedFrame.initialize(Window, LWWindowPeer, PlatformWindow) line: 55    
        LWWindowPeer.<init>(Window, PlatformComponent, PlatformWindow, LWWindowPeer$PeerType) line: 156 
        LWCToolkit(LWToolkit).createDelegatedPeer(Window, PlatformComponent, PlatformWindow, LWWindowPeer$PeerType) line: 210   
        LWCToolkit.createEmbeddedFrame(CViewEmbeddedFrame) line: 204    
        CViewEmbeddedFrame.addNotify() line: 55 
        SWT_AWT$1.run() line: not available 
        InvocationEvent.dispatch() line: 311    
        EventQueue.dispatchEventImpl(AWTEvent, Object) line: 756    
        EventQueue.access$500(EventQueue, AWTEvent, Object) line: 97    
        EventQueue$3.run() line: 709    
        EventQueue$3.run() line: 703    
        AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]    
        ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: 76   
        EventQueue.dispatchEvent(AWTEvent) line: 726    
        EventDispatchThread.pumpOneEventForFilters(int) line: 201   
        EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 116    
        EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 105   
        EventDispatchThread.pumpEvents(int, Conditional) line: 101  
        EventDispatchThread.pumpEvents(Conditional) line: 93    
        EventDispatchThread.run() line: 82  
    Daemon Thread [Timer-0] (Suspended) 
        waiting for: TaskQueue  (id=87) 
        Object.wait(long) line: not available [native method]   
        TimerThread.mainLoop() line: 552    
        TimerThread.run() line: 505 
    Daemon Thread [IPC Server Thread] (Suspended)   
        PlainSocketImpl.socketAccept(SocketImpl) line: not available [native method]    
        SocksSocketImpl(AbstractPlainSocketImpl).accept(SocketImpl) line: 409   
        ServerSocket.implAccept(Socket) line: 545   
        ServerSocket.accept() line: 513 
        Server.start(int) line: 81  
        e.run() line: 1237  
        Thread.run() line: 745  
    Daemon Thread [IPC Process Thread] (Suspended)  
        CGraphicsDevice.nativeGetScreenInsets(int) line: not available [native method]  
        CGraphicsDevice.getScreenInsets() line: 128 
        LWCToolkit.getScreenInsets(GraphicsConfiguration) line: 407 
        SwingUtilities$SharedOwnerFrame(Window).init(GraphicsConfiguration) line: 506   
        SwingUtilities$SharedOwnerFrame(Window).<init>() line: 537  
        SwingUtilities$SharedOwnerFrame(Frame).<init>(String) line: 420 
        SwingUtilities$SharedOwnerFrame(Frame).<init>() line: 385   
        SwingUtilities$SharedOwnerFrame.<init>() line: 1758 
        SwingUtilities.getSharedOwnerFrame() line: 1833 
        JWindow.<init>(Frame) line: 187 
        JWindow.<init>() line: 139  
        InternalChromiumProcess.doStart(List<String>) line: 1078    
        InternalChromiumProcess(ChromiumProcess).start(int) line: 123   
        d.run() line: 184   
        Thread.run() line: 745  

0 个答案:

没有答案