[GS] Screen freezes/stutters when you select idle builders in late game

I have been getting some weird pathfinding bugs with builders.

This is with unmodded Gathering Storm. It's been a long game (World is in Atomic Era).

I have lots of railroads and in areas with lots of other civilian units, the game's pathfinding gives me lots of bad paths for my builders. Somewhere 7 or 8 tiles away that I should be able to reach in one turn, instead the game has me take a circuitous route that takes 2 or 3 turns.

The game is especially bad at pathfinding with embarked units. When you can move 8 or 9 tiles by water, the game logic seems to prefer taking 2 or 3 turns by disembarking and then re-embarking.
 
I've tried to reproduce it, but even if there is something very noticeable, it's in no way as laggy as some other people are reporting, so it would help to get save from a game with real lag (see results)

Computer:
i7 4770K / GTX 1080ti / 16 GB RAM / Win10

Map:
Giant Earth (cropped to 180x83)
28 civs + 32 CS

Mods/DLC:
- Prismatic - Color and Jersey Overhaul
- Terra Mirabilis
- DLC: Aztec Civilization Pack
- Expansion: Gathering Storm
- DLC: Poland Civilization Pack
- DLC: Vikings Content
- Yet (not) Another Maps Pack


Natural Wonders on the map:
Spoiler :

FEATURE_TORRES_DEL_PAINE
FEATURE_VREDEFORT_DOME
FEATURE_MOTLATSE_CANYON
FEATURE_TSINGY
FEATURE_NAMIB
FEATURE_SALAR_DE_UYUNI
FEATURE_CERRO_DE_POTOSI
FEATURE_BARRIER_REEF
FEATURE_MOSI_OA_TUNYA
FEATURE_KRAKATOA
FEATURE_PANTANAL
FEATURE_KILIMANJARO
FEATURE_LAKE_VICTORIA
FEATURE_SRI_PADA
FEATURE_GALAPAGOS
FEATURE_CHOCOLATEHILLS
FEATURE_DALLOL
FEATURE_OUNIANGA
FEATURE_WHITEDESERT
FEATURE_BIOLUMINESCENT_BAY
FEATURE_SINAI
FEATURE_IKKIL
FEATURE_DEAD_SEA
FEATURE_GIBRALTAR
FEATURE_EVEREST
FEATURE_VESUVIUS
FEATURE_PAMUKKALE
FEATURE_KAILASH
FEATURE_GOBUSTAN
FEATURE_BARRINGER_CRATER
FEATURE_YOSEMITE
FEATURE_GRAND_MESA
FEATURE_CRATER_LAKE
FEATURE_DEVILSTOWER
FEATURE_OLD_FAITHFUL
FEATURE_CLIFFS_DOVER
FEATURE_GIANTS_CAUSEWAY
FEATURE_LYSEFJORDEN
FEATURE_EYJAFJALLAJOKULL


Added a Timer to GetUnitActionsTable( pUnit ) in \Base\Assets\UI\Panels\UnitPanel.lua
Code:
-- ===========================================================================
--    Refresh unit actions
--    Returns a table of unit actions.
-- ===========================================================================
function GetUnitActionsTable( pUnit )
local timer = Automation.GetTime()
    -- Build action table; holds sub-tables of commands & operations based on UI categories set in DB.
    -- Also defines order actions show in panel.

[...]
print("Getting action table for ".. Locale.Lookup(pUnit:GetName()), "", " = " .. tostring(Automation.GetTime() - timer) .. "s") 
    return actionsTable;
end

At turn 344
Spoiler :

