Modify

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#13024 closed defect (fixed)

NPE at loading new WMS layer

Reported by: slodki Owned by: team
Priority: major Milestone: 16.06
Component: Core imagery Version: latest
Keywords: NPE paintLayer getNativeScales getBestZoom WMS regression gsoc-core Cc: wiktorn, michael2402

Description

What steps will reproduce the problem?

  1. Start JOSM
  2. Load data from OSM for selected region in Poland
  3. Add layer with geoportal ortophoto (WMS)

What is the expected result?

Background displayed (new layer added)

What happens instead?

No layer added, no background displayed.
GUI is flooded with exception pop-up (every few seconds)

Please provide any additional information below. Attach a screenshot if possible.

URL:http://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2016-06-21 01:29:31 +0200 (Tue, 21 Jun 2016)
Build-Date:2016-06-21 01:33:29
Revision:10448
Relative:URL: ^/trunk

Identification: JOSM/1.5 (10448 pl) Linux Slackware 14.2
Memory Usage: 426 MB / 898 MB (265 MB allocated, but free)
Java version: 1.8.0_91-b14, Oracle Corporation, OpenJDK Server VM
Dataset consistency test: No problems found

Plugins:
- OpeningHoursEditor (32158)

Tagging presets:
- https://josm.openstreetmap.de/josmfile?page=Presets/Heritage&preset&zip=1

Map paint styles:
- https://github.com/bastik/mapcss-tools/raw/osm/mapnik2mapcss/osm-results/mapnik.zip
- https://josm.openstreetmap.de/josmfile?page=Styles/Lane_features&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/Lit&zip=1
- https://josm.openstreetmap.de/josmfile?page=Styles/SimpleRoofTags&style&zip=1

Last errors/warnings:
- E: org.openstreetmap.josm.tools.bugreport.ReportedException: java.lang.NullPointerException. Przyczyna: java.lang.NullPointerException
- E: org.openstreetmap.josm.tools.bugreport.ReportedException: java.lang.NullPointerException. Przyczyna: java.lang.NullPointerException
- E: org.openstreetmap.josm.tools.bugreport.ReportedException: java.lang.NullPointerException. Przyczyna: java.lang.NullPointerException
- E: org.openstreetmap.josm.tools.bugreport.ReportedException: java.lang.NullPointerException. Przyczyna: java.lang.NullPointerException
- E: org.openstreetmap.josm.tools.bugreport.ReportedException: java.lang.NullPointerException. Przyczyna: java.lang.NullPointerException

=== REPORTED CRASH DATA ===
MapView#paintLayer:
 - layer: org.openstreetmap.josm.gui.layer.WMTSLayer@b7f85b
 - bounds: Bounds[50.0302649,19.9881966,50.0360328,19.9975279]

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (16) of main
java.lang.NullPointerException
	at org.openstreetmap.josm.gui.layer.WMTSLayer.getNativeScales(WMTSLayer.java:123)
	at org.openstreetmap.josm.gui.layer.WMTSLayer.getBestZoom(WMTSLayer.java:64)
	at org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer.paint(AbstractTileSourceLayer.java:1449)
	at org.openstreetmap.josm.gui.MapView.paintLayer(MapView.java:775)
	at org.openstreetmap.josm.gui.MapView.paint(MapView.java:846)
	at javax.swing.JComponent.paintChildren(JComponent.java:880)
	at javax.swing.JComponent.paint(JComponent.java:1056)
	at javax.swing.JComponent.paintToOffscreen(JComponent.java:5201)
	at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:290)
	at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
	at javax.swing.JComponent._paintImmediately(JComponent.java:5149)
	at javax.swing.JComponent.paintImmediately(JComponent.java:4960)
	at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
	at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
	at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
	at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
	at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Attachments (1)

patch-fix-13024.patch (1.7 KB ) - added by michael2402 9 years ago.

Download all attachments as: .zip

Change History (13)

comment:1 by Don-vip, 9 years ago

Cc: wiktorn michael2402 added
Keywords: regression added
Milestone: 16.06
Priority: normalmajor

comment:2 by michael2402, 9 years ago

Caused by moving hookUpMapView after all layerAdded() calls and thus after the setting of the native scale layer in [10391].

I am currently working on replacing that hook with a new one called from MapView. It will be called multiple times if there are multiple map views. This issue can be fixed by creating the tile source there.

Fixed in this branch (not ready to merge)
https://github.com/michaelzangl/josm/commits/layer-manager-mapview-attach

