Juce Timer -- assertion (! timerExists(t))


#1

Hey JUCE!

(Inside an Audio Plugin project)

Ran into an assertion that you said to let you know about:

   #if JUCE_DEBUG
    // trying to add a timer that's already here - shouldn't get to this point,
    // so if you get this assertion, let me know!
    jassert (! timerExists (t));
   #endif

I’m not sure which specifics you’d like me to share, but basically, I have a Component with a Timer that redraws at a variable FPS.

The FPS is updated when the block size/ sample rate changes.

here is the function:

void EnvelopeView::setSampleRateAndBlockSize(float srate, int newBlockSize)
{
	if (sampleRate != srate || blockSize != newBlockSize)
	{

		stopTimer();

		// ... determine FPS (<50) based on sampleRate ...

		startTimer(1000.0 / ceil(FPS));
		//^^
		// Assertion when altering buffer size in DAW. However, on first call, no problems.
	}
}

#2

What I should probably have said in that assertion comment is that the most likely cause is the user doing something silly like deleting a dangling pointer, or something involving a race condition. Very unlikely to be a bug in the library, so best to look for mistakes in your own code to track this down.


#3

I hit this assertion today along with the jassert(instance == this) in Desktop::~Desktop().
I have no idea how either of those things could happen lol