Pawndemonium is... fixed?! (and how it was fixed)


WELL THEN

First of all, big thanks to Omshinwa for nudging me to look into this again and assisting with some of the debugging. As I mentioned in the postmortem, I feel that this game has a lot of merit, but a fatal bug that made it unplayable.

With some help from them, and the fact that I had access to a different computer that could actually evoke this bug, I got it sorted out and the game is fully playable again without these dumb soft locks.

I'll dive into the technical issues with this problem and how it was fixed. If you don't care about this stuff, you can ignore it 🤓

THE PROBLEM

Ultimately, what would happen was that you could play a board with no issues and then when you moved on to the next board the game would soft lock. The game wouldn't freeze, you could still use menus, but you wouldn't be able to move pieces around and the game was fundamentally unplayable without restarting it.

This led me down a rabbit hole under the assumption that rebuilding the board had some lingering values that didn't get deleted when the prior board was destroyed. Maybe it was referencing a tile that wasn't accessible, or maybe it was trying to access a destroyed piece's data.

THE CHASE

But, in talking with Omshinwa, they shared a very helpful video going through the steps to recreate this and I noticed that the errors started happening as soon as you closed the post-game stats screen.


So I dug through the entire event chain from clicking the "Close" button after finishing a level. Step by step all the way down. Strangely, the errors seemed to happen on the frame AFTER you click the button, which is very odd since pretty much all scene transitions happen in lockstep with each other.

I did a lot of testing to see if things weren't getting deleted when they should and it was all going away as expected.

I should mention that this issue only made itself known on a build of the game, not when the game itself was playing inside of Unity's editor. So diagnosing error logs and iterating was frustrating and time consuming.

Eventually, I decided to get a more verbose stack trace for error message into my in-game logging and eureka... kinda.

Exception- NullReferenceException ~ CmdFlickPiece.GameUpdate () (at <d77af47ee9da48f0987afc993bfb89ce>:0) EventManager.GameUpdate () (at <d77af47ee9da48f0987afc993bfb89ce>:0) CommandManager.Update () (at <d77af47ee9da48f0987afc993bfb89ce>:0)


THE SOLUTION

This doesn't have anything to do with closing the game board and going back to the menu. This is a subprocess to manage when a piece gets "flicked" off the board when it's captured. Part of a command chain to make sure everything happened sequentially instead of all at the same time.

But I was getting errors from that command so I dove into it. There wasn't much there.

  private void GameUpdate()
  {
    ActionComplete = true;
    Object.transform.localPosition += MoveAnim * 0.05f;
    Object.transform.rotation = Quaternion.Euler(0, 0, RotateValue);
    RotateValue += RotateAnim;
    MoveAnim += Vector3.down * 0.05f;
    if (Object.transform.position.y < -10)
    {
      UnityEngine.MonoBehaviour.Destroy(Object.gameObject);
      Complete();
    }
  }

I imagine some of you can tell the problem. The NullReference error is saying that the chess piece no longer exists, which implies that this loop is continuing to run even though the piece itself has been removed from the game. And when you click Close, the board and all pieces get deleted.

Ultimately, this process can't end, because the object no longer exists, so it can never have a Y position of -10, so it can never complete the command, so all of the NEW commands (like moving a piece when you load the board up for another game) get queued up behind something that will never resolve.

The real rub of this is that it only happens if you click the "Close" button fast enough to where the piece hasn't fallen off the screen yet. If you wait a second or two, the piece falls off and gets destroyed like normal and there's no locked command queue on the next board.

The fix itself is pretty simple, just add a check to make sure the object still exists, and if it doesn't kill the process.

  private void GameUpdate()
  {
    ActionComplete = true;
    if (Object == null) { Complete(); return; }
    ...

But getting to that fix took a lot of heartache. As weird as it is to say, but I am thankful that I gave up on this project a year ago because it gave me the opportunity to work on other projects. It allowed for me to become far more aware of how this stuff worked and how to resolve it. Especially putting in my console logging tool.

MOVING ON

I need to assess this game and see where it sits and if it's worth "finishing". I think I have my old notes on it and maybe I can come up with some better ways to make the game a bit more interactive. Back in 2022, this was going to be my next Steam release. It's not there yet, but I'd like to think it could be in the future.

Thanks for reading! I'm glad to put a nail in this bug that plagued me for over 18 months.

-ben

Files

pawndemonium-win.zip 81 MB
Version 20240115-08 Jan 15, 2024
pawndemonium-mac.zip 81 MB
Version 20240115-08 Jan 15, 2024
pawndemonium-linux.zip 83 MB
Version 20240115-08 Jan 15, 2024

Get Pawndemonium

Comments

Log in with itch.io to leave a comment.

(+1)

I never ran into this issue myself, but great to see it fixed!

It might be worth it to fix the main game description, just so that you don't frighten away any potential new players with talk about a game-breaking bug that no longer exists.

Gosh I thought I did that, thank you so much for the catch! I've fixed the page now :)

(+2)

Game looks good to me now, I haven't encountered a bug!

(+1)

Heck yeah! Glad that it's finally working now :)