unoplatform / Uno.WindowsCommunityToolkit

The Windows Community Toolkit is a collection of helper functions, custom controls, and app services. It simplifies and demonstrates common developer tasks building UWP apps for Windows 10. The toolkit is part of the .NET Foundation.
https://docs.microsoft.com/windows/uwpcommunitytoolkit/
Other
61 stars 11 forks source link

DataGrid : Freezes iOS or MacCatalyst app when added to visual tree #186

Closed baskren closed 1 year ago

baskren commented 1 year ago

Current behavior

CommunityToolkit.WinUI.UI.Controls.DataGrid will freeze an iOS (Simulator or Device) or MacCatalyst app when added to the visual tree of the app.

NOTES:

Expected behavior

DataGrid can be added to Uno.WinUi app as it can on other platforms.

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

  1. Create new UnoApp
  2. Build, deploy and launch app to iOS Simulator or Device
  3. Click [Click to add DataGrid] button
  4. Notice app freezes on _grid.Children.Add(_dataGrid); in the following block of code:

        private void _button_Click(object sender, RoutedEventArgs e)
        {
            if (_dataGrid is null)
            {
                _dataGrid = new CommunityToolkit.WinUI.UI.Controls.DataGrid();
    
                var list = new List<string> { "apple", "butter", "cranberries", "dessert", "eggs", "fish" };
                _dataGrid.ItemsSource = list;
                _dataGrid.AutoGenerateColumns = true;
    
                Grid.SetRow(_dataGrid, 1);
                _grid.Children.Add(_dataGrid);
            }
        }

Workaround

Have not yet tested if the issue is present in the following scenarios:

Works on UWP/WinUI

Yes

Environment

Uno.WinUI / Uno.WinUI.WebAssembly / Uno.WinUI.Skia

NuGet package version(s)

  <ItemGroup>
    <PackageReference Include="Uno.CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.1.100" />
    <PackageReference Include="Uno.WinUI" Version="4.6.19" />
    <PackageReference Include="Uno.WinUI.RemoteControl" Version="4.6.19" Condition="'$(Configuration)'=='Debug'" />
    <PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="4.6.19" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />
    <PackageReference Include="Uno.WinUI.Lottie" Version="4.6.19" />
  </ItemGroup>

Affected platforms

iOS

IDE

Visual Studio 2022

IDE version

Version 17.4.1

Relevant plugins

Microsoft Visual Studio Enterprise 2022
Version 17.4.1
VisualStudio.17.Release/17.4.1+33110.190
Microsoft .NET Framework
Version 4.8.04084

Installed Version: Enterprise

Architecture Diagrams and Analysis Tools   00476-80000-00000-AA914
Microsoft Architecture Diagrams and Analysis Tools

Visual C++ 2022   00476-80000-00000-AA914
Microsoft Visual C++ 2022

ADL Tools Service Provider   1.0
This package contains services used by Data Lake tools

ASA Service Provider   1.0

ASP.NET and Web Tools   17.4.326.54890
ASP.NET and Web Tools

Azure App Service Tools v3.0.0   17.4.326.54890
Azure App Service Tools v3.0.0

Azure Data Lake Tools for Visual Studio   2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools   17.4.326.54890
Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio   2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools   4.4.0-6.22559.4+d7e8a398ef479a908e76bded82150c39251d0c9c
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

CleanBinAndObjCommand Extension   1.2.58
CleanBinAndObjCommand Visual Studio Extension Detailed Info

Common Azure Tools   1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Extensibility Message Bus   1.4.1 (main@2ee106a)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.

IncrediBuild Build Acceleration   1.6.0.2
IncrediBuild effectively reduces compilation and development times by up to 90%.

Linux Core Dump Debugging   1.0.9.33020
Enables debugging of Linux core dumps.

Microsoft Azure Hive Query Language Service   2.6.5000.0
Language service for Hive query

Microsoft Azure Stream Analytics Language Service   2.6.5000.0
Language service for Azure Stream Analytics

Microsoft Azure Tools for Visual Studio   2.9
Support for Azure Cloud Services projects

Microsoft JVM Debugger   1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Mono Debugging for Visual Studio   17.4.19 (8c0a575)
Support for debugging Mono processes with Visual Studio.

NuGet Package Manager   6.4.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/