comment:3 by stoecker, 9 years ago

Keywords: gsoc-core added

comment:4 by malenki, 9 years ago

I have a similar but not identical issue.
When looking the region around https://www.openstreetmap.org/way/26604122
and adding one of the NRW-Atlas WMS layers an exception shows up¹ but only one time when adding a layer.
The imagery gets displayed and I can go on mapping.
Bing and Mapbox Imagery is fine.

¹

URL:http://josm.openstreetmap.de/svn/trunk
Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b
Last:Changed Date: 2016-06-23 02:35:10 +0200 (Thu, 23 Jun 2016)
Build-Date:2016-06-23 01:34:05
Revision:10463
Relative:URL: ^/trunk

Identification: JOSM/1.5 (10463 de) Linux Debian GNU/Linux unstable (sid)
Memory Usage: 537 MB / 2222 MB (93 MB allocated, but free)
Java version: 1.8.0_91-b14, Oracle Corporation, Java HotSpot(TM) 64-Bit Server VM
VM arguments: [-Dsun.java2d.opengl=false]
Dataset consistency test: No problems found


Last errors/warnings:
- W: java.io.IOException: Attribution is not loaded yet
- W: java.io.IOException: Attribution is not loaded yet
- W: java.io.IOException: Attribution is not loaded yet
- E: org.openstreetmap.josm.tools.bugreport.ReportedException: java.lang.IllegalArgumentException: Cannot paint layer, it is not registered.. Ursache: java.lang.IllegalArgumentException: Cannot paint layer, it is not registered.
- E: org.openstreetmap.josm.tools.bugreport.ReportedException: java.lang.IllegalArgumentException: Cannot paint layer, it is not registered.. Ursache: java.lang.IllegalArgumentException: Cannot paint layer, it is not registered.

=== REPORTED CRASH DATA ===
MapView#paintLayer:
 - layer: org.openstreetmap.josm.gui.layer.WMSLayer@6954a62d
 - bounds: Bounds[52.1631764,8.4605476,52.1642952,8.4640989]

=== STACK TRACE ===
Thread: AWT-EventQueue-0 (17) of main
java.lang.IllegalArgumentException: Cannot paint layer, it is not registered.
	at org.openstreetmap.josm.gui.MapView.paintLayer(MapView.java:785)
	at org.openstreetmap.josm.gui.MapView.paint(MapView.java:857)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JSplitPane.paintChildren(JSplitPane.java:1047)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JLayeredPane.paint(JLayeredPane.java:586)
	at javax.swing.JComponent.paintChildren(JComponent.java:889)
	at javax.swing.JComponent.paint(JComponent.java:1065)
	at javax.swing.JComponent.paintToOffscreen(JComponent.java:5210)
	at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:290)
	at javax.swing.RepaintManager.paint(RepaintManager.java:1272)
	at javax.swing.JComponent._paintImmediately(JComponent.java:5158)
	at javax.swing.JComponent.paintImmediately(JComponent.java:4969)
	at javax.swing.RepaintManager$4.run(RepaintManager.java:831)
	at javax.swing.RepaintManager$4.run(RepaintManager.java:814)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:814)
	at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:789)
	at javax.swing.RepaintManager.prePaintDirtyRegions(RepaintManager.java:738)
	at javax.swing.RepaintManager.access$1200(RepaintManager.java:64)
	at javax.swing.RepaintManager$ProcessingRunnable.run(RepaintManager.java:1732)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:109)
	at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:184)
	at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:229)
	at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:227)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:227)
	at java.awt.Dialog.show(Dialog.java:1084)
	at java.awt.Component.show(Component.java:1673)
	at java.awt.Component.setVisible(Component.java:1625)
	at java.awt.Window.setVisible(Window.java:1014)
	at java.awt.Dialog.setVisible(Dialog.java:1005)
	at org.openstreetmap.josm.gui.ExtendedDialog.setVisible(ExtendedDialog.java:502)
	at org.openstreetmap.josm.gui.ExtendedDialog.showDialog(ExtendedDialog.java:289)
	at org.openstreetmap.josm.gui.layer.WMSLayer.projectionChanged(WMSLayer.java:146)
	at org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer.initializeIfRequired(AbstractTileSourceLayer.java:649)
	at org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer.attachToMapView(AbstractTileSourceLayer.java:624)
	at org.openstreetmap.josm.gui.MapView.layerAdded(MapView.java:605)
	at org.openstreetmap.josm.gui.layer.LayerManager.fireLayerAdded(LayerManager.java:357)
	at org.openstreetmap.josm.gui.layer.LayerManager.realAddLayer(LayerManager.java:176)
	at org.openstreetmap.josm.gui.layer.MainLayerManager.realAddLayer(MainLayerManager.java:200)
	at org.openstreetmap.josm.gui.layer.LayerManager$1.run(LayerManager.java:163)
	at org.openstreetmap.josm.gui.util.GuiHelper.runInEDTAndWaitWithException(GuiHelper.java:146)
	at org.openstreetmap.josm.gui.layer.LayerManager.addLayer(LayerManager.java:160)
	at org.openstreetmap.josm.actions.AddImageryLayerAction.actionPerformed(AddImageryLayerAction.java:82)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
	at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
	at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
	at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
	at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:289)
	at java.awt.Component.processMouseEvent(Component.java:6535)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
	at java.awt.Component.processEvent(Component.java:6300)
	at java.awt.Container.processEvent(Container.java:2236)
	at java.awt.Component.dispatchEventImpl(Component.java:4891)
	at java.awt.Container.dispatchEventImpl(Container.java:2294)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
	at java.awt.Container.dispatchEventImpl(Container.java:2280)
	at java.awt.Window.dispatchEventImpl(Window.java:2750)
	at java.awt.Component.dispatchEvent(Component.java:4713)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:86)
	at java.awt.EventQueue$4.run(EventQueue.java:731)
	at java.awt.EventQueue$4.run(EventQueue.java:729)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

