Object Pooling Didn’t Fix My Audio Spike. The Import Settings Did.
TL;DR A 5-minute music track set to Decompress On Load froze the main thread for about 390 ms on every cold play, in a Development Build. Switching the clip to Compressed In Memory or Streaming brought the worst frame down to about 2 ms. Object pooling the AudioSource made the play call about 0.02 ms faster, which is real but irrelevant to that spike. Background I […]
Read MoreSwallowing vs. Re-throwing OperationCanceledException in UniTask
The question If you catch OperationCanceledException in a UniTask step and don’t re-throw it, the rest of the chain keeps running and the whole sequence reports success. I’d read that rule many times, but I wanted to see it happen in my own console, with timestamps and frame numbers as evidence. This post is the record of […]
Read MoreCancellationToken.Register(): The Observer Pattern You Already Know
Checking IsCancellationRequested works, but it only works if something is actively looking. A loop mid-await will notice eventually. But what about code that isn’t looping at all — a resource that just needs to clean itself up the moment cancellation happens, with nobody polling it? That’s what Register() is for. Instead of asking “has this […]
Read MoreCancellationTokenSource in Unity: Why “Stop” Doesn’t Always Stop
Have you ever clicked Stop and watched your code keep running anyway? That’s not a bug. It’s a loop that was never given a way to check. It doesn’t ignore you on purpose — it simply never asked, so it never looks. Fixing this doesn’t require a redesign. It takes one object, threaded through the […]
Read More
When Should the View Just… React? Wiring Observer Pattern to a Health Bar
I almost didn’t need Observer pattern for this. A health bar is small — one int, one slider, one button. It would have been faster to just call view.SetSliderValue() directly from wherever health changes. That’s exactly the problem. “Wherever health changes” turns out to be more than one place the moment you add a second damage source, […]
Read More