Windows #58 Massive slowdown in dungeon [resolved]

R.D.
Posts: 379
Joined: Fri Oct 07, 2016 10:41 am

Windows #58 Massive slowdown in dungeon [resolved]

Post by R.D. »

There is massive slowdown when you enter the dungeon in the attached save.

The console gets spammed with

IndexOutOfRangeException: Array index is out of range.
DaggerfallConnect.Arena2.BsaFile.GetRecordId (Int32 record) (at Assets/Scripts/API/BsaFile.cs:247)
DaggerfallWorkshop.SoundReader.GetAudioClip (Int32 soundIndex) (at Assets/Scripts/SoundReader.cs:72)
DaggerfallWorkshop.DaggerfallAudioSource.GetAudioClip (Int32 soundIndex) (at Assets/Scripts/Internal/DaggerfallAudioSource.cs:212)
DaggerfallWorkshop.Game.EnemySounds.IsReady () (at Assets/Scripts/Game/EnemySounds.cs:123)
DaggerfallWorkshop.Game.EnemySounds.FixedUpdate () (at Assets/Scripts/Game/EnemySounds.cs:75)

The problem appears ever since this commit:
https://github.com/Interkarma/daggerfal ... f9b233361c
Attachments
SAVE7.zip
(44.38 KiB) Downloaded 119 times
Last edited by R.D. on Sun Oct 08, 2017 8:10 am, edited 1 time in total.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Windows #58 Massive slowdown in dungeon

Post by Interkarma »

Thanks for the report. :)

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Windows #58 Massive slowdown in dungeon

Post by TheLacus »

Uh sorry, i used the soundindex before this check (if (!soundFile.GetSound(soundIndex, out dfSound))). Should i just move it back where it was? But why is passing a wrong index in the first place?

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Windows #58 Massive slowdown in dungeon

Post by Interkarma »

TheLacus wrote:Uh sorry, i used the soundindex before this check (if (!soundFile.GetSound(soundIndex, out dfSound))). Should i just move it back where it was? But why is passing a wrong index in the first place?
It's all good. Code changes, something breaks, it get fixed again. :)

I definitely wouldn't trust the sound index without verification. It's possible for the game data to reference invalid sound IDs, so a "bad index" is actually an expected input to handle. That's the reason my original implementation was defensive around this input.

GetSound() will usually bounce index for one of two reasons:
  • Most likely: Input sound index is out of range (< 0 || >= count).
  • Less likely: Failed to read valid record index from sound BSA file.
I've added an additional defensive check to top of GetAudioClip() that doesn't require actually trying to get sound as well. Hopefully this fixes it. I'll have more time to drill down into this over long weekend if needed.

User avatar
TheLacus
Posts: 1305
Joined: Wed Sep 14, 2016 6:22 pm

Re: Windows #58 Massive slowdown in dungeon

Post by TheLacus »

Thank you :)

R.D.
Posts: 379
Joined: Fri Oct 07, 2016 10:41 am

Re: Windows #58 Massive slowdown in dungeon

Post by R.D. »

I'm no longer getting the slowdown after the latest commit, thanks!

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Windows #58 Massive slowdown in dungeon

Post by Interkarma »

Great, thanks for following up! :)

R.D.
Posts: 379
Joined: Fri Oct 07, 2016 10:41 am

Re: Windows #58 Massive slowdown in dungeon

Post by R.D. »

I wonder if a particular enemy type caused this. I had the slowdown in the dungeon in the attached save, and then in another I tested, but then not in a third one. Also the issue had existed for a while but I don't know that anyone has mentioned it, so maybe its a somewhat uncommon enemy.

Using the "killall" command in the save file I see human enemies, atronachs (all types), gargoyles and zombies were in the dungeon.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Windows #58 Massive slowdown in dungeon

Post by Interkarma »

Yep, definitely worth running down the source of the problem as well. I'm leaving this open until then, and your save game will help reproduce.

Narf the Mouse
Posts: 833
Joined: Mon Nov 30, 2015 6:32 pm

Re: Windows #58 Massive slowdown in dungeon

Post by Narf the Mouse »

Hmm...Run through the dungeon again and see if any of them don't make sounds?
Previous experience tells me it's very easy to misunderstand the tone, intent, or meaning of what I've posted. If you have questions, ask.

Locked