浏览器非常慢,因为webstartable

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

相反,我应该开始寻找的东西丢失(更新似乎在美国东部时间,尽管可能需要仔细观察):

  • 任何其他人经历不同的加载时间?
  • 任何猜测可能是什么原因?
  • 如何调试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);
                }
            });
        }
    
    }
    

    编辑

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

    编辑2

    似乎有两个单独的问题

  • 在安全受限的上下文中打开用于加载切片的连接需要的时间稍长一点,这是JavaWebStartSecurity.checkConnect(String,int)中的热点,如@Howard已经提到的那样。
  • 似乎只有在MapKit用于SingleFrameApplication(BSAF)时才会发生EDT的奇怪阻塞,
  • 要重现阻塞,请运行SimpleWSDemoApp,等待地图可见(需要一些时间,这是第一个问题),然后使用鼠标快速上下移动缩放大拇指:UI完全被阻塞。 在普通框架(顶部的参考)上做同样的事情有最初的加载等待,但不能再现阻塞。

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

    "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)
    

    即拖动鼠标踢入检查剪贴板访问的权限...


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

    链接地址: http://www.djcxy.com/p/12757.html

    上一篇: Viewer extremely slow as webstartable

    下一篇: Icon exists in systray?