wpf: Button renders wrong after mouse leave
- .NET Core Version: 3.0 preview 5
- Windows version: 1803 build 17134.765
- Does the bug reproduce also in WPF for .NET Framework 4.8?: ~I don’t know.~ It works fine on 4.6/4.7 and 4.8
Problem description: With this XAML:
<Window x:Class="RetailEntertainment.Zorgstand.SignIn.Desktop.Views.AddNewConnectionWindow"
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:RetailEntertainment.Zorgstand.SignIn.Desktop.Views"
xmlns:vms="clr-namespace:RetailEntertainment.Zorgstand.SignIn.Desktop.ViewModels"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance vms:AddNewRegistrationDialogViewModel}"
Title="New registration" Width="400" Height="100">
<StackPanel>
<TextBlock Text="Entert the connection string received from the portal:" />
<TextBox Text="{Binding ConnectionString}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="Cancel" Margin="4" Padding="2" Command="{Binding CloseDialogCommand}"/>
<Button Content="Save" Margin="4" Padding="2" Command="{Binding TestAndAddRegistrationCommand}"/>
</StackPanel>
</StackPanel>
</Window>
The buttons render wrong after mouse leaves.
Before:
After:
Actual behavior: It looks like the button renders as if it has its parent size. After resizing the window, it renders normally again.
Expected behavior: No weird rendering
Minimal repro: Code is above
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 97 (22 by maintainers)
I don’t agree that much. External software might be triggering this, but if WPF core is the only library that has issues, then there is something ~wrong~ different with WPF core.
I sure as heck won’t adopt WPF core in production applications knowing that it glitches with at least 2 different pieces of software that comes with fresh PC’s.
I collected the modules of a broken WPF app, and find three unexpected modules:
Yes! It’s the NahimicOSD.dll that is mentioned by most of you, and the AlienwareSoundCenter does this!
UPDATE:
Other possible paths:
The last one is not from Dell’s device:
I’ve written a post to talk about this.
@jorisvergeer @stevenbrix my best guess here is that Nahimic has an overlay that they can render. When they do their overlay rendering, they probably change the viewport to cover the entire swapchain, and don’t change it back to what the application had set. Then when WPF goes to render, it assumes that the viewport is still what it was last time, and if the only thing that changed was the same thing that changed last time, then it doesn’t try to update the viewport. If Nahimic was involved, then it ends up rendering something that was supposed to be a sub-rect into the entire swapchain.
In this case, they’re not drawing their overlay… but they’re still changing the viewport it seems. This is more or less a guess, but it fits the symptoms and wouldn’t surprise me.
I agree with Microsofts approach as this overlay software is basically malware in my eyes and causes problems with a lot of apps. But it is quite widespread unforunately and only the latest releases of their software will have the .net core detection fixes in, so I’ve found a couple of workarounds.
One is to inspect the modules at startup (Process.GetCurrentProcess().Modules) and if a module named “NahimicOSD.dll” is there it will downgrade to software rendering (RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly). At least the app will run without corruption and on other PCs you will still get acceleration.
The second method which keeps the hardware accleration is to put a d3d9.dll proxy in your application directory, this seems to stop the overlay injectors. I took this one https://github.com/maltsevda/FakeD3D9 and removed the adjustments specific for that use case and made it a straight proxy https://github.com/roceh/FakeD3D9 . It seems to stop Nahimic/Sonic Suite that gets installed with my realtek audio drivers for my motherboard (ASUS ROG 370F).
Nahimic was updated to v1.4.1.0 which fixes this bug! yeah!
For anyone with ASUS ROG machines, the Sonic Suite application that comes with the system causes this issue (I assume it uses Nahimic internally).
@anose001 Yes.
I’ve removed the
ScheduledModules
folder and everything goes back to fine.But I’m still determining a better solution for our software.
I can conform that my problems (which I still have) are going away when I set the
WindowStyle
to"None"
andAllowsTransparency
to"True"
as mentioned by @zamoldar
I started to a new production project with .Net Core 3.1 because it has LTS support then I had to switch the .NET Framework due to this UI problem.
@jorisvergeer sounds like we’ve definitely found our culprit then! I have no idea why that audio service would be causing this. I’ve sent them a support request, hopefully they are responsive 🤞
Possibly related to https://github.com/dotnet/wpf/issues/319
I tried this on another PC at work. There it shows the correct behavior.
Throwing this bug in the category that depends on the environment it runs on.
App.xaml.zip I have this issue with
dotnet new wpf
and just showing my window.🖼️ Screenshots
NahimicOSD is an on-screen display library that displays something on any software using DirectX as its rendering engine. Unfortunately, the additional rendering blooms the rendering of WPF apps (DirectX 9 application precisely).
You can see more details in my post and the DELL community:
Thanks! The first suggestion worked and I was able to confirm that Nahimic loads into the modules that startup. Although I would like to try the second one as well but was not able to find a dll file. Do I need to compile it after downloading the github repo?
Also, this is a little strange, but for over a year everything was perfectly fine and then all of a sudden this started occurring. I am wondering whether the audio driver update or anything… that would be quite unfortunate.
I just encountered this problem too. I can’t believe that two years later, this garbage Nahimic stuff still has the same issue.
I read online that the Nahimic Service comes with something called “Sonic Suite”, which was apparently bundled with the sound drivers for my motherboard. I uninstalled that as well as some other Sonic thing, but they left the Nahimic Service in place. I couldn’t figure out how to properly uninstall the service so I first disabled it and then deleted the
C:\Windows\system32\NahimicService.exe
file (protip: good, well-written apps don’t just drop their executables into system32). I’m worried a driver update will bring it back, in which case I’ll just put a dummy EXE there and change the permissions so that nobody other than some random user account on my PC can write to the file.Why are drivers bundled with so much junk these days? I miss the days when they were just an
.inf
file and a few.cat
and.sys
and/or.vxd
files, with no randomly bundled executables.@stevenbrix I think you are on to something
I stopped the Nahimic Service, and suddenly WPF acted just fine.
@walterlv @lindexi You are right. But you have to have the “Perforator” tab open. Otherwise it doesn’t work.
I’ll try it when I get home.
@jorisvergeer The tool works fine with .NET Core 3.0 WPF application. I’ve tested it a few weeks ago.
I wrote a post for my demo and you may read the English translated version:
Anyway, What I guess that happend om my machine it this:
(Approximation with Paint)
It wants to draw this:
Accidently draws a button on with its parents (or window, they are the same) size (I saw something like this on one occasion when switching windows):
Then only draws the portion in the buttons region:

