{"record":{"id":"6dd88814ef66f081","repo":"LykosAI/StabilityMatrix","slug":"currentbitmapsize-is-null","errorCode":null,"errorMessage":"CurrentBitmapSize is null","messagePattern":"CurrentBitmapSize is null","errorType":"validation","errorClass":"ValidationException","httpStatus":null,"severity":"error","filePath":"StabilityMatrix.Avalonia/ViewModels/Inference/SelectImageCardViewModel.cs","lineNumber":164,"sourceCode":"        }\n\n        tabContext.SourceImageWidth = CurrentBitmapSize.Width > 0 ? CurrentBitmapSize.Width : 0;\n        tabContext.SourceImageHeight = CurrentBitmapSize.Height > 0 ? CurrentBitmapSize.Height : 0;\n    }\n\n    /// <inheritdoc />\n    public void ApplyStep(ModuleApplyStepEventArgs e)\n    {\n        // With Mask image\n        if (IsMaskEditorEnabled && MaskEditorViewModel.IsMaskEnabled)\n        {\n            MaskEditorViewModel.PaintCanvasViewModel.CanvasSize = CurrentBitmapSize;\n\n            e.Builder.SetupImagePrimarySourceWithMask(\n                ImageSource ?? throw new ValidationException(\"Input Image is required\"),\n                !CurrentBitmapSize.IsEmpty\n                    ? CurrentBitmapSize\n                    : throw new ValidationException(\"CurrentBitmapSize is null\"),\n                MaskEditorViewModel.GetCachedOrNewMaskRenderInverseAlphaImage(),\n                MaskEditorViewModel.PaintCanvasViewModel.CanvasSize,\n                e.Builder.Connections.BatchIndex\n            );\n        }\n        // Normal image only\n        else\n        {\n            e.Builder.SetupImagePrimarySource(\n                ImageSource ?? throw new ValidationException(\"Input Image is required\"),\n                !CurrentBitmapSize.IsEmpty\n                    ? CurrentBitmapSize\n                    : throw new ValidationException(\"CurrentBitmapSize is null\"),\n                e.Builder.Connections.BatchIndex\n            );\n        }\n    }\n","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/LykosAI/StabilityMatrix/blob/af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002/StabilityMatrix.Avalonia/ViewModels/Inference/SelectImageCardViewModel.cs#L146-L182","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before: CurrentBitmapSize.IsEmpty -> throws\n// after: guard before applying\nif (vm.CurrentBitmapSize.IsEmpty) { throw new InvalidOperationException(\"Image not fully loaded\"); }\nawait vm.ApplyStep(args);","handlingStrategy":"validation","validationCode":"if (vm.ImageSource is not null && vm.CurrentBitmapSize.IsEmpty)\n    throw new ValidationException(\"Image is still loading; wait for the preview before generating\");","typeGuard":"bool hasValidBitmapSize = !vm.CurrentBitmapSize.IsEmpty;","tryCatchPattern":"try { vm.ApplyStep(args); }\ncatch (ValidationException ex) when (ex.Message == \"CurrentBitmapSize is null\") { /* await image load completion */ }","preventionTips":["Await image decode completion before enabling Generate","Recompute CurrentBitmapSize whenever ImageSource changes","Reject zero-dimension image files at selection time"],"tags":["validation","bitmap","image-input"],"backgroundTag":"missing-required-argument","analyzedSha":"af93d6ef57c01cd890d7e0ad0a9ea8c9fcda3002","analyzedAt":"2026-09-12T19:02:43.389Z","contentChangedAt":"2026-09-12T19:02:43.389Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}