[MOD] Distant Terrain

A curated forum for compatible and maintained mods. Users are unable to create new topics in this forum but can reply to existing topics. Please message a moderator to have your mod moved into this forum area.
Post Reply
User avatar
Midknightprince
Posts: 1324
Joined: Fri Aug 11, 2017 6:51 am
Location: San Antonio TX
Contact:

Re: [MOD] Distant Terrain

Post by Midknightprince »

This mod doesn't seem to work right if terrain transitions is not picked for me.
If its OFF, When I fast travel, it stays in the map screen when I get there, so I exit that, and the screen is black with the hud showing (I'm in the game, I can hear it).
So I push esc again and the exit menu pops up, I can see the game in the background (like normal), but when I hit esc again, its still black, I can see the hud, hear the game doing its thing.

BUT, when I have terrain transitions ON, the game crashes like 1 or 2 minutes in..
Tbh, I don't think TT has ever worked for me..

Hopefully you can't find something, cause I tried everything I can think of for like 2 hours, and I have no clue, and I want this thing to work bigtime.
Like, bigtime, bigtime.
Check out my YouTube Channel!

User avatar
SickBoy
Posts: 9
Joined: Sun Jul 22, 2018 2:44 am

Re: [MOD] Distant Terrain

Post by SickBoy »

BUG REPORT

DETAILS:
The "Terrain Transition" option causes a major memory leak. If left alone, it will use up all available RAM until the computer locks/crashes. If you save (and reload) your game indoors, the leak will not start until you exit to an outdoor environment. Even upon re-entering an indoor environment it will continue to leak. Strangest of all: it will keep eating RAM when you have the "ESC" menu up (the one with save/load/sound/music/exit/etc. options) in both indoor and outdoor environments.

STEPS TO REPRODUCE:
Have the "Terrain Transition" option enabled on a save where you're indoors (RAM will be stable at this point), go outside (triggering the leak), go back inside, press ESC, watch the RAM usage increase a dozen or so MB per second until crash.

The leak occurs without those specific steps (so long as you go outside at any point), but that is the easiest way I found to track it and eliminate as many external factors as possible. In comparison: without "Terrain Transition" enabled there will be no leak and RAM usage stabilizes when following the same steps.

EXTRA NOTES:
  • If you're testing with the "ESC" menu up, there will probably be a bit of a drop in RAM usage if you close the menu.. but it will soon (< 1 minute) start to climb again.
  • This occurs even if Terrain Transition is the *only* option enabled (all other combinations of options do as well).
  • Unfortunately, as Midknightprince already reported, disabling "Terrain Transition" completely breaks fast travel.
GAME INFO:
  • DFU Version: Windows Build #124 (64bit)
  • Mod Version: 2.4.0
  • DF Files: From DaggerfallSetup, no optional addons included
  • Other Mods: None used during testing
  • Game Settings:
    Spoiler!
    Image
    Image
TESTING RIG INFO:
  • OS: Windows 7 Ultimate 64bit
  • CPU: Intel i5 4460 @ 3.20GHz (quad core)
  • GPU: NVIDIA GTX 960 2GB
  • RAM: PNY 2x 4GB DDR3 (8GB total)

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: [MOD] Distant Terrain

Post by Nystul »

Not sure what causes this. Does it also happen when Distant Terrain is the only mod and no texture mods are installed?

User avatar
SickBoy
Posts: 9
Joined: Sun Jul 22, 2018 2:44 am

Re: [MOD] Distant Terrain

Post by SickBoy »

Yes. My tests (after a lot of trial and error to figure out what was going on, since I originally thought it was a DFU problem) were with a fresh installation, a new save, and *only* Distant Terrain in terms of mods. I don't use texture mods (or any non-dfmod mods) anyways since my system can't handle them. I then narrowed it down by testing every combination of DT options, with Terrain Transition definitely being the sole culprit.

Same goes for the related bug that Midknightprince reported. Fresh install, fresh save, only using DT... with TT off you can't fast travel without breaking the game, with it on you get a memory leak.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: [MOD] Distant Terrain

Post by Nystul »

I am trying to reproduce this - in unity project this behaves different than in standalone build - strange (edit: no it did not - just me being to stupid to match settings)

update: even without any mods, daggerfall unity temporary (until next call to Resources.UnloadUnusedAssets()) leaks memory indoors... (not much and it is much more with distant terrain mod enabled), funny finding is that opening and closing any gui window will trigger garbage collection and will free up memory (must be Resources.UnloadUnusedAssets(); in UserInterfaceWindow::CloseWindow() function)...

so my findings are garbage collection won't take place and destroy loaded but no longer needed objects until Resources.UnloadUnusedAssets() is called...

Some time ago Interkarma suggested to use GameObject.Destroy function instead of GameObject.DestroyImmediate.
I remember I did not experience any leaks with the old method.
Since quite some time I am also using GameObject.Destroy now for destroying terrain objects of distant terrain mod.

anyway I will try to do some Resources.UnloadUnusedAssets() in some of my mod's functions and see if it helps

User avatar
SickBoy
Posts: 9
Joined: Sun Jul 22, 2018 2:44 am

Re: [MOD] Distant Terrain

Post by SickBoy »

If it's just a matter of triggering Resources.UnloadUnusedAssets(), wouldn't that mean that opening and closing a GUI while indoors should halt the mod-related leak? My reasoning being that since you're indoors, the outdoor assets shouldn't be considered in use... and thus the leak present in the mod wouldn't be re-triggered until you go outdoors again.

I mention this because it's definitely not the case. While toggling GUI elements will indeed dump a fair amount (at least the first time), the leak will still continue afterwards even while staying indoors in the exact same spot... and subsequent toggling won't be nearly as impactful for garbage cleanup.

What exactly is the Terrain Transition supposed to be doing, and are you sure that whatever it does is even part of what Resources.UnloadUnusedAssets() considers for cleanup? I'm wondering if this is more of an infinite loop-related problem, rather than a lack of garbage collection. Just spitballing though, since I'm not even sure what that option is meant to do.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: [MOD] Distant Terrain

Post by Nystul »

SickBoy wrote: Fri Jul 27, 2018 1:53 am If it's just a matter of triggering Resources.UnloadUnusedAssets(), wouldn't that mean that opening and closing a GUI while indoors should halt the mod-related leak? My reasoning being that since you're indoors, the outdoor assets shouldn't be considered in use... and thus the leak present in the mod wouldn't be re-triggered until you go outdoors again.
since there are also coroutines involved that will still run when switching to an interior no... but I agree that it should not go on forever^^
SickBoy wrote: Fri Jul 27, 2018 1:53 am I mention this because it's definitely not the case. While toggling GUI elements will indeed dump a fair amount (at least the first time), the leak will still continue afterwards even while staying indoors in the exact same spot... and subsequent toggling won't be nearly as impactful for garbage cleanup.
as mentioned even dfunity without mods will make memory go up indoors a bit
SickBoy wrote: Fri Jul 27, 2018 1:53 am What exactly is the Terrain Transition supposed to be doing, and are you sure that whatever it does is even part of what Resources.UnloadUnusedAssets() considers for cleanup? I'm wondering if this is more of an infinite loop-related problem, rather than a lack of garbage collection. Just spitballing though, since I'm not even sure what that option is meant to do.
blends near terrain into distant terrain. This is quite resource heavy since it has to create a whole ring of unity terrains around near terrain. so disabling it when your system is not high-end is an option.

edit: I have pinpointed something down - just have to find a solution ;)

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: [MOD] Distant Terrain

Post by Nystul »

new version 2.4.1 is available - get it in the first post of this thread - should fix the memory leaking

User avatar
SickBoy
Posts: 9
Joined: Sun Jul 22, 2018 2:44 am

Re: [MOD] Distant Terrain

Post by SickBoy »

2.4.1 definitely fixed the leak, awesome work!

If you need more info on pinning down the fast travel bug when TT is disabled, let me know... though Midknightprince pretty much covered everything in their post.

User avatar
Nystul
Posts: 1501
Joined: Mon Mar 23, 2015 8:31 am

Re: [MOD] Distant Terrain

Post by Nystul »

Regarding the fast travel bug: how can I reproduce this? I never encountered this one

Post Reply