Page 1 of 2
How to fix lag
Posted: Sun Aug 11, 2019 12:07 pm
by lostmushroom
Hey, I've noticed a few issues with lag when I'm testing my game. Some dialogue choices seem to make the game run really slowly, or stop completely for a few seconds. I have quite a lot of variables and conversations linked to other conversations. Is there a way to fix this?
Re: How to fix lag
Posted: Sun Aug 11, 2019 2:55 pm
by Tony Li
Let's identify the cause of what you're seeing as lag.
Is the lag consistent? In other words, does node A always lag but node B never lags? Or is it intermittent, where node A sometimes lags but sometimes doesn't?
There's no performance difference between a link that's within the same conversation and a link that crosses conversations. It's all the same to the Dialogue System. Even updating dozens of variables in the same node won't cause lag. So the issue is elsewhere.
Are you using any custom registered Lua functions?
On old, low end mobile devices, it's possible to see a little lag when a character barks. This is because the character may need to evaluate the nodes of the bark conversation and all of its Conditions. Ticking the Cache Bark Lines checkbox will prevent it from having to re-evaluate Conditions.
Another possible source of delay is the Sequence field. If a specific node lags, check its Sequence field. If it has any commands, check if those commands are intended to cause some kind of delay. If the Sequence field is blank, the node will use the Dialogue Manager's Camera & Cutscene Settings > Default Sequence, which is initially set to: Delay({{end}})
This causes the node to wait for a duration based on the text length and the Dialogue Manager's Subtitle Settings.
Re: How to fix lag
Posted: Sun Aug 11, 2019 3:30 pm
by lostmushroom
I think its consistent. I have a "master" conversation, which sets several variables and has a lot of nodes checking for different things, before sending you to another random conversation. It seems to happen whenever it runs this master conversation.
The only sequence fields I'm using are Continue() to skip nodes I don't want to show up, and RandomizeNextEntry(). Not using any custom Lua functions.
It's also happening a bit in my Corgi project and seems to be with anything to do with the inventory. Adding, subtracting and getting quantities of items in the inventory caused a lag.
Could it be the default sequence in Camera/Cutscene settings? Should I delete that?
Re: How to fix lag
Posted: Sun Aug 11, 2019 3:47 pm
by Tony Li
lostmushroom wrote: ↑Sun Aug 11, 2019 3:30 pmIt's also happening a bit in my Corgi project and seems to be with anything to do with the inventory. Adding, subtracting and getting quantities of items in the inventory caused a lag.
Adding, subtracting, and getting using the Dialogue System (e.g., the Lua functions such as mmAddItem())? Or inventory in general?
lostmushroom wrote: ↑Sun Aug 11, 2019 3:30 pmCould it be the default sequence in Camera/Cutscene settings? Should I delete that?
Your default sequence should be set to something. I recommend leaving it unchanged for now.
Are there any messages in the Console window? (Side note: every message that's logged to the Console window does a stack trace of the running code, which is a length operation. If you've set the Dialogue Manager's Debug Level to Info, this will cause lag because it logs a lot of messages.)
Re: How to fix lag
Posted: Mon Aug 12, 2019 2:19 pm
by lostmushroom
Yeah, using the Lua functions.
The Debug level was set to warnings, but there were quite a few messages so I set it to None. Not sure it's made a difference though, I'm still getting a slight lag in the same place.
Re: How to fix lag
Posted: Mon Aug 12, 2019 2:49 pm
by Tony Li
Each Lua function does need to check with Inventory Engine. I can look into optimizing this check. Can you distribute the Lua functions so fewer of them run at the beginning of the conversation? For example, if you can defer half of them until the next node, it will cut the lag in half. (This is assuming all Lua functions have an equal amount of overhead with Inventory Engine. In reality, some functions may have more overhead than others.) Alternatively, if you're checking the same thing in multiple nodes, you can use a group node to call the function just once and store the result in a variable. Then check the variable instead of calling the function again.
Re: How to fix lag
Posted: Mon Aug 12, 2019 3:00 pm
by lostmushroom
Cool, I can try that
thanks
Re: How to fix lag
Posted: Mon Aug 12, 2019 3:43 pm
by Tony Li
Also feel free to send a copy of the conversation to tony (at) pixelcrushers.com if you'd like me to take a closer look. I might be able to suggest some ways to optimize it.
If I can optimize the way the Lua functions interface with Inventory Engine, I'll include a note in the next version's release notes.
Re: How to fix lag
Posted: Mon Aug 12, 2019 8:58 pm
by Tony Li
Wow, that lag was terrible. Sorry! Please import this updated package:
DS_InventoryEngineSupport_2019-08-12.unitypackage
It should fix the issues. You shouldn't have to change your Conditions and Script fields.
Re: How to fix lag
Posted: Tue Aug 13, 2019 2:37 pm
by lostmushroom
Amazing, thanks for the fix!