microsoft-ui-xaml icon indicating copy to clipboard operation
microsoft-ui-xaml copied to clipboard

Microsoft.UI.Xaml.Controls.Image causes an application crash

Open megamechanic opened this issue 1 year ago • 1 comments

Describe the bug

using <Image Source="{Binding Url}" /> causes random application crash. This sometimes happens in a random place in the application for different users, regardless of the SDK version & OS verision.

U can see this in Event Viewer only: Faulting Application Name: Symplast.Practice.WinUI.exe, Version: 1.0.0.0, Timestamp: 0x661e0000 Faulting module name: KERNELBASE.dll, version: 10.0.19041.4355, timestamp: 0xd7762934 Exception code: 0xc000027b Error offset: 0x000000000012d332 Faulting process ID: 0x4260 Faulty application startup time: 0x01dab36dba2d6f93 Faulting application path: C:\dev\Repos\WindowsPracticeApp\src\Symplast.Practice.WinUI\bin\x64\Debug\net7.0-windows10.0.22000.0\win10-x64\AppX\Symplast.Practice.WinUI.exe Path of the failed module: C:\WINDOWS\System32\KERNELBASE.dll Report ID: 2a467cce-ee5d-4574-94e5-529b2174cec6 Full name of the failing package: SymplastAcquisitionInc.SymplastPracticeDebug_3.406.0.0_x64__0fs0te9py8mmr Application code associated with the failing package: App

If you subscribe to Image.Loaded event and assign Image.Source in code It will fix the crash. However it doesn't help when ItemsStackPanel because of virtualization.

Steps to reproduce the bug

add<Image Source="{Binding Url}" /> to any place in an app

Expected behavior

No response

Screenshots

No response

NuGet package version

Windows App SDK 1.5.3: 1.5.240428000

Packaging type

Packaged (MSIX)

Windows version

No response

IDE

Visual Studio 2022

Additional context

for ex: using this custom control instead of Image fix the crash

<UserControl
	x:Class="Symplast.Practice.Controls.ImageControl"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<Image
		x:Name="ContentImage"
		Loaded="OnContentImageLoaded" />
</UserControl>
public sealed partial class ImageControl : UserControl
{
    public static readonly DependencyProperty SourceProperty =
           DependencyProperty.Register(nameof(Source), typeof(ImageSource), typeof(ImageControl)
           , new PropertyMetadata(null, (s, e) => ((ImageControl)s).OnSourcePropertyChanged(e)));

    public static readonly DependencyProperty StretchProperty =
            DependencyProperty.Register(nameof(Stretch), typeof(Stretch), typeof(ImageControl), new(Stretch.Uniform));

    public ImageControl()
    {
        this.InitializeComponent();
    }

    public ImageSource? Source
    {
        get => GetValue(SourceProperty) as ImageSource;
        set => SetValue(SourceProperty, value);
    }

    public Stretch Stretch
    {
        get => (Stretch)GetValue(StretchProperty);
        set => SetValue(StretchProperty, value);
    }

    private void OnContentImageLoaded(object sender, RoutedEventArgs e) => TrySetSource();

    private void OnSourcePropertyChanged(DependencyPropertyChangedEventArgs e) => TrySetSource();

    private void TrySetSource()
    {
        if (ContentImage.IsLoaded)
        {
            ContentImage.Source = Source;
        }
    }
}

megamechanic avatar Jun 06 '24 14:06 megamechanic

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one. Thank you!

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

github-actions[bot] avatar Jun 27 '24 16:06 github-actions[bot]

I was unable to reproduce this issue. Could you please share a simple project that demonstrates this issue?

kmahone avatar Jul 23 '24 22:07 kmahone

I was unable to reproduce this issue. Could you please share a simple project that demonstrates this issue?

I'd tried but I couldn't create a simple project.

megamechanic avatar Jul 24 '24 10:07 megamechanic

Unfortunately we are not able to reproduce the issue making this issue unactionable. Please provide a repro if you can reproduce it. Thanks!

ranjeshj avatar Aug 22 '24 22:08 ranjeshj