Code:
UnitPanel: Getting action table for Redcoat                 = 0.034999847412109s
UnitPanel: Getting action table for Cuirassier             = 0.021000146865845s
UnitPanel: Getting action table for Redcoat                 = 0.0060000419616699s
UnitPanel: Getting action table for Frigate                 = 0.040999889373779s
UnitPanel: Getting action table for Frigate                 = 0.039000034332275s
UnitPanel: Getting action table for Redcoat                 = 0.015000104904175s
UnitPanel: Getting action table for Redcoat                 = 0.0060000419616699s
UnitPanel: Getting action table for Builder                 = 0.27799987792969s
UnitPanel: Getting action table for Trader                 = 0s
UnitPanel: Getting action table for Frigate                 = 0.052000045776367s
UnitPanel: Getting action table for Builder                 = 0.26999998092651s
UnitPanel: Getting action table for Military Engineer     = 0.034999847412109s
UnitPanel: Getting action table for Cuirassier             = 0.019999980926514s
UnitPanel: Getting action table for Builder                 = 0.26600003242493s
UnitPanel: Getting action table for Redcoat                 = 0.0049998760223389s
UnitPanel: Getting action table for Redcoat                 = 0.0049998760223389s
UnitPanel: Getting action table for Frigate                 = 0.039000034332275s
UnitPanel: Getting action table for Frigate                 = 0.039999961853027s
UnitPanel: Getting action table for Redcoat                 = 0.0060000419616699s
UnitPanel: Getting action table for Redcoat                 = 0.005000114440918s
UnitPanel: Getting action table for Redcoat                 = 0.0049998760223389s
UnitPanel: Getting action table for Redcoat                 = 0.005000114440918s
UnitPanel: Getting action table for Builder                 = 0.26600003242493s
UnitPanel: Getting action table for Builder                 = 0.28799986839294s
UnitPanel: Getting action table for Builder                 = 0.2810001373291s
UnitPanel: Getting action table for Frigate                 = 0.039000034332275s
UnitPanel: Getting action table for Frigate                 = 0.039999961853027s
UnitPanel: Getting action table for Cuirassier             = 0.021999835968018s
UnitPanel: Getting action table for Caravel                 = 0.049000024795532s
UnitPanel: Getting action table for Military Engineer     = 0.035000085830688s
UnitPanel: Getting action table for Military Engineer     = 0.033999919891357s
UnitPanel: Getting action table for Redcoat                 = 0.005000114440918s
UnitPanel: Getting action table for Redcoat                 = 0.005000114440918s
UnitPanel: Getting action table for Builder                 = 0.30299997329712s
UnitPanel: Getting action table for Redcoat                 = 0.0069999694824219s
UnitPanel: Getting action table for Redcoat                 = 0.0049998760223389s
UnitPanel: Getting action table for Redcoat                 = 0.0069999694824219s
UnitPanel: Getting action table for Builder                 = 0.34300017356873s
UnitPanel: Getting action table for Builder                 = 0.26600003242493s
UnitPanel: Getting action table for Builder                 = 0.26400017738342s
UnitPanel: Getting action table for Redcoat                 = 0.032999992370605s
UnitPanel: Getting action table for Cuirassier             = 0.019999980926514s
UnitPanel: Getting action table for Frigate                 = 0.038000106811523s
UnitPanel: Getting action table for Frigate                 = 0.039000034332275s
UnitPanel: Getting action table for Builder                 = 0.30299997329712s
UnitPanel: Getting action table for Builder                 = 0.30000019073486s
UnitPanel: Getting action table for Builder                 = 0.28500008583069s
UnitPanel: Getting action table for Builder                 = 0.28600001335144s


At turn 347
Spoiler :

Code:
AutoPlay_InGame: Total Turn time = 52.621000051498 seconds
AutoPlay_InGame: Turn 347 : 1926 AD
UnitPanel: Getting action table for Redcoat         = 0.0069999694824219s
UnitPanel: Getting action table for Redcoat         = 0.0099999904632568s
UnitPanel: Getting action table for Military Engineer         = 0.039999961853027s
UnitPanel: Getting action table for Field Cannon         = 0.0060000419616699s
UnitPanel: Getting action table for Redcoat         = 0.0060000419616699s
UnitPanel: Getting action table for Builder         = 0.36199998855591s
UnitPanel: Getting action table for Frigate         = 0.04800009727478s
UnitPanel: Getting action table for Builder         = 0.3529999256134s
UnitPanel: Getting action table for Field Cannon         = 0.0060000419616699s
UnitPanel: Getting action table for Cuirassier         = 0.0060000419616699s
UnitPanel: Getting action table for Redcoat         = 0.0059998035430908s
UnitPanel: Getting action table for Redcoat         = 0.0069999694824219s
UnitPanel: Getting action table for Builder         = 0.33800005912781s
UnitPanel: Getting action table for Builder         = 0.3289999961853s
UnitPanel: Getting action table for Builder         = 0.33500003814697s


