RPTools / maptool

Virtual Tabletop for playing roleplaying games with remote players or face to face.
http://rptools.net
GNU Affero General Public License v3.0
801 stars 262 forks source link

Campaign can be auto-deleted by overriding when starting a server #2262

Open si-lang opened 4 years ago

si-lang commented 4 years ago

Hello guys,

this happened to me a few days ago and today I was able to reproduce this bug. Since this is no "once in a lifetime" thing for me I thought I might file a bug report here:

Describe the bug When trying to start a new server for the currently open campaign MapTool gets into a state where it thinks that there is already a server running. It then automatically switches from the currently active campaign to the default "Grasslands" map only campaign. After that, while trying to create a server using UPnP, MapTool presents error popups (I think there where two) stating that there is already a server running (although there is none). Furthermore, an additional error popup regarding not found UPnP appear. In this state (no server startet and Grasslands campaign open), when saving the campaign, the "blank" Grasslands only campaign will override the previously open campaign and override it. This can also happen automatically if auto-save is configured and you are unlucky with the time-frame (like me that day).

To Reproduce Steps to reproduce the behavior:

  1. Open a campaign (for me it was a bigger one, containing a Pathfinder Framework: https://forums.rptools.net/viewtopic.php?t=26670) and do a backup of it if you want to keep it after the process ;)
  2. Try to start a server using UPnP (for configuration, see screenshot)
  3. This is very unreliable and only "works" sporadically (but if so, quite dramatically)
  4. When the map resets to Grasslands either wait for an automatic save cycle or save manually
  5. Your current campaign should now be overridden

Expected behavior Besides from the bug that there where no two servers running at the given time, an automatic reset to the default campaign should in no way lead to overriding an existing campaign.

Screenshots Screenshot

MapTool Info

Desktop (please complete the following information):

Phergus commented 4 years ago

Can't reproduce this under Windows. Starting a server with Use UPnP enabled but failing doesn't reset the campaign to default for me.

Can any other Mac users confirm this?

Azhrei commented 4 years ago

I am using macOS 10.15.7 (Catalina, with all updates) and cannot reproduce this.

We know there are race conditions in creating/copying the Campaign object, so he's likely seeing an artifact of that.

@si-lang If this is repeatable for you, please turn on full logging before doing Step 2 in your list and then submit the log file after Step 4. To turn on full logging on macOS means running a macro that individually enables the maximum amount of logging for each subsystem. Your log file will be under ~/.maptool-rptools/logs. It can be attached directly or put into a ZIP file and attached. You can navigate to that directory or use ⇧⌘G (Shift-Cmd-G) within Finder and paste that name into the field.

Paste this text into a macro button (if you want to save it) or into the chat window (if you don't care about saving it). If you paste it into a button, click the button afterward to execute the code.

[h: loggers = json.sort(log.getLoggers(),"a","name")]
[r, FOREACH(logger, loggers, "<br/>"), CODE: {
    [r: name = json.get(logger, "name")]
    [r: log.setLevel(json.get(logger, "name"), "DEBUG")]
}]
si-lang commented 4 years ago

Hey guys,

thank you for looking into this. I also can not reconstruct this behavior anymore... Maybe I just had bad luck, having this issue twice in a row. At least I did some digging and can support the theory, that this might be related to a concurrency issue: The framework I am using uses a macro, that lets players switch to a "Starting Map" on campaign load. This also applies for GMs. After starting a server this Macro is also executed for the GM. Maybe in some unfortunate constellation with autosave, this lead to the lost campaign(s) (luckily the second time I did my homework with proper backups). I will let the DEBUG mode run whenever I setup a server. If the bug happens again, I will gladly post the log here.

Azhrei commented 4 years ago

That sounds like a plan. (You likely don't want to leave the DEBUG mode running all the time, though, as it'll generate some pretty huge log files!)

aliasmask commented 3 years ago

I recently heard someone accidentally overwrote their campaign with a grasslands map. This could be a windows thing. When I saved a test campaign, then did a new campaign the default name to save is the last campaign. I think the same thing will happen if you just close the campaign and it asks you to save. If you're not paying attention, then you could overwrite the old campaign. I've never done this, so I'm just guessing as to what may have happened. Not sure there is an MT solution either. Can you put a default file name that is unique when the campaign hasn't been saved before?