View Issue Details

IDProjectCategoryLast Update
0024706AI War 2Crash/ExceptionDec 9, 2021 1:47 am
ReporterCrabby Assigned ToChris_McElligottPark  
Severitycrash 
Status resolvedResolutionfixed 
Product Version2.803 Multiplayer Option Overload 
Fixed in VersionBeta 3.743 Return Of The Imperial Spire 
Summary0024706: Delete Campaign Error
DescriptionI was clearing out my campaigns. I deleted one. Then when I clicked delete campaign again, it asked me if I wanted to delete the one I just deleted. I have this exception appear. It should tell me that I haven't selected a campaign to delete or tell me that I'm deleting a different campaign (yellow text).

I have attached screenshots and the debug log; the very end of the debug log shows the exception.
TagsNo tags attached.

Relationships

has duplicate 0025412 resolvedChris_McElligottPark A small bug when deleting several campaigns 
has duplicate 0025865 resolved Repeatedly clicking Delete Campaign in the Load Game screen throws an error 
related to 0025735 resolvedChris_McElligottPark Autosave - pathing issue 
related to 0025722 resolvedChris_McElligottPark Saving more consecuive times in a row changed campaign to tutorial 

Activities

Crabby

Apr 17, 2021 12:46 pm

reporter  

Delete Campaign Error.png (893,790 bytes)
ArcenDebugLog.txt (1,951,482 bytes)

Crabby

Jun 12, 2021 3:36 pm

reporter   ~0062066

I tried again, and I inadvertently deleted a campaign that I was in the middle of. Then I deleted the test campaign, and then I clicked again, and this shows up.

Now I'm peeved that I lost my campaign I was in the middle of.
Delete Campaign Error 3.png (1,168,149 bytes)

Crabby

Jun 12, 2021 3:38 pm

reporter   ~0062067

Mind you, this is if I don't manually click on the campaigns.

tom.prince

Oct 21, 2021 2:30 am

developer   ~0062984

It looks like this happens because SaveLoadMethods.ParseListOfOnDiskCampaigns in CodeExternal/AIWarExternalCode/src/UIs/MasterMenu/Window_SaveGameMenu.cs uses `Task.Run`, so works asynchronously. But `deleteCampaign` in CodeExternal/AIWarExternalCode/src/UIs/Window_LoadGameMenu.cs expects it to have populated SaveLoadMethods.SortedCampaignNames as soon as it has returned. Removing the Task.Run (and Action) from ParseListOfOnDiskCampaigns does fix the issue, but I don't know the history of why that method was made (partially) asynchronous.

I've attached a patch that makes ParseListOfOnDiskCampaigns synchronous, which seems like the simplest fix, if that is an acceptable solution. I can think of other ways to address the issue if it is important to keep it asynchronous.

While debugging this, I also noticed that after deleting a save, the load screen still thinks you have the deleted save selected. This is most noticeable if you delete a save and them immediately click start (which gives you a `Could not find savegame path:`). I've also attached a patch which clears the selection when a save is deleted.
delete-campaigns-fix.patch (1,517 bytes)   
# HG changeset patch
# User Tom Prince <[email protected]>
# Date 1634796978 21600
#      Thu Oct 21 00:16:18 2021 -0600
# Node ID 6253a5dea07c97a170765b4c23b0acc1b6a0613a
# Parent  cd511aa5e9630790ecdb9a6738d3bca30fc79ebb
Fix deleting multiple campaigns.

`ParseListOfOnDiskCampaigns` was running asynchronously, but the delete campaign code was
assuming that it ran synchronously, so `Window_LoadGameMenu` didn't have a consistent idea
of what the current campaign is. In particular, `cachedCurrentCampaignName` was set incorrectly.

By changing `ParseListOfOnDiskCampaigns` to run synchronously, we avoid the inconsistencies when
deleting a campaign.

diff --git CodeExternal/AIWarExternalCode/src/UIs/MasterMenu/Window_SaveGameMenu.cs CodeExternal/AIWarExternalCode/src/UIs/MasterMenu/Window_SaveGameMenu.cs
--- CodeExternal/AIWarExternalCode/src/UIs/MasterMenu/Window_SaveGameMenu.cs
+++ CodeExternal/AIWarExternalCode/src/UIs/MasterMenu/Window_SaveGameMenu.cs
@@ -478,7 +478,6 @@ namespace Arcen.AIW2.External
                 case 1: //time since start
                 case 2:
                 default:
