Monday August 30, 2021; 4:27 PM EDT
- There was a big data-losing bug in Drummer, and last night I think I got it. #
- Of course I was looking in the wrong place. Staring at code that wasn't working and not questioning whether or not it worked. One of the oldest programmer debugging mistakes. How long have I been programming? Too long. I still make this most obvious error. I suck!!!#
- So here's the setup.#
- At least two tabs open, one is an instant outline, the other could be anything.#
- The other one is frontmost.#
- A change comes in for the instant outline. Since it is not frontmost, we stash the opmltext somewhere out of the way until the user activates the I/O by clicking in its tab. (I/O is the shorthand for instant outline.)#
- Click in the tab of the I/O.#
- Drummer then starts activating the I/O. If it finishes before it gets to the code where it installs the updated outline, everything is cool, nothing gets overwritten. This is what's called a "race condition" in programming.#
- But if it's still doing the activation when it installs the opmltext, it will go into the other outline, which is now not visible.#
- And it shows the I/O but the old version of it. Since you don't know what to expect, you don't notice it.#
- Then when you switch back to the other outline, oh my god, it's got the I/O outline. #
- If you then make a change, it will write it back out to the server. And you've lost your outline. #
- The fix was simple. Don't install the new opmltext until the I/O is fully activated. #
- As I've been writing this I've been switching back and forth over in Drummer on every line I type.#
- It hasn't fucked up once! #
- Hoo hah, I think I got it. #
- 😀😀😀😃😄😁😆😅😂😇😉😍#