Office Developer Tools for Visual Studio   17.0.32915.00
Microsoft Office Developer Tools for Visual Studio

Razor (ASP.NET Core)   17.0.0.2246202+61cc048d36a3fc9246d2f04625988b19a18ab8f0
Provides languages services for ASP.NET Core Razor.

SQL Server Data Tools   17.0.62207.28050
Microsoft SQL Server Data Tools

Syntax Visualizer   1.0
An extension for visualizing Roslyn SyntaxTrees.

Test Adapter for Boost.Test   1.0
Enables Visual Studio's testing tools with unit tests written for Boost.Test.  The use terms and Third Party Notices are available in the extension installation directory.

Test Adapter for Google Test   1.0
Enables Visual Studio's testing tools with unit tests written for Google Test.  The use terms and Third Party Notices are available in the extension installation directory.

ToolWindowHostedEditor   1.0
Hosting json editor into a tool window

TypeScript Tools   17.0.10921.2001
TypeScript Tools for Microsoft Visual Studio

UnoPlatformPackage Extension   1.0
UnoPlatformPackage Visual Studio Extension Detailed Info

Visual Basic Tools   4.4.0-6.22559.4+d7e8a398ef479a908e76bded82150c39251d0c9c
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual C++ for Cross Platform Mobile Development (Android)   17.0.33006.217
Visual C++ for Cross Platform Mobile Development (Android)

Visual C++ for Cross Platform Mobile Development (iOS)   17.0.33006.217
Visual C++ for Cross Platform Mobile Development (iOS)

Visual C++ for Linux Development   1.0.9.33020
Visual C++ for Linux Development

Visual F# Tools   17.4.0-beta.22512.4+525d5109e389341bb90b144c24e2ad1ceec91e7b
Microsoft Visual F# Tools

Visual Studio IntelliCode   2.2
AI-assisted development for Visual Studio.

VisualStudio.DeviceLog   1.0
Information about my package

VisualStudio.Mac   1.0
Mac Extension for Visual Studio

VSPackage Extension   1.0
VSPackage Visual Studio Extension Detailed Info

Workflow Manager Tools 1.0   1.0
This package contains the necessary Visual Studio integration components for Workflow Manager.

Xamarin   17.4.0.301 (d17-4@96af3ae)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer   17.4.0.138 (remotes/origin/d17-4@d36bba3cc9)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin Templates   17.4.2 (c457c97)
Templates for building iOS, Android, and Windows apps with Xamarin and Xamarin.Forms.

Xamarin.Android SDK   13.1.0.1 (d17-4/13ba222)
Xamarin.Android Reference Assemblies and MSBuild support.
    Mono: a96bde9
    Java.Interop: xamarin/java.interop/d17-4@fcc33ce2
    SQLite: xamarin/sqlite/3.39.3@23e1ae7
    Xamarin.Android Tools: xamarin/xamarin-android-tools/main@0be567a

Xamarin.iOS and Xamarin.Mac SDK   16.0.0.92 (3dd3dc52c)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

Anything else we need to know?

Is there a "how to build and debug" document or video (maybe an old Twitch stream) for the UNO.WCT project? A quick glance at the code made me realize it was going to be a career to get to the point where I could start debugging this.

baskren commented 1 year ago

EDIT: Verified that issue occurs on iOS device as well

baskren commented 1 year ago

Compressed Demo Project: UnoApp.zip

baskren commented 1 year ago

Verified:

jeromelaban commented 1 year ago

Thanks for the report. This is a behavior related to https://github.com/unoplatform/uno/issues/3519, and that particular behavior in the DataGrid can be controlled with: https://github.com/unoplatform/Uno.WindowsCommunityToolkit/blob/0896559e61458aa97a2f808b51e20b23f0a47659/CommunityToolkit.WinUI.UI.Controls.DataGrid/DataGrid/DataGridFeatureConfiguation.cs#L19

Can you try setting this flag to false ?

baskren commented 1 year ago

THANK YOU!

jeromelaban commented 1 year ago

Great. We'll likely need to set this property to false when running with iOS.

jeromelaban commented 1 year ago

Fixed in latest experimental build https://github.com/unoplatform/Uno.WindowsCommunityToolkit/pull/187

baskren commented 1 year ago

Rock on!