What can one do about WPF render tearing of the UI?
To my disappointment I found out that one of the applications I'm working on renders rather poorly on certain computers. The UI static graphics and text suffer from a severe case of tearing without doing any kind of animations. This makes text unreadable and of course, the graphics look poor.
I've noticed this problem on different computers but the one that really made me think was a newer Toshiba laptop with a Radeon Mobility video card: when this laptop runs on battery, there is no tearing - but when it runs plugged-in everything is a mess. So this looks like a problem with power line noise which apparently affects the video card - I'm guessing hardware accelerated graphics. However, non-WPF graphics render fine so how do you tell users: "It's not my app, it's your power supply!" ?!
Have you ever run into this? And is there anyway to fix it?
The app is .NET 4.0, and the laptop was running Windows 7.
I've run into this same thing on my Acer laptop. It was actually a driver issue with the screen driver, and a vendor update completely solved the problem.
I would recommend contacting Toshiba directly regarding this problem. Point them to some public, easy to find WPF application that demonstrates the issue.
In the meantime, the only "solution" I know of is to have WPF disable hardware acceleration entirely. This post describes how to force software rendering for all WPF applications, which should correct the tearing (at the cost of dramatically reduced rendering perf.).
The issues are normally caused by drivers for ATI video cards. NVidia cards (while they have their own issues) generally don't display these problems.
The easiest way to fix it is to disable hardware rendering. This can cause performance issues, but often won't make a noticeable difference and can sometimes even improve performance. You'll need to test it for your own app to see. To set from a Window's code:
(PresentationSource.FromVisual(this) as HwndSource).CompositionTarget.RenderMode = RenderMode.SoftwareOnly;
As Reed said, this is quite possibly a driver issue. However, I've seen this before on some cards with up-to-date drivers, so it's not always a fixable problem, depending on your hardware. If this is a graphics problem caused by a particular graphics card, you might be able to try this workaround...
In regedit, you can create or edit the following DWORD value to "1" to force software rendering of all WPF applications:
I've found in the past that on low-end machines (netbooks and integrated-graphics machines) this can often noiceable improve the performance of WPF apps, because it reduces memory contention between the GPU and CPU.