Units on land : ~0.006s
Units on sea : ~0.035s
Builder : ~0.30s

It shows that builder get the action table much slower than other units, but there is a difference of the same scale between land units and embarked/sea units, so I don't think it's proving anything.

Save game attached (turn 347), sadly that game crashes the next turn (sea level change): I can't test further.

So your turn, provide saved games, please, this can't be fixed by anyone (including Firaxis) without any evidences of an issue.

Edit, for reference, at turn 13, with same settings:
Spoiler :

Code:
UnitPanel: Getting action table for Builder         = 0.003000020980835s
UnitPanel: Getting action table for Builder         = 0.0039999485015869s
UnitPanel: Getting action table for Warrior         = 0.0010001659393311s
UnitPanel: Getting action table for Warrior         = 0s
UnitPanel: Getting action table for Warrior         = 0s
UnitPanel: Getting action table for Builder         = 0.0049998760223389s
UnitPanel: Getting action table for Builder         = 0.003000020980835s
 

Attachments

Last edited:
I can comfirm as well that I was getting the builder lag with Terra Mirabilis. I turned it off and havent had the problem since.
 
Never noticed this.
 
Managed to get a game with a bit more lag, tracked down the lag in the
Code:
for operationRow in GameInfo.UnitOperations() do
loop to be in calling the following line
Code:
local bCanStart, tResults = UnitManager.CanStartOperation( pUnit, actionHash, nil, tParameters, true)
for "actionHash" being building an improvement

Spoiler Builder (0.79400014877319s) :

Code:
UnitPanel:   - Getting data for Air Attack         = 0s
UnitPanel:   - Getting data for Automate Exploration         = 0s
UnitPanel:   - Getting data for Build Improvement         = 0.79200005531311s
UnitPanel:   - Getting data for Build Road         = 0s
UnitPanel:   - Getting data for Clear Contamination         = 0s
UnitPanel:   - Getting data for Convert Barbarians         = 0s
UnitPanel:   - Getting data for Deploy         = 0s
UnitPanel:   - Getting data for Designate National Park         = 0s
UnitPanel:   - Getting data for Disembark         = 0s
UnitPanel:   - Getting data for Embark         = 0s
UnitPanel:   - Getting data for Evangelize Belief         = 0s
UnitPanel:   - Getting data for Excavate Artifact         = 0s
UnitPanel:   - Getting data for Fortify         = 0s
UnitPanel:   - Getting data for Fortify Until Healed         = 0s
UnitPanel:   - Getting data for Found City         = 0s
UnitPanel:   - Getting data for Found Religion         = 0s
UnitPanel:   - Getting data for Harvest Resource         = 0.0010001659393311s
UnitPanel:   - Getting data for Launch Inquisition         = 0s
UnitPanel:   - Getting data for Make Trade Route         = 0s
UnitPanel:   - Getting data for Move To         = 0s
UnitPanel:   - Getting data for Move To Unit         = 0s
UnitPanel:   - Getting data for WMD Strike         = 0s
UnitPanel:   - Getting data for Coastal Raid         = 0s
UnitPanel:   - Getting data for Pillage         = 0s
UnitPanel:   - Getting data for Pillage Road         = 0s
UnitPanel:   - Getting data for Plant Woods         = 0s
UnitPanel:   - Getting data for Ranged Attack         = 0s
UnitPanel:   - Getting data for Re-Base         = 0s
UnitPanel:   - Getting data for Remove Feature         = 0s
UnitPanel:   - Getting data for Remove Heresy         = 0s
UnitPanel:   - Getting data for Remove Improvement         = 0s
UnitPanel:   - Getting data for Repair         = 0s
UnitPanel:   - Getting data for Repair Road         = 0s
UnitPanel:   - Getting data for Rest and Repair         = 0s
UnitPanel:   - Getting data for Retrain         = 0s
UnitPanel:   - Getting data for Route To         = 0s
UnitPanel:   - Getting data for Skip Turn         = 0s
UnitPanel:   - Getting data for Sleep         = 0s
UnitPanel:   - Getting data for Spread Religion         = 0s
UnitPanel:   - Getting data for Counterspy         = 0s
UnitPanel:   - Getting data for Disrupt Rocketry         = 0s
UnitPanel:   - Getting data for Gain Sources         = 0s
UnitPanel:   - Getting data for Great Work Heist         = 0s
UnitPanel:   - Getting data for Listening Post         = 0s
UnitPanel:   - Getting data for Recruit Partisans         = 0s
UnitPanel:   - Getting data for Sabotage Production         = 0s
UnitPanel:   - Getting data for Siphon Funds         = 0s
UnitPanel:   - Getting data for Steal Tech Boost         = 0s
UnitPanel:   - Getting data for Travel To New City         = 0s
UnitPanel:   - Getting data for Swap Units         = 0s
UnitPanel:   - Getting data for Transfer to Another City         = 0s
UnitPanel:   - Getting data for Unit Upgrade         = 0s
UnitPanel:   - Getting data for Alert         = 0s
UnitPanel:   - Getting data for Alert         = 0s
UnitPanel:   - Getting data for Heal Religious Units         = 0s
UnitPanel:   - Getting data for Special Operation         = 0s
UnitPanel:   - Getting data for Fabricate Scandal         = 0s
UnitPanel:   - Getting data for Foment Unrest         = 0s
UnitPanel:   - Getting data for Neutralize Governor         = 0s
UnitPanel:   - Getting data for Build Improvement Adjacent         = 0s
UnitPanel:   - Getting data for Perform Rock Concert         = 0s
UnitPanel:   - Getting data for Breach Dam         = 0s
UnitPanel: Getting action table for Builder         = 0.79400014877319s

