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

High GPU usage when using WindowChrome, MediaElement and InkCanvas on Intel Iris Xe #8686

Open
Lililili-m opened this issue Jan 15, 2024 · 5 comments
Labels
Investigate Requires further investigation by the WPF team.

Comments

@Lililili-m
Copy link

Description

When I create a WPF full screen demo using WindowChrome 、MediaElement and InkCanvas,the GPU usage will surge to 60%.
1
2

I tested different computers. This problem occurs when the computer graphics card driver is Intel Iris Xe , but is normal on UHD.

And I listed the GPU usage under different configurations:
3

I can't reproduce the same issue from the system native app, so I'm not sure if this is an Intel issue or a WPF issue.

And I tried to get window's touch events to draw Geometry, and the GPU usage was not as exaggerated as InkCanvas, about 30%~40%.

My demo is as follows:

<Window x:Class="MediaElement.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"
        mc:Ignorable="d"
        WindowState="Maximized" 
        ShowInTaskbar="False">
    <WindowChrome.WindowChrome>
        <WindowChrome GlassFrameThickness="-1"/>
    </WindowChrome.WindowChrome>
    <Grid x:Name="TestSp">
        <InkCanvas Background="Aquamarine"></InkCanvas>
        <MediaElement x:Name="LoadingElement" MediaEnded="LoadingElement_OnMediaEnded" LoadedBehavior="Play" Source="MLLoading.gif" 
                      HorizontalAlignment="Center" VerticalAlignment="Bottom" Margin="0 0 0 68" Width="100" Height="100" />
    </Grid>
</Window>
        private void LoadingElement_OnMediaEnded(object sender, RoutedEventArgs e)
        {
            ((MediaElement)sender).Position = ((MediaElement)sender).Position.Add(TimeSpan.FromMilliseconds(1));
        }

Reproduction Steps

  1. Prepare a computer with Intel Iris Xe graphics (I tried it on two computers and it can be reproduced on both computers.),version of the graphics card driver is 31.0.101.5084.
  2. Create an empty WPF application, .net 6.0 or .net framework 4.7.2. I am using .net framework 472, and it is the same when using .net 6.0.
  3. Add MediaElement and Inkcanvas in xaml, and set WindowChrome.
  4. Run the application, write on Inkcanvs.
  5. Observe GPU usage in task manager.

Expected behavior

The GPU usage is normal.

Actual behavior

The GPU usage is very high.

Regression?

No response

Known Workarounds

Set the WPF app to use software rendering.

RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

Impact

No response

Configuration

No response

Other information

No response

@lindexi lindexi added the Investigate Requires further investigation by the WPF team. label Jan 16, 2024
@lindexi
Copy link
Contributor

lindexi commented Jan 16, 2024

It looks like an Intel issues.

@Lililili-m
Copy link
Author

Lililili-m commented Jan 17, 2024

It looks like an Intel issues.

Yeah, I also posted a question in the Intel community.
https://community.intel.com/t5/Graphics/WPF-Application-high-GPU-usage-on-Iris-Xe-GPU/m-p/1563448#M127328

@lindexi
Copy link
Contributor

lindexi commented Jan 19, 2024

Underneath the MediaElement element in WPF, Windows Media Player is used to carry out the actual playback logic. In WPF's InkCanvas, a large number of Geometry objects are created for drawing strokes. I suspect that there is a bug in Intel's Windows Media Player that causes more GPU resources to be consumed when touching or drawing Geometry. However, as more code enters the driver layer, I am unable to obtain more logic through VisualStudio's GPU performance detector. At the same time, according to feedback from the Intel community, the same code works normally on UHD devices, so I have sufficient reason to suspect that this is a problem existing in the Intel driver layer. Can anyone help push Intel to assist in investigating this issue?

@pchaurasia14 pchaurasia14 changed the title High GPU usage when using WindowChrome 、MediaElement and InkCanvas on Intel Iris Xe High GPU usage when using WindowChrome, MediaElement and InkCanvas on Intel Iris Xe Jan 24, 2024
@lindexi
Copy link
Contributor

lindexi commented Mar 3, 2024

According to Intel engineers, the issue originates from the driver layer. The likely cause is that in the current version of Intel, when DX9 processes resources, it will invoke the Media engine to decompress resources, even if there is no Media currently playing. This will result in the consumption of more GPU resources. This issue will be addressed in subsequent Intel driver updates. Once again, thank you for Intel's support.

@Lililili-m
Copy link
Author

According to Intel engineers, the issue originates from the driver layer. The likely cause is that in the current version of Intel, when DX9 processes resources, it will invoke the Media engine to decompress resources, even if there is no Media currently playing. This will result in the consumption of more GPU resources. This issue will be addressed in subsequent Intel driver updates. Once again, thank you for Intel's support.

When the fix driver is released and verified, I will close the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Investigate Requires further investigation by the WPF team.
Projects
None yet
Development

No branches or pull requests

2 participants