-
Notifications
You must be signed in to change notification settings - Fork 776
Description
Describe the bug
Drawing a custom DataGrid control using DirectX in conjunction with CompositionDrawingSurface worked well in a UWP application. However, after migrating to WinUI3, it no longer works efficiently on RDP. Therefore, we consider this a bug.
Why is this important?
Most of our clients run on RDP. The new version of the ERP application we migrated from UWP to WinUI3 has lost performance when browsing data. This is a very significant issue. We've wasted a significant amount of resources migrating to WinUI3, and it's proving fruitless.
Steps to reproduce the bug
I draw content using DirectX (ID2D1DeviceContext) in a bound XAML control.
I do this using Microsoft::UI::Compostion::ICompositionDrawingSurfaceInterop (m_drawingSurfaceInterop).
I have a XAML element (m_grid) bound to the CompositionDrawingSurface like this:
SpriteVisual spriteVisual{ m_compositor.CreateSpriteVisual() };
CompositionSurfaceBrush surfaceBrush{
m_compositor.CreateSurfaceBrush(m_drawingSurfaceInterop.as<ICompositionSurface>()) };
surfaceBrush.Scale({ 96.0f / dpx,96.0f / dpx });
surfaceBrush.HorizontalAlignmentRatio(0);
surfaceBrush.VerticalAlignmentRatio(0);
surfaceBrush.Stretch(CompositionStretch::None);
spriteVisual.Brush(surfaceBrush);
spriteVisual.RelativeSizeAdjustment({ 1.0f,1.0f });
spriteVisual.Offset({ 0,0,0 });
MUX:Hosting::ElementCompositionPreview::SetElementChildVisual(m_grid, spriteVisual);
Actual behavior
-
Very importantly, why did this solution work efficiently on UWP on remote RDP desktops, but not on RDP after migrating to WinUI3 (NS Microsoft.UI). Drawing is about 80 times slower on RDP than on the local desktop. For example, scrolling is terrible; it's impossible to work. I'd appreciate some help with the CompositionDrawingSurface architecture, as even converting it to SwapChain doesn't provide the same rendering performance on RDP as it did on UWP using CompositionDrawingSurface. There's also no way to bind SwapChain to CompositionDrawingSurface in WinUI3.
-
I also don't understand why I have to scale the surface to maintain the correct resolution of rendered text. (The scaling method in the code above works, but the question is why this code is needed, since the CompositionDrawingSurface is retrieved from the Composer's device and it knows the resolution.)
Expected behavior
-
We are testing the same code on UWP and WinUI3 (another Microsoft NS.UI).
WinUI3 renders using CompositionDrawingSurface on RDP on average 80 times slower than the same code on UWP. Performance should be similar. -
Drawing and rendering graphics using ID2D1DeviceContext should not be subject to target surface scaling distortions by default.
Screenshots
No response
NuGet package version
WinUI 3 - Windows App SDK 1.8.0: 1.8.250907003
Windows version
No response
Additional context
No response