Frame Stuttering on Response

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
User avatar
Squimon
Posts: 4
Joined: Wed Mar 16, 2016 7:45 pm

Frame Stuttering on Response

Post by Squimon »

I've noticed that the dialogue system is freezing my game for a fraction of a second each time the conversation-in-progress transitions to a new node. At first, I thought my actor portraits were too high-res and it was taking a moment to load them in. I experimented with crunching them down and changing their texture type but it didn't fix the problem.

Has anybody encountered something like this?
User avatar
Tony Li
Posts: 21061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Frame Stuttering on Response

Post by Tony Li »

Hi,

Is your Dialogue Manager's Debug Level set to Info? If so, it logs a lot of information to the Console view. Logging to the Console really slows down Unity.

If that isn't the culprit, please feel free to send a reproduction project (Assets and ProjectSettings folders) to tony (at) pixelcrushers.com and let me know what version of Unity to use. I'll be happy to take a look and let you know if I can find a reason. I'm finishing up work for the day, but I can get to work on it tomorrow.
User avatar
Squimon
Posts: 4
Joined: Wed Mar 16, 2016 7:45 pm

Re: Frame Stuttering on Response

Post by Squimon »

Hey Tony,

edit: Our dialogue manager's debug level is set to "warning".

Wanted to give you an update. The Unity profiler isolated the ConversationView script component of the dialogue manager spiking 95% cpu usage each time the scene's conversation would progress to a new node, hence the stuttering. We've worked out that the stuttering problem only happens during play mode in the Unity editor and thankfully doesn't occur in any builds of the game. This is fine as it doesn't interfere with the player's experience.

Whether it's an optimization issue on our end or with the dialogue system itself, we're not sure. Figured this might be the sort of thing you're interested in knowing though.

Thanks.
User avatar
Tony Li
Posts: 21061
Joined: Thu Jul 18, 2013 1:27 pm

Re: Frame Stuttering on Response

Post by Tony Li »

Hi,

ConversationView does a couple things that could get computationally expensive in certain situations, particularly in the editor. If you want to dig into it further at any point, try setting the profiler to Deep Profile and drill into ConversationView.ShowSubtitle. (Or ConversationView.ShowResponses if you notice the stutter when showing the player response menu.) Here are the potential sources of stutter in ShowSubtitle:
  • Check the Console view. Some other script could be logging to the console when showing a subtitle. Performancewise, ideally when you're playing nothing should ever be logged to the console.
  • ShowSubtitle first sends "OnConversationLine(subtitle)" to the Dialogue Manager and both participants. If you have any scripts that have OnConversationLine methods, make sure they don't take too long to process, and avoid writing to the console.
  • Then it calls the dialogue UI's ShowSubtitle method. If you're using Unity UI and have a complex auto-layout, Unity might take a little time in the editor to compute the layout positions of the UI elements. Layout computation is usually faster in builds because it doesn't have to worry about updating the Scene view, Inspector view, etc. Since you said the stutter occurs only in the editor, this is probably the reason.
  • Then it plays the dialogue entry's Sequence. If the sequence contains any sequencer commands that run at the start of the sequence, make sure they start up quickly. The built-in sequencer commands are fast, but you may need to check any custom sequencer commands you've written.
  • Finally, if you've added any Lua Observers and set them to update during every dialogue entry, they will run their Lua expressions. This can be an expensive operation, especially if you've registered your own code with Lua that takes a long time to run and you're using it in the observer's Lua expression.
User avatar
Squimon
Posts: 4
Joined: Wed Mar 16, 2016 7:45 pm

Re: Frame Stuttering on Response

Post by Squimon »

Hi Tony,

Running the deep profiler exposed that it is ShowSubtitle at fault. Since it's a problem that won't affect users and only we, as developers, will have to deal with we're fine just putting up with it. Thanks for your tips!
Post Reply