Spoiler Redcoat on land (0.0060000419616699s) :

Code:
UnitPanel:   - Getting data for Air Attack         = 0s
UnitPanel:   - Getting data for Automate Exploration         = 0.005000114440918s
UnitPanel:   - Getting data for Build Improvement         = 0s
UnitPanel:   - Getting data for Build Road         = 0s
UnitPanel:   - Getting data for Clear Contamination         = 0s
UnitPanel:   - Getting data for Convert Barbarians         = 0s
UnitPanel:   - Getting data for Deploy         = 0s
UnitPanel:   - Getting data for Designate National Park         = 0s
UnitPanel:   - Getting data for Disembark         = 0s
UnitPanel:   - Getting data for Embark         = 0s
UnitPanel:   - Getting data for Evangelize Belief         = 0s
UnitPanel:   - Getting data for Excavate Artifact         = 0s
UnitPanel:   - Getting data for Fortify         = 0s
UnitPanel:   - Getting data for Fortify Until Healed         = 0s
UnitPanel:   - Getting data for Found City         = 0s
UnitPanel:   - Getting data for Found Religion         = 0s
UnitPanel:   - Getting data for Harvest Resource         = 0s
UnitPanel:   - Getting data for Launch Inquisition         = 0s
UnitPanel:   - Getting data for Make Trade Route         = 0s
UnitPanel:   - Getting data for Move To         = 0s
UnitPanel:   - Getting data for Move To Unit         = 0s
UnitPanel:   - Getting data for WMD Strike         = 0s
UnitPanel:   - Getting data for Coastal Raid         = 0s
UnitPanel:   - Getting data for Pillage         = 0s
UnitPanel:   - Getting data for Pillage Road         = 0s
UnitPanel:   - Getting data for Plant Woods         = 0s
UnitPanel:   - Getting data for Ranged Attack         = 0s
UnitPanel:   - Getting data for Re-Base         = 0s
UnitPanel:   - Getting data for Remove Feature         = 0s
UnitPanel:   - Getting data for Remove Heresy         = 0s
UnitPanel:   - Getting data for Remove Improvement         = 0s
UnitPanel:   - Getting data for Repair         = 0.00099992752075195s
UnitPanel:   - Getting data for Repair Road         = 0s
UnitPanel:   - Getting data for Rest and Repair         = 0s
UnitPanel:   - Getting data for Retrain         = 0s
UnitPanel:   - Getting data for Route To         = 0s
UnitPanel:   - Getting data for Skip Turn         = 0s
UnitPanel:   - Getting data for Sleep         = 0s
UnitPanel:   - Getting data for Spread Religion         = 0s
UnitPanel:   - Getting data for Counterspy         = 0s
UnitPanel:   - Getting data for Disrupt Rocketry         = 0s
UnitPanel:   - Getting data for Gain Sources         = 0s
UnitPanel:   - Getting data for Great Work Heist         = 0s
UnitPanel:   - Getting data for Listening Post         = 0s
UnitPanel:   - Getting data for Recruit Partisans         = 0s
UnitPanel:   - Getting data for Sabotage Production         = 0s
UnitPanel:   - Getting data for Siphon Funds         = 0s
UnitPanel:   - Getting data for Steal Tech Boost         = 0s
UnitPanel:   - Getting data for Travel To New City         = 0s
UnitPanel:   - Getting data for Swap Units         = 0s
UnitPanel:   - Getting data for Transfer to Another City         = 0s
UnitPanel:   - Getting data for Unit Upgrade         = 0s
UnitPanel:   - Getting data for Alert         = 0s
UnitPanel:   - Getting data for Alert         = 0s
UnitPanel:   - Getting data for Heal Religious Units         = 0s
UnitPanel:   - Getting data for Special Operation         = 0s
UnitPanel:   - Getting data for Fabricate Scandal         = 0s
UnitPanel:   - Getting data for Foment Unrest         = 0s
UnitPanel:   - Getting data for Neutralize Governor         = 0s
UnitPanel:   - Getting data for Build Improvement Adjacent         = 0s
UnitPanel:   - Getting data for Perform Rock Concert         = 0s
UnitPanel:   - Getting data for Breach Dam         = 0s
UnitPanel: Getting action table for Redcoat         = 0.0060000419616699s

