{"record":{"id":"7b439820dab84caf","repo":"dotnet/maui","slug":"bindable","errorCode":null,"errorMessage":"bindable","messagePattern":"bindable","errorType":"exception","errorClass":"ArgumentNullException","httpStatus":null,"severity":"error","filePath":"src/Compatibility/Core/src/iOS/Renderers/ImageElementManager.cs","lineNumber":359,"sourceCode":"\t\t\t\t{\n\t\t\t\t\tif (element != null && onLoading != null)\n\t\t\t\t\t{\n\t\t\t\t\t\t// only mark as finished if we are still on the same image\n\t\t\t\t\t\tif (element.GetValue(imageSourceProperty) == initialSource)\n\t\t\t\t\t\t\tonLoading.Invoke(false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tonSet(null);\n\t\t\t\tonLoading?.Invoke(false);\n\t\t\t}\n\t\t}\n\n\t\tinternal static async Task ApplyNativeImageAsync(this BindableObject bindable, BindableProperty imageSourceProperty, Action<NativeImage> onSet, Action<bool> onLoading = null, CancellationToken cancellationToken = default(CancellationToken))\n\t\t{\n\t\t\t_ = bindable ?? throw new ArgumentNullException(nameof(bindable));\n\t\t\t_ = imageSourceProperty ?? throw new ArgumentNullException(nameof(imageSourceProperty));\n\t\t\t_ = onSet ?? throw new ArgumentNullException(nameof(onSet));\n\n\t\t\tonLoading?.Invoke(true);\n\t\t\tif (bindable.GetValue(imageSourceProperty) is ImageSource initialSource)\n\t\t\t{\n\t\t\t\ttry\n\t\t\t\t{\n\t\t\t\t\tusing (var nsimage = await initialSource.GetNativeImageAsync(cancellationToken))\n\t\t\t\t\t{\n\t\t\t\t\t\t// only set if we are still on the same image\n\t\t\t\t\t\tif (bindable.GetValue(imageSourceProperty) == initialSource)\n\t\t\t\t\t\t\tonSet(nsimage);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tfinally\n\t\t\t\t{\n\t\t\t\t\tif (onLoading != null)","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/dotnet/maui/blob/f377ff1c5ee04d334d8a925f50c83a6b7afddf03/src/Compatibility/Core/src/iOS/Renderers/ImageElementManager.cs#L341-L377","documentation":"A second ApplyNativeImageAsync overload extends BindableObject directly (no renderer needed). It calls bindable.GetValue(imageSourceProperty) (line 366), so a null bindable is rejected. Use this when you have only the element/control, not its platform renderer.","triggerScenarios":"Calling the extension on a null BindableObject receiver, e.g. when an element was already disposed/unparented before the async image load continued.","commonSituations":"Async continuation running after the page popped (element nulled out); weak-reference cleanup leaving the bindable null.","solutions":["Capture the element in a local and null-check before awaiting the image load continuation.","Use a CancellationToken tied to the element's lifecycle and cancel on unload.","Prefer calling this overload on a strongly-held Element reference."],"exampleFix":"// before\nawait Element.ApplyNativeImageAsync(Image.SourceProperty, onSet);\n// (Element may be null after await)\n\n// after\nvar el = Element;\nif (el != null)\n    await el.ApplyNativeImageAsync(Image.SourceProperty, onSet);","handlingStrategy":"validation","validationCode":"var el = bindable;\nif (el == null) return;\nawait el.ApplyNativeImageAsync(prop, onSet);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Hold a strong local reference to the element across awaits.","Cancel continuation on element unload."],"tags":["argumentnullexception","ios","image","async","lifecycle"],"backgroundTag":null,"analyzedSha":"f377ff1c5ee04d334d8a925f50c83a6b7afddf03","analyzedAt":"2026-08-13T14:26:18.069Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}