Hi, I need to load some SVG icons. I do this via IconUtil.toImage(icon)
.
Unfortunately, it logs an error when it fails to load an SVG file.
Here are the logged messages:
2025-06-15 13:54:37,153 [ 16021] SEVERE - #c.i.u.i.ScaledIconCache - Cannot invoke "com.github.weisj.jsvg.renderer.awt.PlatformSupport.b()" because "context.a" is null
java.lang.NullPointerException: Cannot invoke "com.github.weisj.jsvg.renderer.awt.PlatformSupport.b()" because "context.a" is null
at com.github.weisj.jsvg.cJ.intrinsicSize(SourceFile:45)
at com.github.weisj.jsvg.aM.a(SourceFile:118)
at com.github.weisj.jsvg.bf.a(SourceFile:179)
at com.github.weisj.jsvg.bn.a(SourceFile:1101)
at com.github.weisj.jsvg.bl.a(SourceFile:140)
at com.github.weisj.jsvg.aU.a(SourceFile:186)
at com.github.weisj.jsvg.aU.c(SourceFile:147)
at com.github.weisj.jsvg.cO.a(SourceFile:81)
at com.github.weisj.jsvg.aU.a(SourceFile:147)
at com.github.weisj.jsvg.cV.a(SourceFile:1158)
at com.github.weisj.jsvg.ba.a(SourceFile:152)
at com.github.weisj.jsvg.bn.a(SourceFile:1101)
at com.github.weisj.jsvg.bn.a(SourceFile:1101)
at com.github.weisj.jsvg.bn.a(SourceFile:1101)
at com.github.weisj.jsvg.bl.a(SourceFile:140)
at com.github.weisj.jsvg.nodes.SVG.renderWithSize(SourceFile:144)
at com.intellij.ui.svg.JsvgKt.renderSvgWithSize(jsvg.kt:46)
at com.intellij.ui.svg.JsvgKt.renderSvg(jsvg.kt:19)
at com.intellij.ui.svg.JsvgKt.renderSvg$default(jsvg.kt:10)
at com.intellij.ui.svg.SvgKt.renderImage(svg.kt:291)
at com.intellij.ui.svg.SvgKt.renderAndCache(svg.kt:258)
at com.intellij.ui.svg.SvgKt.access$renderAndCache(svg.kt:1)
at com.intellij.ui.svg.SvgKt.loadSvgAndCacheIfApplicable-F6nGey4(svg.kt:567)
at com.intellij.ui.icons.ImageCacheKt.doLoadByDescriptor(imageCache.kt:241)
at com.intellij.ui.icons.ImageCacheKt.loadByDescriptorWithoutCache(imageCache.kt:148)
at com.intellij.ui.icons.ImageCacheKt.loadImage(imageCache.kt:111)
at com.intellij.ui.icons.ImageCacheKt.loadImage$default(imageCache.kt:64)
at com.intellij.ui.icons.ImageDataByPathResourceLoader.loadImage(ImageDataByUrlLoader.kt:67)
at com.intellij.ui.icons.CachedImageIcon.loadImage-Xbo1f9k$intellij_platform_util_ui(CachedImageIcon.kt:351)
at com.intellij.ui.icons.ScaledIconCache.loadIcon-GvFvY-8(ScaledIconCache.kt:62)
at com.intellij.ui.icons.ScaledIconCache.getCachedIcon-BVbfYdY(ScaledIconCache.kt:43)
at com.intellij.ui.icons.CachedImageIcon.resolveActualIcon(CachedImageIcon.kt:187)
at com.intellij.ui.icons.CachedImageIcon.getIconWidth(CachedImageIcon.kt:148)
I already catch the exception. The problem is that it logs messages with SEVERE severity before raising any exception. And you know what happens when something logs a severe/error message: users see an error report. I’d like to prevent that.
I used to silent these logs by reconfiguring the loggers, per example:
Logger.getFactory().getLoggerInstance(com.intellij.ui.icons.ScaledIconCache.class.getName()).setLevel(LogLevel.OFF);
but it doesn’t help. I can’t say if I’m reconfiguring the wrong loggers, or if the IDE prevents this. Logs seems to come from ScaledIconCache
, and I reconfigured its logger…
In the past, I was using my own version of JSVG, and I was able to silent these loggers. Now, IJ is using its own fork of JSVG, and I’m using it. This fork is private, and it seems (partially) obfuscated, which doesn’t help.
Any help would be appreciated. Thanks!