WPF Window Extremely Slow to Open


#1

So I am using WPF windows as dialogs for a plugin I am working on. However, when the user opens a WPF window for the first time, it is extremely slow. The initial load takes 25 seconds or more. Then every time it opens after that, it opens instantly. What could be causing this? How can I fix it? The window I am trying right now is just an empty WPF window with 1 label. It seems like this should load instantly.

Thanks!


(Dale Fugier) #2

Hi Ryan,

We’re going to need to see a sample project, that replicates the problem, so we can build it and run it here.

– Dale


#3

Dale,

I have a super simple project for you right here. The command tries to open a WPF window in Rhino. However on my machine the first time the command it run it takes 25-30 seconds for the window to appear, then every other time it is nearly instantaneous.

WPF_Form_Demo.zip (35.8 KB)

Let me know if you have any questions.
Thanks!

Ryan


(Menno Deij - van Rijswijk) #4

This is probably related to the fact that WPF needs to load a lot of support DLLs before it can show stuff. I have noticed the delay as well, although in my case with an SSD it is only a couple of seconds at most, and have always attributed it to that.

Normal WPF applications typically show a splash screen during this period of loading support DLLs.


(Dale Fugier) #5

I’m not seeing a noticeable delay here (this isn’t to say you aren’t.). If you watch your output window (in Visual Studio), you will need a number of DLLs loaded when your command is run (which is probably the delay you are seeing).


(Steve Baer) #6

25 seconds is way too long. Are you seeing this only when running in the Visual Studio debugger? If that is the case, you may be waiting for symbols downloading from Microsoft.


#7

How can I make sure I am not running with Visual Studio Debugger?


(Menno Deij - van Rijswijk) #8

If you are running Rhino from VS, you will have to press F5 or click the “Play” button to start the debugger.
To start Rhino from VS, but not with the debugger, press Ctrl+F5. Or just click the Rhino icon on your desktop or from your start menu like any normal user would do. Then you are certain not to run the debugger.


#9

Even when I run it from Rhino started on its own, and with the plugin located on my C drive which is a SSD. it is still taking 20-25 seconds. I can make a video if that helps. Again, for some reason it is only the inital load. Every other time, it opens instantaneously.

Is there any way I can profile the code to see exactly what it is executing?


(Menno Deij - van Rijswijk) #10

You can see what is going on by running it in the Debugger from Visual Studio (F5). Before starting it, open the “Output Window”. Each time a library is loaded, or a message is printed, it gets written to that window. You can see which libraries take a long time to load, or maybe other messages that may give some more information.

If you’re making a video, please make it from the debugger with the output window open.

Just to make sure: when you say initial load, it is the first time your plug-in is loaded, but it happens every time you start Rhino? Or is it only when you start Rhino for the first time, then when you start Rhin again, the load time is not so long?


(Menno Deij - van Rijswijk) #11

Also you might try this solution

basically, it could be a problem with the NGEN images. To try to solve, open an administrative console and run

cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319
ngen update

#12

Try to use NGEN. Made a huge difference on my application. Read about it in my blog.