I took a look at the performance with the new profiler tool. And I am very surprised to find that Slate appears to be the culprit.
In the game thread (14ms)
A “Total Slate Tick Time” of 7ms while the entire interface is hidden
A “World Tick Time” of 4ms, of which 1.5ms is physics and 1.8ms is actual game tick, the rest being small stuff
The rest is the “Frame sync”
In the render thread (15ms)
SlateDrawWindowsCommand takes 10ms, of which “Present time” takes 9.7ms. The hierarchy isn’t helpful : it stops at “self” right after that.
RenderView family takes 3.5ms which is completely OK.
The part of this frame time that makes sens amounts to less than 8ms, which is very good. The Slate part howerer is a problem, or should I say two problems :
The main Slate container is invisible (EVisibility::Hidden) so I didn’t expect any Slate time
The interface I show the rest of the time is not trivial, but nowhere near the complexity of the Unreal Editor which runs fine
If that can help, I just uploaded a screenshot of my interface. To break it down, there are 40 button object, each button being a SButton + SBorder + SBox + SHorizontalBox + (content + SImage). The content can either be a simple Slate brush, or more complex like the bottom-left buttons.
It’s not trivial but it’s not unreasonable either and I plan on doing more than that. I think any editor window is drastically more complex. All of this is from PIE.
Hardware-wise I’ve got a i7 3770K, a GTX 660 and 16GB RAM.
The main Slate container is invisible (EVisibility::Hidden) so I didn’t expect any Slate time
At the moment, we call Tick() on EVisibility::Hidden and EVisibility::Collapsed widgets. A CVAR called Slate.TickInvisibleWidgets has been introduced. We are trying it out to see what the fallout will be from no longer ticking invisible widgets. Currently it defaults to 1, but we are looking to make it 0 by default because the results are promising so far.
The interface I show the rest of the time is not trivial, but nowhere near the complexity of the Unreal Editor which runs fine
Do you find that the interface is unresponsive and sluggish, or are you simply unhappy with the numbers? Keep in mind that if you are running PIE, the numbers you are likely to see include all of the editor UI, your game UI, and any profiling tools. If you run with -game you can press ~ to bring up the console and use stat slate to toggle a breakdown of Slate stats. I’m curious about what kinds of numbers you will see.
With all that said, we are looking to make Slate more efficient. Aside from no longer ticking the invisible widgets, we are also looking to be more frugal with game-thread CPU time. These changes are currently in progress, but they have potential to break some existing UIs in annoying ways. We have to be very careful to balance our eagerness to finalize/release the performance enhancements with the need for careful testing. It might take an extra release cycle before these are made widely available.
Because when you run PIE, the Slate time includes all the editor drawing. The editor has a lot of non-trivial UI. It also possibly does multiple present calls (depending on which windows you have open). Merely iterating over the myriad of widgets in the editor takes time. All of that amounts to overhead. Enough for 10ms, for sure.