Spoiler Battleship (0.005000114440918s) :

Code:
UnitPanel:   - Getting data for Air Attack         = 0s
UnitPanel:   - Getting data for Automate Exploration         = 0.0039999485015869s
UnitPanel:   - Getting data for Build Improvement         = 0s
UnitPanel:   - Getting data for Build Road         = 0s
UnitPanel:   - Getting data for Clear Contamination         = 0s
UnitPanel:   - Getting data for Convert Barbarians         = 0s
UnitPanel:   - Getting data for Deploy         = 0s
UnitPanel:   - Getting data for Designate National Park         = 0s
UnitPanel:   - Getting data for Disembark         = 0s
UnitPanel:   - Getting data for Embark         = 0s
UnitPanel:   - Getting data for Evangelize Belief         = 0s
UnitPanel:   - Getting data for Excavate Artifact         = 0s
UnitPanel:   - Getting data for Fortify         = 0s
UnitPanel:   - Getting data for Fortify Until Healed         = 0s
UnitPanel:   - Getting data for Found City         = 0s
UnitPanel:   - Getting data for Found Religion         = 0s
UnitPanel:   - Getting data for Harvest Resource         = 0s
UnitPanel:   - Getting data for Launch Inquisition         = 0s
UnitPanel:   - Getting data for Make Trade Route         = 0s
UnitPanel:   - Getting data for Move To         = 0s
UnitPanel:   - Getting data for Move To Unit         = 0s
UnitPanel:   - Getting data for WMD Strike         = 0s
UnitPanel:   - Getting data for Coastal Raid         = 0s
UnitPanel:   - Getting data for Pillage         = 0s
UnitPanel:   - Getting data for Pillage Road         = 0s
UnitPanel:   - Getting data for Plant Woods         = 0s
UnitPanel:   - Getting data for Ranged Attack         = 0s
UnitPanel:   - Getting data for Re-Base         = 0s
UnitPanel:   - Getting data for Remove Feature         = 0s
UnitPanel:   - Getting data for Remove Heresy         = 0s
UnitPanel:   - Getting data for Remove Improvement         = 0s
UnitPanel:   - Getting data for Repair         = 0s
UnitPanel:   - Getting data for Repair Road         = 0s
UnitPanel:   - Getting data for Rest and Repair         = 0s
UnitPanel:   - Getting data for Retrain         = 0s
UnitPanel:   - Getting data for Route To         = 0s
UnitPanel:   - Getting data for Skip Turn         = 0s
UnitPanel:   - Getting data for Sleep         = 0s
UnitPanel:   - Getting data for Spread Religion         = 0s
UnitPanel:   - Getting data for Counterspy         = 0s
UnitPanel:   - Getting data for Disrupt Rocketry         = 0s
UnitPanel:   - Getting data for Gain Sources         = 0s
UnitPanel:   - Getting data for Great Work Heist         = 0s
UnitPanel:   - Getting data for Listening Post         = 0s
UnitPanel:   - Getting data for Recruit Partisans         = 0s
UnitPanel:   - Getting data for Sabotage Production         = 0s
UnitPanel:   - Getting data for Siphon Funds         = 0s
UnitPanel:   - Getting data for Steal Tech Boost         = 0s
UnitPanel:   - Getting data for Travel To New City         = 0s
UnitPanel:   - Getting data for Swap Units         = 0s
UnitPanel:   - Getting data for Transfer to Another City         = 0s
UnitPanel:   - Getting data for Unit Upgrade         = 0s
UnitPanel:   - Getting data for Alert         = 0s
UnitPanel:   - Getting data for Alert         = 0s
UnitPanel:   - Getting data for Heal Religious Units         = 0s
UnitPanel:   - Getting data for Special Operation         = 0s
UnitPanel:   - Getting data for Fabricate Scandal         = 0s
UnitPanel:   - Getting data for Foment Unrest         = 0s
UnitPanel:   - Getting data for Neutralize Governor         = 0s
UnitPanel:   - Getting data for Build Improvement Adjacent         = 0s
UnitPanel:   - Getting data for Perform Rock Concert         = 0s
UnitPanel:   - Getting data for Breach Dam         = 0s
UnitPanel: Getting action table for Battleship         = 0.005000114440918s

