I worked most of the day trying to debug the digital radio decodes that come my way via websocket. In particular I find inconsistent results when the window receiving the payloads lacks focus. This specialized log provides observability into the strange behavior on both ends of the connection. expand
Each cell intends to collect five seconds of activity with seconds labeled across the top and minutes down the side. I'm using Date.now() and setInterval for async recording. The radio is decoding gps synchronous signals from four bands on a 15-second cadence.
Minute 09 was as expected: 60 dots, three bands decoded every 15 seconds. From minute 10 to minute 46 I was trying to check-in my work. I see setInterval stopping. Date.now() returning wrong values. And the websocket eventually wedging completely.
I find the radio application (SparkSDR) is frozen. I poke it back to life and then return to my html script on the receiving end of the websocket. enlarge
I've gained a lot of experience watching this get scrambled as focus moves and the operating system sleeps. I've found rows should depend on any event reliably timed with Date.now(). The interval timer is still useful to show when the ui is active but websocket wedged. I've added a reopen button that reconnects the websocket and find that is often required after an os sleep. Current version online. github