Flow-Launcher/Flow.Launcher · warning · InvalidOperationException
Invalid SVG dimensions: Height must be greater than zero in
Error message
Invalid SVG dimensions: Height must be greater than zero in {path} What it means
Thrown as InvalidOperationException from LoadSvgImage when, after parsing the SVG with FileSvgReader, drawing.Bounds.Height is <= 0. The renderer cannot compute a scale factor (desiredHeight / 0 would be infinity/NaN) so rendering is aborted. This guards the subsequent RenderTargetBitmap creation which would otherwise throw or produce a degenerate image.
Source
Thrown at Flow.Launcher.Infrastructure/Image/ImageLoader.cs:518
{
// Set up drawing settings
var desiredHeight = loadFullImage ? FullImageSize : SmallIconSize;
var drawingSettings = new WpfDrawingSettings
{
IncludeRuntime = true,
// Set IgnoreRootViewbox to false to respect the SVG's viewBox
IgnoreRootViewbox = false
};
// Load and render the SVG
var converter = new FileSvgReader(drawingSettings);
var drawing = converter.Read(new Uri(path));
// Calculate scale to achieve desired height
var drawingBounds = drawing.Bounds;
if (drawingBounds.Height <= 0)
{
throw new InvalidOperationException($"Invalid SVG dimensions: Height must be greater than zero in {path}");
}
var scale = desiredHeight / drawingBounds.Height;
var scaledWidth = drawingBounds.Width * scale;
var scaledHeight = drawingBounds.Height * scale;
// Convert the Drawing to a Bitmap
var drawingVisual = new DrawingVisual();
using (DrawingContext drawingContext = drawingVisual.RenderOpen())
{
drawingContext.PushTransform(new ScaleTransform(scale, scale));
drawingContext.DrawDrawing(drawing);
}
// Create a RenderTargetBitmap to hold the rendered image
var bitmap = new RenderTargetBitmap(
(int)Math.Ceiling(scaledWidth),
(int)Math.Ceiling(scaledHeight),
96, // DpiXView on GitHub (pinned to 7fc63b07bb)
Solutions
- Open the SVG in a browser/editor and confirm it renders with a real size.
- Add explicit width and height (or a viewBox) attributes to the <svg> root element.
- If the SVG is third-party, replace it with a version that declares dimensions or convert it to PNG.
- Handle the failure upstream by catching InvalidOperationException in the image loader and falling back to a default icon.
Example fix
// before <svg xmlns="http://www.w3.org/2000/svg">...</svg> // after — declare a viewBox so the renderer computes bounds <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24">...</svg>
Defensive patterns
Strategy: try-catch
Validate before calling
using var reader = XmlReader.Create(path);
var doc = XDocument.Load(reader);
var root = doc.Root;
if (root?.Attribute("viewBox") == null && root?.Attribute("width") == null)
return LoadDefaultIcon(); Type guard
// Ensure the SVG root declares a viewBox or width/height
static bool IsSvgRenderable(string path)
{
var doc = XDocument.Load(path);
var svg = doc.Root;
return svg?.Attribute("viewBox") != null
|| (svg?.Attribute("width") != null && svg?.Attribute("height") != null);
} Try / catch
try { return LoadSvgImage(path); }
catch (InvalidOperationException ex) when (ex.Message.Contains("SVG dimensions"))
{ Log.Warn(ClassName, $"Unrenderable SVG: {path}"); return LoadDefaultIcon(); } Prevention
- Author icon SVGs with explicit width/height or a viewBox attribute.
- Validate SVGs in an editor/browser before shipping them.
- Provide a fallback PNG/icon for assets that fail to render.
- Strip web-only percentage/CSS sizing from SVGs used as app icons.
When it happens
Trigger: An SVG with no explicit width/height and no viewBox (Bounds stays at 0,0,0,0); an SVG whose root element has width/height of 0 or negative; a malformed SVG that FileSvgReader partially parses leaving an empty Drawing; an SVG that uses only CSS-based sizing that the SVG renderer doesn't resolve.
Common situations: Plugin author ships an icon SVG exported with no dimensions; web-optimized SVG stripped of width/height attributes; an SVG referencing external resources that fail to load, collapsing the bounds; an SVG designed with percentage-based sizing only.
Related errors
- The zip file does not contain a plugin.json file.
- Failed to get IShellItemImageFactory
- Failed to get thumbnail
- DoublePinyinSchema '{schemaKey}' is invalid or double pinyin
- Invalid corner type
AI-assisted analysis of Flow-Launcher/Flow.Launcher@7fc63b07bb (2026-08-13).
Data as JSON: /api/errors/8929bd106febdf88.
Report an issue: GitHub.