Spoiler Military Engineer (0.15100002288818s) :

Code:
UnitPanel:   - Getting data for Air Attack         = 0s
UnitPanel:   - Getting data for Automate Exploration         = 0s
UnitPanel:   - Getting data for Build Improvement         = 0.15000009536743s
UnitPanel:   - Getting data for Build Road         = 0s
UnitPanel:   - Getting data for Clear Contamination         = 0s
UnitPanel:   - Getting data for Convert Barbarians         = 0s
UnitPanel:   - Getting data for Deploy         = 0s
UnitPanel:   - Getting data for Designate National Park         = 0s
UnitPanel:   - Getting data for Disembark         = 0s
UnitPanel:   - Getting data for Embark         = 0s
UnitPanel:   - Getting data for Evangelize Belief         = 0s
UnitPanel:   - Getting data for Excavate Artifact         = 0s
UnitPanel:   - Getting data for Fortify         = 0s
UnitPanel:   - Getting data for Fortify Until Healed         = 0s
UnitPanel:   - Getting data for Found City         = 0s
UnitPanel:   - Getting data for Found Religion         = 0s
UnitPanel:   - Getting data for Harvest Resource         = 0s
UnitPanel:   - Getting data for Launch Inquisition         = 0s
UnitPanel:   - Getting data for Make Trade Route         = 0s
UnitPanel:   - Getting data for Move To         = 0s
UnitPanel:   - Getting data for Move To Unit         = 0s
UnitPanel:   - Getting data for WMD Strike         = 0s
UnitPanel:   - Getting data for Coastal Raid         = 0s
UnitPanel:   - Getting data for Pillage         = 0s
UnitPanel:   - Getting data for Pillage Road         = 0s
UnitPanel:   - Getting data for Plant Woods         = 0s
UnitPanel:   - Getting data for Ranged Attack         = 0s
UnitPanel:   - Getting data for Re-Base         = 0s
UnitPanel:   - Getting data for Remove Feature         = 0s
UnitPanel:   - Getting data for Remove Heresy         = 0s
UnitPanel:   - Getting data for Remove Improvement         = 0s
UnitPanel:   - Getting data for Repair         = 0s
UnitPanel:   - Getting data for Repair Road         = 0s
UnitPanel:   - Getting data for Rest and Repair         = 0s
UnitPanel:   - Getting data for Retrain         = 0s
UnitPanel:   - Getting data for Route To         = 0s
UnitPanel:   - Getting data for Skip Turn         = 0s
UnitPanel:   - Getting data for Sleep         = 0s
UnitPanel:   - Getting data for Spread Religion         = 0s
UnitPanel:   - Getting data for Counterspy         = 0s
UnitPanel:   - Getting data for Disrupt Rocketry         = 0s
UnitPanel:   - Getting data for Gain Sources         = 0s
UnitPanel:   - Getting data for Great Work Heist         = 0s
UnitPanel:   - Getting data for Listening Post         = 0s
UnitPanel:   - Getting data for Recruit Partisans         = 0s
UnitPanel:   - Getting data for Sabotage Production         = 0s
UnitPanel:   - Getting data for Siphon Funds         = 0s
UnitPanel:   - Getting data for Steal Tech Boost         = 0s
UnitPanel:   - Getting data for Travel To New City         = 0s
UnitPanel:   - Getting data for Swap Units         = 0s
UnitPanel:   - Getting data for Transfer to Another City         = 0s
UnitPanel:   - Getting data for Unit Upgrade         = 0s
UnitPanel:   - Getting data for Alert         = 0s
UnitPanel:   - Getting data for Alert         = 0s
UnitPanel:   - Getting data for Heal Religious Units         = 0s
UnitPanel:   - Getting data for Special Operation         = 0s
UnitPanel:   - Getting data for Fabricate Scandal         = 0s
UnitPanel:   - Getting data for Foment Unrest         = 0s
UnitPanel:   - Getting data for Neutralize Governor         = 0s
UnitPanel:   - Getting data for Build Improvement Adjacent         = 0s
UnitPanel:   - Getting data for Perform Rock Concert         = 0s
UnitPanel:   - Getting data for Breach Dam         = 0s
UnitPanel: Getting action table for Military Engineer         = 0.15100002288818s


