#23530 closed defect (othersoftware)
Some SVGs with <use> tag don’t load in mappaint styles: NullPointerException
Reported by: | keepright! ler | Owned by: | team |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | Core mappaint | Version: | tested |
Keywords: | template_report, mapcss, svg, nullpointerexception | Cc: |
Description
What steps will reproduce the problem?
- Create a MapCSS stylesheet with a rule that assigns the osm-carto scrub SVG texture as
fill-image
.- In my case, the code is:
area[natural=scrub] { fill-color: #c8d7ab; } area[natural=scrub]::texture { fill-image: "assets/openstreetmap-carto/symbols/generating_patterns/scrub.svg"; }
- In my case, the code is:
- Load the stylesheet in JOSM and make a
natural=scrub
area. - Be surprised!
What is the expected result?
The scrub texture is displayed on top of the scrub base color.
What happens instead?
The scrub texture doesn’t load: Clock icons are displayed in the scrub area and there is an error in the log:
2024-03-01 17:20:46.767 WARNUNG: Could not parse path null java.lang.NullPointerException: Cannot invoke "java.net.URI.getScheme()" because "uri" is null at com.kitfox.svg.SVGUniverse.cleanUri(SVGUniverse.java:328) at com.kitfox.svg.SVGUniverse.getElement(SVGUniverse.java:363) at com.kitfox.svg.SVGUniverse.getElement(SVGUniverse.java:309) at com.kitfox.svg.Use.getBoundingBox(Use.java:157) at com.kitfox.svg.Group.doRender(Group.java:199) at com.kitfox.svg.BufferPainter.paintElement(BufferPainter.java:57) at com.kitfox.svg.RenderableElement.render(RenderableElement.java:116) at com.kitfox.svg.Group.doRender(Group.java:205) at com.kitfox.svg.SVGRoot.doRender(SVGRoot.java:306) at com.kitfox.svg.BufferPainter.paintElement(BufferPainter.java:57) at com.kitfox.svg.RenderableElement.render(RenderableElement.java:116) at com.kitfox.svg.SVGRoot.renderToViewport(SVGRoot.java:250) at com.kitfox.svg.SVGDiagram.render(SVGDiagram.java:114) at com.kitfox.svg.SVGDiagram.render(SVGDiagram.java:125) at org.openstreetmap.josm.tools.ImageProvider.lambda$createImageFromSvg$3(ImageProvider.java:1472) at org.openstreetmap.josm.tools.ImageResizeMode.createBufferedImage(ImageResizeMode.java:95) at org.openstreetmap.josm.tools.ImageProvider.createImageFromSvg(ImageProvider.java:1469) at org.openstreetmap.josm.tools.ImageResource.getImageIconAlreadyScaled(ImageResource.java:194) at org.openstreetmap.josm.tools.ImageResource.getImageIcon(ImageResource.java:165) at org.openstreetmap.josm.tools.ImageResource.getImageIcon(ImageResource.java:150) at org.openstreetmap.josm.gui.mappaint.styleelement.MapImage.lambda$loadImage$0(MapImage.java:195) at java.base/java.util.concurrent.CompletableFuture.uniAcceptNow(CompletableFuture.java:757) at java.base/java.util.concurrent.CompletableFuture.uniAcceptStage(CompletableFuture.java:735) at java.base/java.util.concurrent.CompletableFuture.thenAccept(CompletableFuture.java:2214) at org.openstreetmap.josm.tools.ImageProvider.getResourceAsync(ImageProvider.java:724) at org.openstreetmap.josm.gui.mappaint.styleelement.MapImage.load(MapImage.java:178) at org.openstreetmap.josm.gui.mappaint.styleelement.MapImage.loadImage(MapImage.java:187) at org.openstreetmap.josm.gui.mappaint.styleelement.MapImage.getImage(MapImage.java:161) at org.openstreetmap.josm.gui.mappaint.styleelement.MapImage.getImage(MapImage.java:115) at org.openstreetmap.josm.gui.mappaint.styleelement.AreaElement.create(AreaElement.java:86) at org.openstreetmap.josm.gui.mappaint.ElemStyles.generateStyles(ElemStyles.java:408) at org.openstreetmap.josm.gui.mappaint.ElemStyles.getImpl(ElemStyles.java:261) at org.openstreetmap.josm.gui.mappaint.ElemStyles.getStyleCacheWithRange(ElemStyles.java:173) at org.openstreetmap.josm.gui.mappaint.ElemStyles.get(ElemStyles.java:150) at org.openstreetmap.josm.data.osm.visitor.paint.ComputeStyleListWorker.add(ComputeStyleListWorker.java:171) at org.openstreetmap.josm.data.osm.visitor.paint.ComputeStyleListWorker.visit(ComputeStyleListWorker.java:143) at org.openstreetmap.josm.data.osm.Way.accept(Way.java:184) at org.openstreetmap.josm.data.osm.visitor.paint.ComputeStyleListWorker.acceptDrawable(ComputeStyleListWorker.java:129) at org.openstreetmap.josm.data.osm.visitor.paint.ComputeStyleListWorker.computeDirectly(ComputeStyleListWorker.java:116) at org.openstreetmap.josm.data.osm.visitor.paint.ComputeStyleListWorker.compute(ComputeStyleListWorker.java:93) at org.openstreetmap.josm.data.osm.visitor.paint.ComputeStyleListWorker.compute(ComputeStyleListWorker.java:34) at java.base/java.util.concurrent.RecursiveTask.exec(RecursiveTask.java:110) at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387) at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312) at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843) at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808) at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Please provide any additional information below. Attach a screenshot if possible.
- The issue occurs with the original SVG file from the osm-carto repository; it won’t display in SVGViewer, too. Kinda makes sense, as the deprecated
xlink:href
(in the actual file:NS1:href
,NS2:href
,NS3:href
and so on …) attribute is used instead ofhref
. - When I fix the SVG by replacing all
NS{number}:href
attributes withhref
, the image displays correctly in SVGViewer, but still not in JOSM. - When I use a different SVG texture (e. g. the beach one), it works everywhere, including in JOSM.
File (attachment) | Firefox Browser | SVGViewer | JOSM |
---|---|---|---|
scrub.svg (original) | working | broken | broken |
scrub-fix.svg | working | working | broken |
beach.svg (different texture) | working | working | working |
Relative:URL: ^/trunk Repository:UUID: 0c6e7542-c601-0410-84e7-c038aed88b3b Last:Changed Date: 2024-02-05 12:56:34 +0100 (Mon, 05 Feb 2024) Revision:18969 Build-Date:2024-02-06 02:30:58 URL:https://josm.openstreetmap.de/svn/trunk Identification: JOSM/1.5 (18969 de) Mac OS X 11.6 OS Build number: macOS 11.6 (20G165) Memory Usage: 508 MB / 1704 MB (63 MB allocated, but free) Java version: 21.0.2+13-LTS, Eclipse Adoptium, OpenJDK 64-Bit Server VM Look and Feel: javax.swing.plaf.metal.MetalLookAndFeel Screen: Display 1 2240×1260 (scaling 2.00×2.00) Maximum Screen Size: 2240×1260 Best cursor sizes: 16×16→16×16, 32×32→32×32 Environment variable LANG: de_DE.UTF-8 System property file.encoding: UTF-8 System property sun.jnu.encoding: UTF-8 Locale info: de_DE Numbers with default locale: 1234567890 -> 1234567890 Dataset consistency test: No problems found Plugins: + ColorPlugin (v1.1.2.1) + Create_grid_of_ways (36178) + FastDraw (36200) + apache-commons (36176) + buildings_tools (36200) + colorscheme (36196) + easypresets (1623509627) + imagery_offset_db (36126) + indoorhelper (1.2.3) + jts (36004) + log4j (36176) + measurement (36200) + merge-overlap (36178) + openqa (v0.3.3) + rasterfilters (1.0.4) + rex (53) + tageditor (36200) + todo (137) + turnlanes-tagging (0.0.5) + turnrestrictions (36200) + utilsplugin2 (36200) Tagging presets: + https://josm.openstreetmap.de/josmfile?page=Presets/NewTags&zip=1 + https://josm.openstreetmap.de/josmfile?page=Presets/Playground_Equipment&zip=1 + https://josm.openstreetmap.de/josmfile?page=Presets/OneClick&zip=1 + https://josm.openstreetmap.de/josmfile?page=Presets/Leaftype&zip=1 + https://josm.openstreetmap.de/josmfile?page=Presets/LaneAttributes&zip=1 + http://osmtools.de/josm/steps.xml + https://josm.openstreetmap.de/josmfile?page=Presets/BuildingPreset&zip=1 + https://josm.openstreetmap.de/josmfile?page=Presets/OSMRookie&zip=1 + https://josm.openstreetmap.de/josmfile?page=Presets/Tracks&zip=1 + https://raw.githubusercontent.com/yopaseopor/traffic_signs_preset_JOSM/master/DE.zip + <josm.userdata>/EasyPresets.xml Map paint styles: - https://josm.openstreetmap.de/josmfile?page=Styles/Surface-DataEntry&style&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Potlach2_access&zip=1 + ${HOME}/Documents/Geography/OpenStreetMap/MapCSS/custom general-purpose opaque.mapcss - https://josm.openstreetmap.de/josmfile?page=Styles/Potlatch2&zip=1 - ${HOME}/Documents/Geography/OpenStreetMap/MapCSS/custom highway.mapcss - ${HOME}/Documents/Geography/OpenStreetMap/MapCSS/custom maxspeed.mapcss - https://github.com/bastik/mapcss-tools/raw/osm/mapnik2mapcss/osm-results/mapnik.zip - https://josm.openstreetmap.de/josmfile?page=Styles/Modified&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Coloured_Streets&style&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Noname&style&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Surface&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Landcover&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/SimpleRoofTags&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/SimpleBuildingTags&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Lane_and_Road_Attributes&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Lane_features_ryg&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Coloured_buildings&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/LayerChecker&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Fixme&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Sidewalks&zip=1 - https://github.com/hotosm/HDM-JOSM-style/archive/master.zip - https://raw.githubusercontent.com/species/josm-preset-wheelchair/master/sidewalks_kerbs.mapcss - https://josm.openstreetmap.de/josmfile?page=Styles/AdvertisingStyle&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/BesideTheRoad_Speed&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/Ph_Typhoon&zip=1 - https://github.com/igitov/forest-josm-style/archive/master.zip - https://josm.openstreetmap.de/josmfile?page=Styles/NewHighwayColors&zip=1 - https://josm.openstreetmap.de/josmfile?page=Styles/NoFeature&zip=1 - <josm.userdata>/styles/indoor.mapcss - <josm.userdata>/plugins/indoorhelper/resources/sit.mapcss Validator rules: + http://openrailwaymap.org/validator/openrailwaymap.validator.mapcss + /Users/irma/Library/JOSM/validator/indoorhelper.validator.mapcss + https://josm.openstreetmap.de/josmfile?page=Rules/GermanySpecific&zip=1 - https://josm.openstreetmap.de/josmfile?page=Rules/SuspiciousSwimming_Pool&zip=1 Last errors/warnings: - 00010.609 E: Id 'Germany-Naturraeume' is not unique - used by 'Physical DE - Physische Karte (Naturräume)' and 'Physical DE - Physische Karte (Naturräume)'! - 00011.876 E: java.nio.file.NoSuchFileException: <josm.userdata>/EasyPresets.xml - 00011.876 E: <josm.userdata>/EasyPresets.xml - 00012.156 W: Hinzufügen von /Users/irma/Library/JOSM/validator/indoorhelper.validator.mapcss zum Merkmalsprüfer fehlgeschlagen - 00012.156 W: java.nio.file.NoSuchFileException: /Users/irma/Library/JOSM/validator/indoorhelper.validator.mapcss - 00108.611 E: Fehler beim Laden des Bildes 'nonexistent' - 00122.579 E: Fehler beim Laden des Bildes 'assets/openstreetmap-carto/symbols/generating_patterns/scrub.svgs' - 01955.519 E: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map sun.awt.AppContext.table accessible: module java.desktop does not "opens sun.awt" to unnamed module @83298d7 - 01956.154 E: java.lang.reflect.InaccessibleObjectException: Unable to make field private final java.util.Map sun.awt.AppContext.table accessible: module java.desktop does not "opens sun.awt" to unnamed module @83298d7
Attachments (3)
Change History (12)
by , 19 months ago
Attachment: | Attachments JOSM Ticket #23530.zip added |
---|
comment:1 by , 19 months ago
I've replaced <use href
by <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href
in scrub-fix.svg and this works. I have no
idea if this is a bug in JOSM or in your data.
comment:2 by , 19 months ago
Hmm, that's a bit strange.
<use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#gSjorsa39f3u43" xmlns:NS1="http://www.w3.org/1999/xlink"
I would expect that xmlns:xlink="http://www.w3.org/1999/xlink"
is specified once in the <svg> top tag and later only xlink:href is used. The xmlns:NSx has no purpose at all anymore, that's a copy and paste issue from the original file.
Attached that variant which works for me and look clean as it should.
NOTE: Included SVG renderer SVGsalamander does not support any strange variant of XML, but only a useful subset.
comment:3 by , 19 months ago
Resolution: | → othersoftware |
---|---|
Status: | new → closed |
beach.svg like the variant from GerdP uses non-strange namespaces. I'd think the variant I provided should still be preferred. There is really no reason to specify the namespace multiple times.
Closing as othersoftware.
While probably your fixed variant is theoretically right I'm not convinced it's useful to implement support for such strange namespace handling ;-)
follow-up: 9 comment:4 by , 19 months ago
Should I forward this issue to the osm-carto GitHub repository? Because that strange linking is used there.
comment:5 by , 19 months ago
Also, is there any way to fix these SVGs in an automated fashion? Because editing these SVGs is really some work!
comment:6 by , 19 months ago
Also, which is SO ANNOYING:
I cannot clear the cached version! Unless I change the filename in my MapCSS file, JOSM wouldn’t load the texture from disk but use the cached (but broken!) version!
HOW CAN I TELL JOSM TO RELOAD ALL TEXTURES?! There is NOTHING to delete in ~/Library/Caches/JOSM
!
comment:7 by , 19 months ago
Resolution: | othersoftware |
---|---|
Status: | closed → reopened |
comment:8 by , 19 months ago
Resolution: | → othersoftware |
---|---|
Status: | reopened → closed |
Oh, I just found out that the SVG texture isn’t rendered in high-DPI … so the PNG texture will actually look better!
But it would still be useful to know for the future how to purge the image texture cache …
comment:9 by , 19 months ago
Replying to keepright! ler:
Should I forward this issue to the osm-carto GitHub repository? Because that strange linking is used there.
Probably. The original files are error prone and waste space.
Sure there are ways to automate such changes. I e.g. used kate editor with regexp search and replace.
But it would still be useful to know for the future how to purge the image texture cache …
Please check our really extensive help instead of extending the scope of closed tickets. A simple google search for "josm cache directory" will result in Help/Preferences as first result.
And BTW JOSM has no texture cache. It has a downloaded file cache or we would uselessly stress servers.
ZIP archive with three icons