#4924 closed defect (fixed)

ModificationTemplateManager OOS

Reported by: elexis Owned by: elexis
Priority: Release Blocker Milestone: Alpha 23
Component: UI & Simulation Keywords:
Cc: Patch: Phab:D1201

Description

As reported by mimo in Phab:rP20737, the commit introduced this error when deserializing and resigning a game while some auras were applied:

ERROR: Script message handler OnOwnershipChanged failed
ERROR: Script message handler OnOwnershipChanged failed
ERROR: Script message handler OnOwnershipChanged failed
ERROR: Script message handler OnOwnershipChanged failed
ERROR: Script message handler OnOwnershipChanged failed
ERROR: Script message handler OnGlobalOwnershipChanged failed
ERROR: Script message handler OnGlobalOwnershipChanged failed
ERROR: Script message handler OnGlobalOwnershipChanged failed
ERROR: Script message handler OnGlobalOwnershipChanged failed
ERROR: Script message handler OnGlobalOwnershipChanged failed
ERROR: Script message handler OnGlobalOwnershipChanged failed
ERROR: Script message handler OnGlobalOwnershipChanged failed
ERROR: JavaScript error: simulation/components/AuraManager.js line 184
TypeError: this.templateModificationsCache.get(...).get(...).get(...) is undefined
  AuraManager.prototype.RemoveTemplateBonus@simulation/components/AuraManager.js:184:2
  Auras.prototype.RemoveTemplateBonus@simulation/components/Auras.js:393:1
  Auras.prototype.Clean@simulation/components/Auras.js:222:4
  Auras.prototype.OnOwnershipChanged@simulation/components/Auras.js:455:2
  Player.prototype.SetState@simulation/components/Player.js:445:1
  g_Commands.resign@simulation/helpers/Commands.js:449:3
  ProcessCommand@simulation/helpers/Commands.js:47:3

The error can be reproduced from command line on turn 1 using

pyrogenesis -replay="/path/to/commands.txt" -mod=public -rejointest=1

and this replay:

start {"settings":{"PlayerData":[{"AI":"","Civ":"cart","Color":{"b":200,"g":46,"r":46},"Name":"Player","PopulationLimit":10000,"Resources":{"food":10000,"metal":10000,"stone":10000,"wood":10000},"StartingTechnologies":["phase_town","phase_city"],"Team":-1,"AIDiff":3,"AIBehavior":"random"},{"AI":"","Civ":"athen","Color":{"b":20,"g":20,"r":150},"Name":"Creeps","Team":-1,"AIDiff":3,"AIBehavior":"random"}],"CircularMap":true,"GameType":"endless","VictoryScripts":[],"BaseHeight":0,"BaseTerrain":["medit_rocks_grass"],"Description":"Explore the Carthaginian Buildings and Units.","Keywords":["demo"],"LockTeams":false,"Name":"Sandbox - The Carthaginians","Preview":"Sandbox - Carthaginians.png","RevealMap":false,"Script":"corsica.js","Size":192,"PopulationCap":300,"StartingResources":300,"Ceasefire":0,"RelicCount":2,"ExploreMap":false,"DisableTreasures":false,"DisableSpies":false,"CheatsEnabled":true,"RelicDuration":20,"WonderDuration":20,"RegicideGarrison":false,"LastManStanding":false,"RatingEnabled":false,"TriggerScripts":[],"mapType":"scenario","Seed":203870521,"AISeed":4257308017},"mapType":"scenario","mapPath":"maps/scenarios/","mapFilter":"demo","gameSpeed":1,"matchID":"1571F1FEB0DDEDB2","map":"maps/scenarios/Sandbox - Carthaginians","timestamp":1514985029,"engine_version":"0.0.23","mods":["mod","public"]}
turn 0 200
end
turn 1 200
cmd 1 {"type":"resign"}
end
turn 2 200
end
turn 3 200
end
turn 4 200
end

Attachments (1)

superhackylolnopeuneval.patch (2.8 KB) - added by elexis 23 months ago.
This fixes the issue but doesn't look like we want to use it.

Download all attachments as: .zip

Change History (5)

comment:1 Changed 23 months ago by elexis

Ok, it's the same issue as back in the day.

The AuraManager? serializes some data of the JSON templates so after deserialization it fails to identify the original data.

Specifically the affected classes array is affected.

It is used as a key in that complaining line at AuraManager L184.

After deserialization the templateModificationsCache points to the affected array from the deserialized state, but it tries to lookup the array of the template manager which is a different instance.

So we have to teach the AuraManager to not serialize this part either.

Changed 23 months ago by elexis

This fixes the issue but doesn't look like we want to use it.

comment:2 Changed 23 months ago by gameboy

I got a similar error message:

ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnPlayerDefeated failed
ERROR: Script message handler OnGlobalPlayerDefeated failed
ERROR: JavaScript error: simulation/components/AuraManager.js line 184 TypeError: this.templateModificationsCache.get(...).get(...).get(...) is undefined AuraManager.prototype.RemoveTemplateBonus@simulation/components/AuraManager.js:184:2 Auras.prototype.RemoveTemplateBonus@simulation/components/Auras.js:393:1 Auras.prototype.Clean@simulation/components/Auras.js:222:4 Auras.prototype.OnPlayerDefeated@simulation/components/Auras.js:485:2 Player.prototype.SetState@simulation/components/Player.js:452:1 Trigger.prototype.ConquestOwnershipChanged@maps/scripts/ConquestCommon.js:23:5 Trigger.prototype.DoAction@simulation/components/Trigger.js:331:3 Trigger.prototype.CallEvent@simulation/components/Trigger.js:225:4 Trigger.prototype.OnGlobalOwnershipChanged@simulation/components/Trigger.js:270:2
ERROR: Script message handler OnGlobalOwnershipChanged failed
Last edited 23 months ago by gameboy (previous) (diff)

comment:3 Changed 23 months ago by elexis

Milestone: BacklogAlpha 23
Patch: Phab:D1201

comment:4 Changed 22 months ago by elexis

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 21014:

Fix AuraManager? OOS on rejoin following rP20737 / D1108.

The AuraManager? serialized the affects array of the aura JSON files, while the Auras components create new affects arrays upon deserialization.
So the AuraManager? of rejoined clients failed to identify and remove the according aura effects of units who received the aura effect before the rejoin.

Fix it by not serializing the array but only the strings inside the array.
It were preferable to rebuild the modification cache and remove the serialization altogether, refs #3834.

rP18100 introduced the same OOS on rejoin, refs #3909, #4239, but it wasn't noticed due to the revert in rP18804.

Differential Revision: https://code.wildfiregames.com/D1201
Reviewed By: bb
Comments By: gameboy
Fixes #4924

Note: See TracTickets for help on using tickets.