7

刚刚尝试将一些 swingx-ws 组件添加到整个 swinglabs 演示中 - 并注意到与本地加载相比,一个简单的 JXMapKit/-Viewer 在webstartable中加载图块的速度要慢几个数量级。

相当迷失在我应该从哪里开始寻找(ui 更新似乎在 EDT 上,但可能需要仔细查看):

  • 还有其他人经历不同的加载时间吗?
  • 任何猜测可能是什么原因?
  • 如何调试 webstartable?

代码相当简单(要在本地运行,您需要swingx 和 swingx-ws

public class WSDemo {

    private JComponent createContent() {
        JComponent content = new JPanel();
        content.setLayout(new BorderLayout());

        content.add(createMapKit()); 
        return content;
    }

    protected JComponent createMapKit() {
        final int max = 17;
        TileFactoryInfo info = new TileFactoryInfo(1, max - 2, max, 256, true,
                true, // tile size is 256 and x/y orientation is normal
                "http://tile.openstreetmap.org",// 5/15/10.png",
                "x", "y", "z") {
            public String getTileUrl(int x, int y, int zoom) {
                zoom = max - zoom;
                String url = this.baseURL + "/" + zoom + "/" + x + "/" + y
                        + ".png";
                return url;
            }

        };
        DefaultTileFactory tf = new DefaultTileFactory(info);
        tf.setThreadPoolSize(1);
        final JXMapKit kit = new JXMapKit();
        kit.setTileFactory(tf);
        kit.setZoom(10);
        kit.setAddressLocation(new GeoPosition(51.5, 0));
        kit.getMainMap().setDrawTileBorders(true);
        return kit;
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                JFrame frame = new JFrame("");
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.add(new WSDemo().createContent());
                frame.setLocationByPlatform(true);
                frame.setSize(400, 400);
                frame.setVisible(true);
            }
        });
    }

}

编辑

似乎它与网络上下文中的权限检查有某种关系:分析表明整个连接调用堆栈是不同的(不过分令人惊讶)并且需要很长时间。暂时放弃..

编辑 2

似乎有2个不同的问题

  • 正如@Howard 已经指出的那样,打开连接以在安全受限的上下文中加载磁贴所需的时间稍长,即 JavaWebStartSecurity.checkConnect(String, int) 中的热点。
  • 一个相当奇怪的 EDT 阻塞似乎只有在 mapKit 用于 SingleFrameApplication(BSAF)时才会发生

要重现阻塞,运行SimpleWSDemoApp,等到地图可见(需要一些时间,这是第一个问题),然后使用鼠标快速上下移动缩放拇指:ui 完全被阻塞。在普通帧(顶部的参考)上执行相同操作会等待初始加载,但无法重现阻塞。

奇怪的事情(对我来说)是什么阻止了 EDT,来自 VisualVM 的线程转储:

"AWT-EventQueue-0" prio=6 tid=0x063d3000 nid=0x1468 waiting for monitor entry [0x05efe000]
   java.lang.Thread.State: BLOCKED (on object monitor)
    at java.security.Permissions.implies(Unknown Source)
    - waiting to lock <0x29f7b118> (a java.security.Permissions)
    at sun.security.provider.PolicyFile.implies(Unknown Source)
    at java.security.ProtectionDomain.implies(Unknown Source)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkSystemClipboardAccess(Unknown Source)
    at java.awt.event.InputEvent.canAccessSystemClipboard(Unknown Source)
    at java.awt.event.InputEvent.<init>(Unknown Source)
    at java.awt.event.MouseEvent.<init>(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$200(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)

即拖动鼠标会检查剪贴板访问权限...

4

1 回答 1

3

Web Start 应用程序也是一个 JVM 进程,因此您可以尝试使用VisualVM对其进行分析(此条目描述了如何执行此操作)。使用 VisualVM 分析这两个应用程序并比较 JVM 设置(如堆大小、JIT 编译器差异)也是值得的。我认为 Web Start 应用程序使用客户端编译器运行,生成本机代码的速度比服务器编译器慢。

于 2013-04-09T15:34:27.393 回答