Nahimic is on several alienware machines,
https://www.reddit.com/r/MSI_Gaming/comments/l45fnj/guide_how_to_uninstall_nahimic_completely_from/
Same here for all WPF program, i uninstall all Sonic app (ASUS), and work perfectly after reboot (NahimicService is run).
@jorisvergeer the software might be crapware, but it was previously not causing this prior to recent windows 10 cumulative updates unless a severely out dated version was installed.
Like mentioned in other posts here Nahimic did introduce measures to prevent it from causing this, and these measures have been rendered ineffective as a result of some change in the OS.
@HitEmUp Like everyone else here. It is probably caused by some crapware that came with your sound drivers that likes to inject itself into various applications not on it’s blacklist that make use of DirectX for drawing. Probably for some 3d spatial aware sound effect or something, or for injecting an overlay of some sort. (Guess what, all new releases of dotnet core are probably not prematurely listed in its blacklist)
Same issue, all buttons like the Visual Studio Installer (bottom right) have this problem after hovering. I tried update my Nvidia drivers… windows 10 is up to date.
@weltkante my bad… I am blind. Thank you. Updating Nahimic now so will see if it will fix it.
@pcfulife Thanks so much for updating this issue, that’s great!
Out of curiosity, did you see any release notes for the update? My short searching for them wasn’t successful. I’d just like to see if they explicitly mention this issue just in case they only accidentally fixed it. I wouldn’t want the behavior to break again by happenstance. I’ll keep looking later on, but if you happened to have them handy (or even one of there installers that shows the notes) that would be helpful!
borderless window(allow transparency) fixing the issue;
can implement move ,minimize maximize, close window functionalities instead of default window, it can create very attractive designs 😃
#2299 This happened to me with .Net Core 3.1 WPF application. I am not using Nahimic and Realtek. I couldn’t fix it so, I created a project with .Net Framework 4.8 WPF application and the problem goes away.
@weltkante That could be, but somehow from all applications I am running, only WPF has this issue.
And also, I just won’t use WPF in my applications if I know that it WILL glitch on fresh out of the box computers from some brands.
@stevenbrix Here you go, I’ve uploaded it temporary to my own VPS, tell me when you are done.
https://vpn01.jorisvergeer.nl/wpftest/
@PascalKoe (who opened #319) mentioned that he was just using the integrated Intel graphics. I’d be curious to know more about your hardware.
I tried this on a Lenova Yoga with the same Intel integrated graphics and Nvidia GTX1050 configuration and didn’t reproduce this. I’m beginning to think it might not have as much to do with the GTX1050 as it does with the intel integrated graphics (or possibly something else on the board). I’m hoping I can get my hands on one of these MSI laptops to reproduce this issue.
For those that can reproduce this, are there any other scenarios or times where you see this behavior? Does this always happen with the sample app and DnSpy, or is there a time when it renders as expected?
If you could try and build the D3D9 sample here and see if there are any issues with it. You’ll probably also need to install the DirectX SDK here. This will help us understand if it’s an issue with WPF or the graphics stack.