JXMapKit/-Viewer 作为 webstartable 非常慢 - 从哪里开始挖掘? [英] JXMapKit/-Viewer extremely slow as webstartable - where to start digging?

查看:31
本文介绍了JXMapKit/-Viewer 作为 webstartable 非常慢 - 从哪里开始挖掘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚尝试向整个 swinglabs 演示中添加一些 swingx-ws 组件 - 并注意到一个简单的 JXMapKit/-Viewer 在 webstartable 与本地加载相比.

Just tried to add some swingx-ws components to the overall swinglabs demos - and noticed that a simple JXMapKit/-Viewer is orders of magnitude slower to load the tiles in the webstartable compared to loading locally.

我不知道应该从哪里开始寻找(用户界面更新似乎在 EDT 上,但可能需要仔细查看):

Rather lost on where I should start looking (ui updates seem to be on the EDT, though might need a closer look):

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

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

The code is rather straightforward (to run locally, you'll need swingx and 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);
            }
        });
    }

}

编辑:

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

seems like it's somehow related to permission checking in the web context: profiling shows that the whole connection call stack is different (not overly surprising) and takes ages. Giving up for now ..

编辑 2:

似乎有两个不同的问题

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

要重现阻塞,请运行 SimpleWSDemoApp,等到地图可见(需要一些时间,这是第一个问题)然后使用鼠标快速上下移动缩放拇指:ui 完全被阻止.在普通框架(顶部的参考)上做同样的事情有初始加载等待,但永远无法重现阻塞.

To reproduce the blocking, run the SimpleWSDemoApp, wait until the map is visible (takes some time, that's the first issue) then use the mouse to move the zoom thumb quickly up and down: the ui is completely blocked. Doing the same on the plain frame (the reference on top) has the initial loading wait, but couldn't ever reproduce the blocking.

奇怪的东西(对我来说)是从 VisualVM 的线程转储中阻止 EDT:

The weird thingy (to me) is what blocks the EDT, from the thread dump of 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)

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

that is dragging the mouse kicks in checking permission for clipboard access ...

推荐答案

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

A Web Start app is also a JVM process so you can try to profile it with VisualVM (this entry describes how to do that). It's also worth to profile both applications with VisualVM and compare JVM settings like heap size, JIT compiler differences. I think that a Web Start application runs with client compiler, which is slower by means of produced native code than a server compiler.

这篇关于JXMapKit/-Viewer 作为 webstartable 非常慢 - 从哪里开始挖掘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