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

Exception thrown after closing window with flyout that contains a color picker #7239

Closed
1 of 2 tasks
dkreho1 opened this issue Jun 14, 2022 · 9 comments
Closed
1 of 2 tasks
Assignees
Labels
area-ColorPicker area-Flyouts bug Something isn't working team-Controls Issue for the Controls team

Comments

@dkreho1
Copy link

dkreho1 commented Jun 14, 2022

Describe the bug

Window defined with the following C++ code:

window = winrt::Microsoft::UI::Xaml::Window::Window();
window.Activate();

winrt::Microsoft::UI::Xaml::Controls::Button button;
button.HorizontalAlignment(winrt::Microsoft::UI::Xaml::HorizontalAlignment::Center);
button.VerticalAlignment(winrt::Microsoft::UI::Xaml::VerticalAlignment::Center);
button.Content(winrt::box_value(L"Button"));
window.Content(button);

winrt::Microsoft::UI::Xaml::Controls::ColorPicker colorPicker;
winrt::Microsoft::UI::Xaml::Controls::Flyout flyout;
flyout.Content(colorPicker);
button.Flyout(flyout);

If I click on the button to open the flyout everything works fine but when I close the window the following exception is thrown:

Exception thrown at 0x00007FFE6D5947F8 (threadpoolwinrt.dll) in FlyoutColorPickerIssue.exe: 0xC0000005 : Access violation reading location 0x0000000000000000.

If I don't open the flyout the exception isn't thrown. Same thing happens if I use XAML to define the same window in MainWindow.xaml. I have tried the same with some other controls, in particular with TextBlock, DatePicker and TimePicker, and the window closes fine without this exception. Also reverted back to Microsoft.WindowsAppSDK 1.0.3 and no exception gets thrown so I'm assuming the issue is with Microsoft.WindowsAppSDK 1.1.0.

Steps to reproduce the bug

  1. Build and run the app
  2. Click on the button to open flyout that contains a color picker
  3. Close the window (using the caption buttons)

Expected behavior

Window to close without any exceptions.

Screenshots

image

NuGet package version

No response

Windows app type

  • UWP
  • Win32

Device form factor

No response

Windows version

Windows 10 (21H2): Build 19044

Additional context

Using Microsoft.WindowsAppSDK 1.1.0

@dkreho1 dkreho1 added the bug Something isn't working label Jun 14, 2022
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Jun 14, 2022
@ojhad ojhad added area-ColorPicker team-Controls Issue for the Controls team area-Flyouts and removed needs-triage Issue needs to be triaged by the area owners labels Jun 22, 2022
@dkreho1
Copy link
Author

dkreho1 commented Aug 3, 2022

Just to give an update. Recently updated to Windows 11 (21H2) Build: 22000.832, and after testing this again with both Windows App SDK 1.1.2 and 1.1.3, it seems that this issue isn't present anymore. Last time I checked on Windows 10 was with Windows App SDK 1.1.2 and the issue was still there.

@jschwizer99
Copy link

jschwizer99 commented Sep 25, 2022

After the drag & drop issues seem to be fixed in App SDK v1.2.0-preview1 I now see colorpicker triggered crashes as described in this ticket. This is a regression of App SDK v1.1.x versions as it was fine for all App SDK v1.0.x versions. Currently, this is a blocker for us for internal testing of the application.

@codendone, @ojhad As the issue looks suspiciously similar to #7260 I've tried the workaround as proposed by dotnet/maui#7317 (comment). As my code is WinRT C++ based, I used the following code fragment.

#include "WorkAroundMicrosoftBug.hpp"

#include "winstring.h"
#include "roapi.h"
#include "guiddef.h"

#include <string>

// https://github.com/dotnet/maui/issues/7317
// https://github.com/microsoft/microsoft-ui-xaml/issues/7260
void WorkaroundMicrosoftBug()
{
    HRESULT result;
    result = RoInitialize(RO_INIT_MULTITHREADED);
    std::wstring name = L"Windows.System.Threading.ThreadPoolTimer";
    HSTRING str;
    void* out;
    result = WindowsCreateString(name.c_str(), name.size(), &str);
    GUID guid = { 0x1a8a9d02, 0xe482, 0x461b, { 0xB8, 0xC7, 0x8E, 0xFA, 0xD1, 0xCC, 0xE5, 0x90 } };
    result = RoGetActivationFactory(str, guid, &out);
    result = RoGetActivationFactory(str, guid, &out);
    result = RoGetActivationFactory(str, guid, &out);
}

Unfortunately, it doesn't solve the crashes that I observe. Is it correct that the tickets are related? Or do I miss something with the workaround?

I hope that we get soon a fix for this issue so that at least we do not suffer anymore from regression of v1.1.x. It would allow us to step finally from App SDK v.1.0.x to something newer.

Any fix or workaround would be highly appreciated.

@jschwizer99
Copy link

@codendone The issue is still visible with App SDK 1.2.221116.1.

@jschwizer99
Copy link

jschwizer99 commented Nov 19, 2022

The official WinUI 3 Gallery (Version: 1.3.16.0) hangs when the Colopicker Tab is opened and the app is closed. Using other tabs doesn't show this behavior. The WinUI 3 Gallery Window is closed but the application is still visible in the task manager consuming significant CPU power after exit. It must be forcefully terminated.

When compiling and running the WinUI 3 Gallery in Debug x64 mode the same access violation can be observed as soon as the colorpicker tab is opened.
image

@jschwizer99
Copy link

This issue is still a regression of all 1.x and 2.x App SDK releases for the Windows 10 platform. I've also tested the latest v1.2.2 release with the same results. On Windows 11 platforms the crash cannot be observed (using the same test code). It currently blocks us from finally upgrading from the outdated 1.0.4 release to something up-to-date without the need to design our own color picker.
It can be very easily reproduced on the official WinUI 3 Gallery. Just open on a Windows 10 platform the tab with the color picker and the app will crash with the above-reported exception.
@bpulliam, @Scottj1s, I appreciate it a lot if this regression could be addressed in one of the next service-releases 1.2.x. With source code access the fix shouldn't be that difficult as easy reproducible and very localized. Many thanks in advance.

@Scottj1s
Copy link
Member

@jschwizer99 Thanks for your patience. We have a fix for this issue and will endeavor to include it in the next 1.2 servicing release.

@jschwizer99
Copy link

@Scottj1s Many thanks for this positive news! I'm looking forward to testing it.

@Scottj1s
Copy link
Member

And thanks @dkreho1 for reporting this issue. The fix will be available soon in the next servicing release, 1.2.3.

@Scottj1s
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ColorPicker area-Flyouts bug Something isn't working team-Controls Issue for the Controls team
Projects
None yet
Development

No branches or pull requests

4 participants