Edit: as reported from other users, removing the natural wonders from the save does not seems to fix the lag when you've reached that point...
 
Thanks for the investigation @Gedemon. As far as I know Terra Mirabilis does nothing to change what Builders can build on any given tile but my guess is that is something in
tResults that includes the recommended Improvement to build. Since TM does a lot to do with yields that could make a difference to the before/after Improvement calculation I suppose.

The issue seems to be to do with Modifiers that have been set up. Removing the NWs doesn't remove the Modifiers and it seems that whatever the code inside
CanStartOperation (BuildImprovement) is doing it is doing something quite inefficient with Modifiers.
 
Last edited:
Looking through Terra Mirabilis for Natural Wonders that are involved with Improvements I got this list:

FEATURE_BARRIER_REEF
FEATURE_BIOLUMINESCENT_BAY
FEATURE_GOBUSTAN
FEATURE_MOSI_OA_TUNYA
FEATURE_VREDEFORT_DOME

Perhaps someone can retest with these disabled in the TM UserSettings.
 
Testing your timing code with a savegame from a Steam users I can confirm the long wait times for getting the unit action table.

Spoiler :

UnitPanel: Getting action table for Samurai = 0.026000022888184s
UnitPanel: Getting action table for Samurai = 0.023999929428101s
UnitPanel: Getting action table for Samurai = 0s
UnitPanel: Getting action table for Samurai = 0s
UnitPanel: Getting action table for Samurai = 0s
UnitPanel: Getting action table for Samurai = 0s
UnitPanel: Getting action table for Builder = 3.2339999675751s
UnitPanel: Getting action table for Builder = 3.1189999580383s
UnitPanel: Getting action table for Builder = 1.6110000610352s
UnitPanel: Getting action table for Builder = 1.9589998722076s
UnitPanel: Getting action table for Builder = 1.4290001392365s
UnitPanel: Getting action table for Builder = 1.3789999485016s
UnitPanel: Getting action table for Reiter = 0.023000001907349s
UnitPanel: Getting action table for Samurai = 0.029999971389771s
UnitPanel: Getting action table for Pike and Shot = 0.029000043869019s
UnitPanel: Getting action table for Cavalry = 0.023999929428101s
UnitPanel: Getting action table for Cavalry = 0.019999980926514s
UnitPanel: Getting action table for Cavalry = 0.023000001907349s
UnitPanel: Getting action table for Cavalry = 0s
UnitPanel: Getting action table for Builder = 1.4430000782013s
UnitPanel: Getting action table for Builder = 1.6470000743866s
UnitPanel: Getting action table for Military Engineer = 0.15999984741211s
UnitPanel: Getting action table for Military Engineer = 0.0010001659393311s
UnitPanel: Getting action table for Military Engineer = 0.15900015830994s
UnitPanel: Getting action table for Military Engineer = 0.15499997138977s
UnitPanel: Getting action table for Builder = 1.4130001068115s
UnitPanel: Getting action table for Builder = 1.3789999485016s
UnitPanel: Getting action table for Builder = 1.4070000648499s
UnitPanel: Getting action table for Culverin = 0.026999950408936s
UnitPanel: Getting action table for Culverin = 0.030999898910522s
UnitPanel: Getting action table for Culverin = 0.03600001335144s
UnitPanel: Getting action table for Samurai = 0s
 
