7

I have a WPF application that behaves strangely seemingly at random. After running for a while, the UI stops rendering. It is simply not updated, the last view that was updated keeps showing. Mouse-over operations does not trigger markings of checkboxes and other items as it normally does. If I minimize the application and restore it again, the whole window goes black. It is NOT the issue of the UI thread being occupied, the application is still responsive. For example, if I right click the mouse, context menus are appearing and I can select menu items from it as usual. If the item brings up a dialog, the dialog appears and is behaving normally, but the underlying UI is still not rendering. All buttons in the UI are clickable even though they are not visible after the UI going black. Tooltips are popping up when hovering over items with tooltips attached.

This happens quite often when leaving the computer with the application running for a period of time.

Anybody seen this behavior before? Any ideas of what can be causing it? How can I debug this? I have no clue where to even begin.

EDIT: I have run Ants Performance Profiler when the UI freezes, the "% Processor Time" is close to - and sometimes above - 100%.

EDIT: It turned out that this happened every time I went to Windows lock screen and back again. I don't know why this happened, but it had to do with a custom dependency property which was implemented to make p/invoke calls to SetWindowLong, GetWindowLong and SetWindowPos. The dependency property is working as expected, except when going back from the Windows lock screen. Not using it was the "solution" to the problem.

  • Update your video card driver. – Federico Berasategui Jul 28 '14 at 14:58
  • have you attached a memory\performance profiler to observe what is going on with memory and processing when this happens? – AwkwardCoder Jul 28 '14 at 15:47
  • Regarding the video card driver: this issue start showing after a refactoring. The non-refactored version does not show this behavior. This makes me conclude that it is something with the code, and not the video driver. – RexTremendae Jul 29 '14 at 07:17
  • I have profiled with a GPU profiler, but it didn't give me any useful information. First the GPU load was 50%, but later on when I looked it was only about 15% and the UI still didn't refresh. – RexTremendae Jul 29 '14 at 07:20
  • I'm looking into a similar case where rendering freezes, but buttons work, even to the extent of opening a new window that renders properly while the main window is still frozen. Minimizing and restoring the frozen main window restores normal rendering behavior. Curiously, the live preview of the main window provided by the task bar still renders properly, which seems to indicate that something breaking between the WPF Window and the region on the desktop where it's supposed to be displayed. From WPF's perspective, everything is OK as CompositionTarget.Rendering is still called regularly. – Fls'Zen Aug 08 '14 at 12:27
  • 1
    @Fls'Zen It seems like very similar symptoms as I had. You can try looking for dependency properties and Win32 API (see the second edit section in the question). – RexTremendae Aug 10 '14 at 16:26
  • In case someone stops by here later, my specific issue turned out to be a handful of bad Intel Core i3 processors in a batch of HP machines we had. Windows 8.1 would make WPF apps look like they froze, but Windows 7 would restart the GPU driver. We exchanged just the i3 CPUs (not motherboards) with HP and all was well. Bizarre. – Fls'Zen Feb 12 '15 at 16:48

1 Answers1

0

I was facing this right now :-(

After digging around, I found the cause in a new Style that was using a BitmapCacheBrush with a BitmapCache.

See repro here: https://github.com/dotnet-campus/wpf-issues/tree/master/BitmapCache

One Quick-Fix is to disable hardware acceleration global with a machine-wide registry setting:

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Avalon.Graphics\DisableHWAcceleration

https://stackoverflow.com/a/2169657/1196586

or for the specific wpf-control/Window

RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

https://stackoverflow.com/a/9802870/1196586

Or just don't use the BitmapCache.

Credit goes to: https://weblog.west-wind.com/posts/2017/Feb/13/Video-Rendering-Issues-for-WPF-Windows#workaround-disable-hardware-acceleration

gReX
  • 1,060
  • 1
  • 20
  • 35