Closed jorisvergeer closed 5 years ago
I run your code but work fine in .NET Framework 4.8.
Minimum Repo:
It run in .NET Framework 4.8.
Could you add some code in your AddNewConnectionWindow.xaml.cs ?
App.xaml.zip
I have this issue with dotnet new wpf
and just showing my window.
Let me add some information: My laptop had an Intel i7 with integrated graphics and a Nvidia 1050 GPU.
To me it looks like that during drawing some framebuffers or textures are messed up, or wrong ones are used.
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.
@jorisvergeer Could you find if some drivers are not installed on your device?
As far as I am aware, I have all drivers installed. I was able to play some games last night.
Are there any commands or tools I can run on my PC to diagnose the drawing? Or to debug the whole .net wpf drawing code.
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:
Are there any commands or tools I can run on my PC to diagnose the drawing? Or to debug the whole .net wpf drawing code.
Yes, the Performance Profiling Tools for Windows Presentation Foundation may help you to find the dirty region.
@lindexi That tool does not seem to work with dotnet core 3.0 WPF
@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:
@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.
Possibly related to https://github.com/dotnet/wpf/issues/319
@0xd4d Its probably related.
I don't know if it is worth anything:
Just captured another fun example:
I guess that somewhere, somehow, some active framebuffery-kind objects are being reused, leaked or mixed up.
@jorisvergeer what's your screen resolution and scale factor? Are you using multiple monitors?
@stevenbrix My laptop has 1920x1080 as resulution is uses the default scale factor. My laptop is of type MSI GF63 8RD
A maybe interesting detail is that is one of those laptops which has dual graphics card. intel and nvidia
I doubt that its got anything to do with DPI/resolution, that would probably keep aspect ratio and not just stretch the image to the window size. Probably more likely something to do with drivers/hardware. The other issue linked above #319 (closed as duplicate) was also reproduced on an integrated intel chipset.
Doesn't WPF have a way to force software rendering? Google finds things like this, if these work in .NET Core maybe someone who can reproduce the problem can check if it goes away when forcing WPF to render in software.
Just as a bit of extra info... I am running a MSI GL73 8RC laptop so pretty close to OP's computer and I am having this same issue using version 2.2.401 skd and 2.2.6 runtime. I think it might be a graphics driver issue but at the same time it happens when I force it to run on the gtx 1050 as well as the intel integrated chip. All drivers are current and up to date. happens on both x86 and x64 versions of dnspy and WPF
tried with same install on my desktop with only gtx 1050 and there was no issue.
I am having this same issue using version 2.2.401 skd and 2.2.6 runtime
@MrPurple6411 WPF has only been ported to .NET Core beginning with 3.0, so I'm curious how you are using 2.x sdk and runtime?
My Surface Book 2 has the gtx 1060 and integrated intel graphics card and i'm not seeing this, so I wonder if it has something to do with the 1050. I'll be working on getting a device to see if i can repro this. Thanks everyone for the info so far!
@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.
@jorisvergeer would you be able to share a VS Live Share session with me sometime so I can take a look under a debugger?
@stevenbrix That would be possible
@jorisvergeer actually even better would be to collect a Time Travel trace using WinDbg Preview and share that with us. One for both framework and core would be really helpful!
I've included a picture below of what your window should look like:
@stevenbrix I've done that, I have 3 files totalling about 2.5GiB of data. How do you want to receive it?
@jorisvergeer If you can upload it to some cloud storage provider like OneDrive or DropBox and provide me a link so I can download them that would be great! Or if you'd prefer, I could provide a link to my OneDrive for you to upload them to.
@stevenbrix Here you go, I've uploaded it temporary to my own VPS, tell me when you are done.
@jorisvergeer got it, thank you!!
@stevenbrix I see that you requested both core and framework. I only did a run with core. Let me know if you want data for framework also still.
@jorisvergeer that would be super helpful! It'll be helpful to compare the framework and core traces from the same machine.
Just a sec.
Meanwhile: Behaviour also appears in the visual studio editor:
@stevenbrix I did a run win .net 4.7.2, no weird behaviour as expected.
There is a file WpfTest01_net472.zip in the same location.
If you could try and build the D3D9 sample here and see if there are any issues with it.
Did this run without problems ?
I don't know why, but I can't reproduce the bug anymore... The only thing I can remeber I changed are my two displays (Dell U2412M 16:10 1920x120 and an old Samsung 1280x1024) to one 32:10 Samsung display. Just tried with the old monitors but no luck so far. Going to take a spare drive and do a fresh install of Windows to see if it then reproduces again...
@stevenbrix You asked for the specs of the custom build computer: CPU: Intel Core i9-9900k Graphics: Intel(R) UHD Graphics 630 Motherboard: Asus ROG STRIX Z390-F GAMING RAM: HyperX Predator DDR4-3200 32GB Kit SSD: Samsung 970 Evo M.2 1000GB
If you could try and build the D3D9 sample here and see if there are any issues with it.
Did this run without problems ?
I am trying now
@stevenbrix @vatsan-madhavan I do run into issues.
When started with "Intel integrated graphics": I could increase complexity until i became bored
When started with "High Performance NVIDIA processor": Initially a lot of black.
When playing with increase and decrease complexity, from time to time the background comes back to live, only to show just a couple of frames, or be stuck when changing complexity.
Note that with WPF it does not matter if I start my example app with one or the other graphics processor. Both show the same glitches.
@jorisvergeer can you try disabling NahimicOSD and see if that fixes the issue? It looks like that is hooking into the Present calls on one of traces and not the other.
@stevenbrix didn't even know i had NahimicOSD
@stevenbrix I think you are on to something
I stopped the Nahimic Service, and suddenly WPF acted just fine.
@stevenbrix I started the service again, and the glitches were back
@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 🤞
@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.
@stevenbrix @jenatali @vatsan-madhavan If @jenatali his hypothesis is true, is it then not a bug in WPF that it assumes that the viewport was not changed. Can we not just always set the correct viewport?
@jorisvergeer no its not a bug in WPF if some 3rd party application hijacks Windows APIs and changes their semantics. The viewport is a variable of the DirectX session and as such under the control of WPF. If this were C# this would be the equivalent of someone else going around changing random private variables via reflection. It is not reasonable to write defensive code against that, anything you add will be subject to the next generation of 3rd party "improvement" hacks. How many backup copies of the viewport settings would you want to keep around to make sure nobody tampered with them?
@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.
Adding workarounds in WPF will just make the 3rd party product staying broken and failing for any number of other applications. You are fixing your immediate problem by making it worse for everyone else in the long term. There needs to be back pressure to vendors and distributors of broken "improvement" hacks to actually fix or remove them. This can only happen by taking the time to identify them as broken. Since the symptoms have been root caused once now, future identification will probably be a lot easier.
I vote for not adding workarounds to correct code. If this is so bad to warrant logic in WPF it should be checking the modules list and blacklisting known bad modules, like it has been practice with video drivers containing known bugs for a long time.
The decision is on Microsoft of course.
Just to add one of the possible culprits, I did not have Nahimic, but Realtek Sonic Studio, which caused this buggy behaviour :)
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:
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