5

I ran into a problem with my GUI. My GUI has multiple parts in it. The first one is for an image (from 500x500 to 3000x3000 and it has to update up to 4 times each seconds) The second one is the main menu The third one has buttons with options regarding the image. I am not showing all of them at once, I scroll through several menus and i render only the ones who are visible. (An example for the otpions is the pixelsize of the image) I display the image inside a Viewbox which is 800x800px big. I stretch the image inside of the box with Stretch="{Binding Path=StretchMode}" The Image I get is some kind of stream. I get multiple Images each second.

Now when I display an image, the first GUI part works fine (regardless of the image size) but the others sometimes have a heavy framedrop. I will give some examples:

Example 1:

The image is 500x500 pixel big. I can work without a framedrop and the whole gui updates correctly.

Example 2:

The image is 1500x1500 pixel big. I can work without a Framedrop and the whole gui updates correctly.

Example 3:

The image is 2500x2500 pixel big. The Image updates fast but the rest of the GUI have framedrop from 60 fps to fps and sometimes even to 1 fps.

My thoughts about this problem were:

  1. Hardware is at its limit. But a look on the Taskmanager and CPU/RAM analysis with Visual Studios says it is allright.
  2. It is too much to render for the GUI because 3000x3000 is big and 4 times each seconds is not slow either. After a test with loaded (I loaded them from a hdd-drive) 3000x3000 images (Same Datatype) it worked fast and without problems.
  3. Too much changes of the GUI at once. I tried the Software with only 5 updates. Still the same problem.
  4. Microsoft Prism event not occuring. This wasn't it either because it comes inside the Controller and is Raising the changes if there is a change. (I have a logger which writes logfiles and it is raising the Change event more than the GUI is really changing)
  5. Usage of a different datatype. Possible but i tried out several. (BitmapSource, BitmapImage and WriteableBitmap)
  6. Outsourcing some rendering options in another thread. Still no change.

I hope you can give me some ideas why the GUI has this behaviour. If you need code, please tell me.

I am not using a VM. The problem occurs on Windows 7 64 bit and Windows 8.1 64 bit (not testet on Windows 10) My hardware differs. The problem appears on my laptop (Intel i7-4702MQ @2.2 Ghz, 8 gb ddr ram, intel board graphics) and on workpc's with different specs (the highest are: Intel Xeon with 3.5 Ghz, 128 GB DDR4 Ram and a Titan X and a 4k Monitor)

Evosoul
  • 197
  • 1
  • 12
  • There have been known memory leaks in prism in the past http://compositewpf.codeplex.com/workitem/4065. Afaik they all have been fixed, but there could be more of them. Experiment a bit, if you have lots of time try cutting out some automatisms of prism (like viewmodel-mapping) for some testing to see if it changes anything. Especially region manager and anything that is event driven is very prone to memory leaks. – Mafii Jan 03 '17 at 15:44
  • You are showing 3k*3x pictures on a laptop with integrated graphics? Are you sure you even have a resolution where showing such a picture makes sense? Maybe your perceived slowness stems from the fact that each such large picture has to be scaled to fit your resolution every time? – nvoigt Jan 04 '17 at 07:00
  • @nvoigt If the problem would only occure on my laptop I would agree with you, but the problem also occurs on a desktop pc with 2 build in Intel Titan X and a 4 monitor. I also rescale the image each time (I will add this information in the question as well) – Evosoul Jan 04 '17 at 07:07
  • Even my 4K monitor cannot show a 2.5k x 2.5k picture without scrollbars or scaling. And you don't seem to use fullscreen. What resolution *do* you have? – nvoigt Jan 04 '17 at 07:11
  • Like I said I rescale the image each time to see it completely. I use a ViewBox with 800x800 with stretch mode. It stretches each image inside the 800x800. It gets more detailed when I zoom in. The resolution of my laptop is 1920x1080 and on the 4k it is 3840x2160 – Evosoul Jan 04 '17 at 07:15
  • 1
    @Mafii I ran the software for several hours with the big image and the Ram never started to grow, so I think that a memory loss (at least a visible) isn't the problem. – Evosoul Jan 04 '17 at 09:10
  • It could be GC related but for that you would need ETW tracing. Alternatively you can try to take memory dumps while it was slow and check the dumps where the call stacks are while the frame rate is low. – Alois Kraus Jan 11 '17 at 22:20

1 Answers1

0

EDIT: Apologies, stack doesn't have my score high enough to comment, so comment-ish content here instead.

EDIT1: Process explorer (from Sysinternals) should be used perhaps as a low-hanging fruit to see what (if any) video resources have a high consumption. there is a tab/area in process explorer for looking at graphic resources. In process explorer you can do a 'select columns' and add GPU resources for easy viewing. Might be a good angle to try.

I would venture a guess at this point that we are dealing with a

An ETW trace with DPC data might be helpful. Also you don't mention if you are in a VM or not, a VM would make taskmanager reflect inaccurate resource consumption on CPU.

An example of how to collect such a trace is here: https://blogs.technet.microsoft.com/jeff_stokes/2012/09/18/how-to-collect-a-trace-for-audio-or-video-problems-in-windows-7/

In any event, I suspect you are looking at kernel drivers or IPC/DPC issues rather than just raw CPU consumption here. More data needs to be provided I think. (hardware specs, OS used, VM/not).

  • 1
    I will look into this! I also added some information about the environment where this error occurs – Evosoul Jan 04 '17 at 06:55
  • 1
    I can't use the "Windows Performance Toolkit" mentioned in the link because I develop under Windows 8.1. I made some analysis with Visual Studio and the GPU is doing nothing while the CPU does all the work. WPF should use the GPU if available (I read this in this link about hardware accelerating http://stackoverflow.com/questions/149763/how-do-you-determine-if-wpf-is-using-hardware-or-software-rendering ). Is there a specific thing I need to activate the GPU? – Evosoul Jan 04 '17 at 12:33
  • Hey sorry I saw this so late. You can definitely use the ADK for 10 on 8.1, in fact we recommend that. There is a scenario in the WPT for capturing GPU activity yes. It is called "Video glitches" another way is under "Resource Analysis" pick "GPU Activity" – Jeff Stokes Mar 02 '17 at 16:41