Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] App crashes when static DoubleCollection is used more than once #18201

Closed
kucint opened this issue Sep 13, 2024 · 2 comments
Closed
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification

Comments

@kucint
Copy link

kucint commented Sep 13, 2024

Current behavior

create a simple app, that uses DoubleCollection.
if DoubleCollection is referenced more than ones, it causes app to crash.

I suppose the issue has nothing to do with DoubleCollection, but rather is related to static instantiation. I mean, using static object of another types will probably as well cause problems.

This issue occurs only on net8.0-windows.
net8.0-desktop is not affected.

Expected behavior

using static DoubleCollection shall work fine.

How to reproduce it (as minimally and precisely as possible)

create a simple app, that uses DoubleCollection.
if DoubleCollection is referenced more than ones, it causes app to crash.

public sealed partial class MainPage : Page
{
    public MainPage()
    {
        this
            .Background(ThemeResource.Get<Brush>("ApplicationPageBackgroundThemeBrush"))
            .Content(new StackPanel()
            .VerticalAlignment(VerticalAlignment.Center)
            .HorizontalAlignment(HorizontalAlignment.Center)
            .Children(
                new TextBlock()
                .Text("Hello Uno Platform!"),
                MyEllipse(),    // first instance works fine with static and local instance of DoubleCollection
                MyEllipse()     // second instance crashes when using static instance of DoubleCollection
            ));
    }

    private static readonly DoubleCollection DashedLine = [3, 2];

    private Ellipse MyEllipse() => new Ellipse()
        .Width(20)
        .Height(20)
        .StrokeThickness(1)
        .Stroke(Colors.Black)
//      .StrokeDashArray(new DoubleCollection() { 3, 2 })   // local instance works always fine
        .StrokeDashArray(DashedLine);                       // crashes when method is called twice
}

App crashes with following exception:
Exception thrown: 'System.ArgumentException' in WinRT.Runtime.dll
An exception of type 'System.ArgumentException' occurred in WinRT.Runtime.dll but was not handled in user code

repro: UnoAppMystery.zip

Workaround

replace static instances of DoubleCollection with local instances

Works on UWP/WinUI

None

Environment

No response

NuGet package version(s)

Version:
Uno.Sdk": "5.3.108

Affected platforms

Windows (WinAppSDK)

IDE

Visual Studio 2022

IDE version

No response

Relevant plugins

No response

Anything else we need to know?

No response

@kucint kucint added difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification labels Sep 13, 2024
@jeromelaban
Copy link
Member

Thanks for the report.

Considering this is a WinUI API issue, we may not be able to fix this issue, though we may be able to find a workaround for that particular scenario.

@kucint
Copy link
Author

kucint commented Oct 2, 2024

@jeromelaban thanks for investigating it.
so I have to use local instances of DoubleCollection rather than static instances.
it is OK.

@kucint kucint closed this as completed Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty/tbd Categorizes an issue for which the difficulty level needs to be defined. kind/bug Something isn't working triage/untriaged Indicates an issue requires triaging or verification
Projects
None yet
Development

No branches or pull requests

2 participants