I can eliminate the lag completely by changing the line in UnitPanel.lua from:
Code:
bCanStart, tResults = UnitManager.CanStartOperation(pUnit, actionHash, nil, tParameters, true);
to
Code:
bCanStart, tResults = UnitManager.CanStartOperation(pUnit, actionHash, nil, tParameters, false, false);

From code comments: for 2nd last boolean, false means "No exclusion test" and the last boolean means "No results". I suspect the exclusion test is the inefficient part. Not sure whether this change will only have UI impact.
 
Thanks for all the investigation into this. I was wrapping up a culture victory on a huge map last night building a lot of seaside and ski resorts, and the builder lag was horrible. Hopefully something will be figured out soon!

I'll note that two of the five wonders listed on the previous page were in my game, although neither were in my territory. I'll disable all five in my next game just in case.
 
I’d actually recommend the above change to the core game file lua file as it removes the lag completely. I don't believe that disabling NWs has any effect. Even disabling all ownership effects for all NWs doesn’t remove the lag.
 
Last edited:
First report of this issue on the Terra Mirabilis comments was on the 8th March - one week ago. We did release an update the previous day.
Thanx for looking into this.

I can confirm that I had this issue for the first time in my last game, which I finished a couple of days ago, and I haven't played a lot lately, so it sort of fits the time frame. Lag times on workers was massive late game, we're talking 10+ seconds each time to activate the worker, and another 10+ seconds for it to move and the action panel to update.

I'll try the fix, but obviously would like a solution that doesn't necessitate changing the game files. Any idea whether it will be possible to find a source of the issue and make it go away without changing game code?

PS: Terra Mirabilis is the best mod, so thanx for all the fantastic work.
 
I'll try the fix, but obviously would like a solution that doesn't necessitate changing the game files. Any idea whether it will be possible to find a source of the issue and make it go away without changing game code?

We can make this change to UnitPanel.lua within the mod. Without the DLL source it is quite difficult to locate the source of the issue. Overall I feel that it shouldn't be possible to cause such a lag with the changes that Terra Mirabilis is making. I think there is some dodgy inefficient code with the
UnitManager.CanStartOperation exclusion test that TM is exacerbating or triggering. With the code itself it is hard to trace when might be causing unnecessary looping or processing. If some people play through a game with this code change in place and report no serious issues then we might just release the updated file with the mod as a workaround.
 
Last edited:
So I enabled GameEffectsLogLevel 4 and selected the Builder in my lag example savegame. I get 10,000 lines in the GameEffects.log all Created Requirement and Created Requirement Set. The game looks like it is recreating and reapplying every Requirement and Requirement Set every time I select a Builder which seems unnecessary for a UI process. Pretty sure this is a base game inefficiency now. When I disable the exclusion test in UnitManager.CanStartOperation for Build Improvement I get no extra lines in GameEffects.log. If you're interested this is all the work the GameEffects.log output when I simply select one Builder in the UI.
 

Attachments

Last edited:
The fix above has been released to Steam so we'll see what feedback we get:
https://steamcommunity.com/sharedfiles/filedetails/changelog/1461463960

For the record, the lag is not actually caused by Terra Mirabilis - there are other mods in the GameEffects.log above. I think that because TM adds so many new Requirements and Requirements Sets it makes reloading them all on every Builder select a particularly bad thing.
 
Back
Top Bottom