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

ColorPicker: Crash in XAML islands when exiting app #3541

Closed
sylveon opened this issue Nov 2, 2020 · 5 comments
Closed

ColorPicker: Crash in XAML islands when exiting app #3541

sylveon opened this issue Nov 2, 2020 · 5 comments
Labels
area-ColorPicker area-Islands Xaml Islands feature bug Something isn't working team-Reach Issue for the Reach team

Comments

@sylveon
Copy link
Contributor

sylveon commented Nov 2, 2020

Describe the bug
When using ColorPicker in XAML islands, if the app is exited within a short timespan of tearing down a XAML island (or directly after), it will cause an access violation in Windows.UI.Xaml.dll.

Steps to reproduce the bug

  1. Create a new blank WPF .NET Framework app.
  2. Add the Microsoft.Toolkit.Wpf.UI.XamlHost NuGet package.
  3. Add a project reference to the UniversalApiContract winmd from the Windows SDK.
  4. Add an app manifest to the app, and within <compatibility> add <maxversiontested Id="10.0.19041.0" />
  5. In MainWindow.xaml, write the following
    <Window x:Class="WpfApp2.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
            xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
            xmlns:local="clr-namespace:WpfApp2" xmlns:xamlhost="clr-namespace:Microsoft.Toolkit.Wpf.UI.XamlHost;assembly=Microsoft.Toolkit.Wpf.UI.XamlHost"
            mc:Ignorable="d"
            Title="MainWindow" Height="450" Width="800">
        <Grid>
            <xamlhost:WindowsXamlHost x:Name="host" />
        </Grid>
    </Window>
  6. In MainWindow.xaml.cs's constructor, write this code
    public MainWindow()
    {
        InitializeComponent();
    
        var sp = new Windows.UI.Xaml.Controls.StackPanel
        {
            Background = new AcrylicBrush
            {
                BackgroundSource = AcrylicBackgroundSource.HostBackdrop,
                TintOpacity = 0
            },
            HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Stretch,
            VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Stretch
        };
        host.Child = sp;
    
        var button = new Windows.UI.Xaml.Controls.Button
        {
            Content = "Click me!",
            HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center,
            VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center
        };
    
        button.Click += (s, e) =>
        {
            Dispatcher.InvokeAsync(Close);
        };
    
        sp.Children.Add(button);
        sp.Children.Add(new ColorPicker());
    }
  7. Launch the app.
  8. Click the button

Expected behavior
The app should not crash

Screenshots
image

Version Info
NuGet package version:
[Microsoft.Toolkit.Wpf.UI.XamlHost 6.1.2]

Windows app type:

UWP Win32
Yes
Windows 10 version Saw the problem?
Insider Build (xxxxx)
May 2020 Update (19041) Yes
November 2019 Update (18363)
May 2019 Update (18362)
October 2018 Update (17763)
April 2018 Update (17134)
Fall Creators Update (16299)
Creators Update (15063)
Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT

Additional context
This also happens in my C++-based XAML islands app, so this is not an issue specific to the WCT WPF host, it just makes reproduction easier.

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Nov 2, 2020
@StephenLPeters StephenLPeters added area-ColorPicker area-Islands Xaml Islands feature team-Reach Issue for the Reach team labels Nov 3, 2020
@Austin-Lamb Austin-Lamb removed the needs-triage Issue needs to be triaged by the area owners label Jan 5, 2021
@Blinue
Copy link

Blinue commented Feb 23, 2023

Seems related to #7260?

My workaround is to manually load threadpoolwinrt.dll before Windows.UI.Xaml.dll is loaded.
https://github.com/Blinue/Magpie/blob/f1809baf11c6a62053285d8e3d08fc4922961c41/src/Magpie/XamlApp.cpp#L40-L44

@sylveon
Copy link
Contributor Author

sylveon commented Feb 23, 2023

That sounds plausible, but unfortunately I'm unsure if we will be getting a fix :(

Maybe @namazso can quickly look at the crash and see if it's the same (but the stacktrace does look similar). @Scottj1s is there any chance to "backport" the fix from #7260, if the issue is the same? I can confirm this issue happens on both the WinUI 2 and system XAML color picker.

My current (terrible) workaround is calling TerminateProcess on my own process instead of gracefully exiting. An update to WinUI 2.8 with the fix would let me drop this nasty workaround.

@sylveon
Copy link
Contributor Author

sylveon commented Jul 15, 2023

Bump, still an issue

@duncanmacmichael duncanmacmichael added the bug Something isn't working label Nov 3, 2023
@JesseCol
Copy link

Unfortunately, the WinUI team is currently spending its time on WinUI 3. To help with this focus, new bugs filed against WinUI 2 are closed in this repo unless they're a security issue or are business critical.

https://github.com/microsoft/microsoft-ui-xaml/blob/main/docs/contribution_handling.md#winui-2

@JesseCol JesseCol closed this as not planned Won't fix, can't repro, duplicate, stale Nov 29, 2023
@Blinue
Copy link

Blinue commented Nov 29, 2023

However, the issues of WinUI 3 have been virtually left unattended, and closing old issues is nothing but a self-deceiving act. I wonder how much you value the feedback from the community.

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Nov 29, 2023
@bpulliam bpulliam removed the needs-triage Issue needs to be triaged by the area owners label Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ColorPicker area-Islands Xaml Islands feature bug Something isn't working team-Reach Issue for the Reach team
Projects
None yet
Development

No branches or pull requests

7 participants