LykosAI/StabilityMatrix · error · ValidationException
CurrentBitmapSize is null
Error message
CurrentBitmapSize is null
What it means
Thrown in SelectImageCardViewModel.ApplyStep when the loaded image's bitmap size is empty (width and height 0), which means no valid bitmap dimensions are available for the mask workflow. The mask setup needs the canvas size to scale the mask render to the image, so an empty size is rejected.
Solutions
- Wait for the image to fully load/decode before clicking Generate (check that a preview thumbnail is visible)
- Re-select the image so CurrentBitmapSize is recomputed from the decoded bitmap
- Verify the image file is a valid, non-zero-dimension image
Example fix
// before: CurrentBitmapSize.IsEmpty -> throws
// after: guard before applying
if (vm.CurrentBitmapSize.IsEmpty) { throw new InvalidOperationException("Image not fully loaded"); }
await vm.ApplyStep(args); Defensive patterns
Strategy: validation
Validate before calling
if (vm.ImageSource is not null && vm.CurrentBitmapSize.IsEmpty)
throw new ValidationException("Image is still loading; wait for the preview before generating"); Type guard
bool hasValidBitmapSize = !vm.CurrentBitmapSize.IsEmpty;
Try / catch
try { vm.ApplyStep(args); }
catch (ValidationException ex) when (ex.Message == "CurrentBitmapSize is null") { /* await image load completion */ } Prevention
- Await image decode completion before enabling Generate
- Recompute CurrentBitmapSize whenever ImageSource changes
- Reject zero-dimension image files at selection time
When it happens
Trigger: ApplyStep in the mask branch where CurrentBitmapSize.IsEmpty is true — i.e. ImageSource may be set but the bitmap size was never computed or the image failed to decode.
Common situations: Image load was asynchronous and the size property was read before decoding finished; corrupted or zero-dimension image file selected; bitmap disposed or reset by view state changes before generation starts.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Input Image is required
- API key is required
- Archive must be a zipped tar.
- Definition: ' ' has options, it must have exactly 1 option…
- Definition ' ' has InitialValue of ' ', but it was not…
AI-assisted analysis of LykosAI/StabilityMatrix@af93d6ef57 (2026-09-12).
Data as JSON: /api/errors/6dd88814ef66f081.
Report an issue: GitHub.
Appendix: source
Thrown at StabilityMatrix.Avalonia/ViewModels/Inference/SelectImageCardViewModel.cs:164
}
tabContext.SourceImageWidth = CurrentBitmapSize.Width > 0 ? CurrentBitmapSize.Width : 0;
tabContext.SourceImageHeight = CurrentBitmapSize.Height > 0 ? CurrentBitmapSize.Height : 0;
}
/// <inheritdoc />
public void ApplyStep(ModuleApplyStepEventArgs e)
{
// With Mask image
if (IsMaskEditorEnabled && MaskEditorViewModel.IsMaskEnabled)
{
MaskEditorViewModel.PaintCanvasViewModel.CanvasSize = CurrentBitmapSize;
e.Builder.SetupImagePrimarySourceWithMask(
ImageSource ?? throw new ValidationException("Input Image is required"),
!CurrentBitmapSize.IsEmpty
? CurrentBitmapSize
: throw new ValidationException("CurrentBitmapSize is null"),
MaskEditorViewModel.GetCachedOrNewMaskRenderInverseAlphaImage(),
MaskEditorViewModel.PaintCanvasViewModel.CanvasSize,
e.Builder.Connections.BatchIndex
);
}
// Normal image only
else
{
e.Builder.SetupImagePrimarySource(
ImageSource ?? throw new ValidationException("Input Image is required"),
!CurrentBitmapSize.IsEmpty
? CurrentBitmapSize
: throw new ValidationException("CurrentBitmapSize is null"),
e.Builder.Connections.BatchIndex
);
}
}
View on GitHub (pinned to af93d6ef57)