
On 26 November my laptop assistant crashed twice. Two different crashes, two different parts of the system, one day. The first, at 11:26 in the morning, was a stack overrun inside the interface library. The second, at 17:54 in the evening, was heap corruption — the memory manager catching damage in the audio pipeline. Different errors, different code, but the same day, and the same machine. That was the first clue that the problem was not one bug. It was the way the whole machine was put together.
The crash dumps told the story in pieces. The evening crash left a 30 MB dump file. Its faulting thread carried more than a hundred frames from the Python runtime, dozens from the Windows core, and a trail through the audio and number-crunching libraries — PortAudio, numpy, scipy, the C foreign-function layer. The morning crash was different code, same shape: native libraries, many threads, one shared heap. Around forty-nine threads were running. The assistant mixes interface code, camera code, number crunching, audio, and a machine-learning runtime in one process. A minidump can show where the damage was found. It cannot show which call caused it. So the fix could not be one line in one place. It had to change how the parts share the machine.
There was also a third failure, quieter than the crashes. The screen capture kept failing with "Access is denied" whenever the screen was locked or a secure desktop was showing. The assistant tried to take a screenshot, Windows refused, and the error bubbled up through the log. Not a crash, but the same family of problem: a native call that assumes the world is always ready, in a world that is not.
The Fix, in One Commit
Faisal picked the first of the options on the table: serialize the audio access — make the audio parts take turns instead of talking over each other. He implemented it directly, and by the evening the work was one commit, pushed to the main branch and verified on GitHub: "feat(stability): harden screen capture with BitBlt fallback, serialize PortAudio access, and add Layer 6 DND". Three fixes, one commit, plus a crash recorder that had been installed earlier.
Fix One: Four Ways to See the Screen
Screen capture now has four layers. It tries the fast capture library first. If that fails, it tries the operating system's own image grab. If that fails, it tries the automation library. And if the screen is locked and nothing can see it, it draws a plain standby frame — 1280 by 720, a simple placeholder — instead of crashing. The assistant can now say "I cannot see the screen right now" with a picture, instead of dying while trying. The locked screen is not an error any more. It is a state, and the code handles it.
Fix Two: One Voice at a Time
The audio fix is a small new file, forty-two lines, built around a single lock. The text-to-speech player, the voice recorder, and the room listener all take the same lock before they touch the audio device, and they release it when they are done. The lock waits up to ten seconds, then reports whether it got in. The room listener yields while the lock is held, instead of recording over the speaker. Before this, three parts of the program could open the audio device at the same moment, through the same native library, on different threads. That is the pattern the crash dumps pointed at. Now one voice uses the microphone and the speaker at a time. It is slower in theory. In practice, the crashes were slower.
Fix Three: Knowing When to Stay Quiet
The third fix is the do-not-disturb layer. The assistant now checks three things before it speaks on its own: whether a do-not-disturb flag is set in its memory, whether it heard speech in the room in the last sixty seconds, and whether a meeting app is in the foreground — video calls, chat apps, and the words call, meeting, talking, huddle, or room in the window title. If any of those is true, it stays quiet and writes "DND active — staying quiet" in its log. The room listener now starts with the rest of the program, so the speech check has real data behind it. An assistant that speaks during a meeting is not helpful. It is an interruption with a voice.
Verified, Not Assumed
The install was checked the way this work is always checked: by reading the files on the laptop and watching the program run. All the files had fresh timestamps. But the running program was still the old code — started at 18:08, before the fix — so it was restarted. The new process started at 18:39:45, its state file was ticking fresh at 18:41:08, the mood reading was stressed, awareness was on, and the health check returned 200. No crash in the first minutes.
That is not proof. A heap fix needs a full day without a crash before it can be called fixed, and the watchdog and the crash log are the safety net until then. What the evening proved is smaller and more honest: the new code is in, it starts clean, and it runs.
When your tools crash twice in one day, do you fix the crash, or do you fix the way the parts share the machine?
Comments
Post a Comment