-                    Action action = () =>
                     {
                         for ( int i = 0; i < WorkingCampaignNames.Count; i++ )
                         {
@@ -497,7 +496,6 @@ namespace Arcen.AIW2.External
                         WorkingCampaignNames.Clear();
                     };
 
-                    Task.Run( action );
 
                     break;
             }
delete-campaigns-fix.patch (1,517 bytes)   
delete-save-selection.patch (999 bytes)   
# HG changeset patch
# User Tom Prince <[email protected]>
# Date 1634797023 21600
#      Thu Oct 21 00:17:03 2021 -0600
# Node ID 43519c3e7b9d1cda580617f68d773470a9c51fdf
# Parent  6253a5dea07c97a170765b4c23b0acc1b6a0613a
Clear the savegame selection when deleting a save in the load menu.

diff --git CodeExternal/AIWarExternalCode/src/UIs/Window_LoadGameMenu.cs CodeExternal/AIWarExternalCode/src/UIs/Window_LoadGameMenu.cs
--- CodeExternal/AIWarExternalCode/src/UIs/Window_LoadGameMenu.cs
+++ CodeExternal/AIWarExternalCode/src/UIs/Window_LoadGameMenu.cs
@@ -418,6 +418,7 @@ namespace Arcen.AIW2.External
             private void deleteSave()
             {
                 World.Instance.DeleteSaveGame( Instance.saveSelected.saveFullFilename, false, false );
+                Instance.saveSelected = null;
                 Instance.PopulateListOfSavegamesInCampaign();
             }
             public override MouseHandlingResult HandleClick_Subclass( MouseHandlingInput input )
delete-save-selection.patch (999 bytes)   

tom.prince

Oct 26, 2021 1:53 am

developer   ~0063001

It looks like you add the Task.Run usage in r12222/r12230 to improve performance with lots of campaigns saves, which suggests that it doesn't make sense to just remove it. It doesn't seem like there is an obvious way to get a notification from ParseListOfOnDiskCampaigns completing. (It looks like there are only a handful of Task.Run calls at all).

Having an interface for getting the list of campaigns from, which we might delete a campaign from doesn't seem like a robust interface. One option that occurred to me as I was writing this, is to just delete the campaign from the list we have, rather than going back to disk, but I'm hesitant about mutating something not owned by the load game screen. I'm curious if you have any thoughts on this.

Chris_McElligottPark

Nov 2, 2021 2:15 pm

administrator   ~0063148

Thanks!

* Fixed several groups of errors that could happen when deleting campaigns, relating to exceptions and having the wrong campaign selected, etc. Some of this was indeed because we were using an asynchronous callback when -- after a delete in particular -- we needed to use a synchronous one for the sake of accuracy.

Issue History

Date Modified Username Field Change
Apr 17, 2021 12:46 pm Crabby New Issue
Apr 17, 2021 12:46 pm Crabby File Added: Delete Campaign Error.png
Apr 17, 2021 12:46 pm Crabby File Added: Delete Campaign Error 2.png
Apr 17, 2021 12:46 pm Crabby File Added: ArcenDebugLog.txt
Jun 12, 2021 3:36 pm Crabby Note Added: 0062066
Jun 12, 2021 3:36 pm Crabby File Added: Delete Campaign Error 3.png
Jun 12, 2021 3:38 pm Crabby Note Added: 0062067
Oct 21, 2021 2:30 am tom.prince Note Added: 0062984
Oct 21, 2021 2:30 am tom.prince File Added: delete-campaigns-fix.patch
Oct 21, 2021 2:30 am tom.prince File Added: delete-save-selection.patch
Oct 26, 2021 1:35 am tom.prince Assigned To => Chris_McElligottPark
Oct 26, 2021 1:35 am tom.prince Status new => assigned
Oct 26, 2021 1:53 am tom.prince Note Added: 0063001
Nov 1, 2021 1:53 am tom.prince Relationship added related to 0025735
Nov 1, 2021 2:04 am tom.prince Relationship added related to 0025722
Nov 2, 2021 2:15 pm Chris_McElligottPark Status assigned => resolved
Nov 2, 2021 2:15 pm Chris_McElligottPark Resolution open => fixed
Nov 2, 2021 2:15 pm Chris_McElligottPark Fixed in Version => Beta 3.743 Return Of The Imperial Spire
Nov 2, 2021 2:15 pm Chris_McElligottPark Note Added: 0063148
Nov 2, 2021 9:30 pm tom.prince Relationship added has duplicate 0025412
Dec 9, 2021 1:47 am tom.prince Relationship added has duplicate 0025865