comment:5 by wiktorn, 9 years ago

Original problem should be fixed with [10458].

The problem that malenki is reporting is a bit different, and we have kind of race between MapView.layerAdded():

  • layerAdded() registers LayerPainter
  • LayerPainter creation is triggers initialization code that needs sometimes to show warning dialogs to the user, which will fire events trying to draw the layer, that has no LayerPainter defined yet

I guess that we have here onLayerAdd event (before adding the layer in LayerManager) and not after it is added. Maybe distinguishing these two situations will clean up this situation.

comment:6 by malenki, 9 years ago

I'd be glad to report "my" problem as a separate issue if needed. :)

by michael2402, 9 years ago

Attachment: patch-fix-13024.patch added

comment:7 by michael2402, 9 years ago

I attached a file that should fix the second issue.

This allows the layer to be drawn before being completely added.

We would not solve this by using an onLayerAdded event because in the event that we want to use multiple map views it is likely that one of them is created after adding some layers, so the map view needs to support this.

comment:8 by wiktorn, 9 years ago

Resolution: fixed
Status: newclosed

In 10474/josm:

Use WarningLayerPainter as a temporary painter for layers during initialization

Patch by: michael2402 - gsoc-core
Closes: #13024

in reply to:  7 comment:9 by wiktorn, 9 years ago

Replying to michael2402:

I attached a file that should fix the second issue.

This allows the layer to be drawn before being completely added.

Thanks, this fixes the problem. I lowered the log level, as this is normal situation, that not fully initialized layer is being drawn.

comment:10 by michael2402, 9 years ago

This is always triggered by a layer delaying the addition of itself.

The problem I see is that layers should not really do any work when being added. If they remove themselves we might get more state problems...

The best thing for them would be to return a painter that just paints nothing and then ask the user if the layer should really be painted (e.g. out of memory, ...)

in reply to:  10 comment:11 by wiktorn, 9 years ago

Replying to michael2402:

This is always triggered by a layer delaying the addition of itself.

The problem I see is that layers should not really do any work when being added. If they remove themselves we might get more state problems...

The best thing for them would be to return a painter that just paints nothing and then ask the user if the layer should really be painted (e.g. out of memory, ...)

So the solution would be, to return a painter, that paints the warning and after the warning is closed, replace the painter with the proper one?

comment:12 by michael2402, 9 years ago

Yes. You can use the same painter and simply do nothing in the paint() method until the problem is resolved.

We can use the notification mechanism used e.g. for the layer displacement here. That way the user flow is not interrupted by the message and the user is notified about the problem.

This would even allow the user to remove an other sat layer so that the current one is displayed. If we add onShow and onHide calls to the painter we can even allow the user to free some memory by hiding layers and then automatically painting the new one.

Last edited 9 years ago by michael2402 (previous) (diff)

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain team.
as The resolution will be set.
The resolution will be deleted. Next status will be 'reopened'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.