This concerns https://bugs.kde.org/show_bug.cgi?id=386620.
The bug is a regression caused by using KisRelaxedTimer in KisSignalCompressor. Top of tree repeats with 2 * interval ms when it should repeat with interval ms, thus the lower frame rate. We could fix the problem by reverting KisRelaxedTimer.
Here follows an analysis of what happens and a proposed fix if we use KisRelaxedTimer.
This is what happens in KisCanvas2 (and KisSignalCompressor) during drawing (i.e continuous updates):
(A) updateSignalCompressor gets started: as KisSignalCompressor's timer is inactive: immediate timeout and start timer
(B) during next interval ms: all start requests to updateSignalCompressor get compressed (i.e. m_gotSignals gets set)
(C) after interval ms, timer callback happens, timer stops (as it's configured as single shot)
(D) after a few more ms (e.g. 3 ms), some new update request comes in, updateSignalCompressor gets started from scratch: as KisSignalCompressor's internal timer is inactive, an immediate timeout and and a new start timer happens
(E) and so on...
With QTimer, all this is fine.
But with KisRelaxedTimer, there is one problem: at (D), KisRelaxedTimer is no longer active, since it stopped with the callback in (C), as it's single shot (this is the same behavior as with QTimer). So (D) now restarts the inactive timer. But starting an inactive KisRelaxedTimer will incur an additional delay of up to interval, and this happens after every interval, thus the observed lower frame rate. To illustrate this, here's a typical sequence:
compressor gets started, restarts internal timer
compressor sets m_gotSignals for a few ms
compressor emits signal and stops interval timer
compressor and its timer are inactive for a few ms
compressor gets started, restarts internal timer
compressor sets m_gotSignals for a few ms
compressor emits signal and stops interval timer
The fix here is to make KisSignalCompressor in FIRST_ACTIVE mode be compressing a bit longer and keep its timer running for one more interval. That is, if KisSignalCompressor is compressing, and an compressed event has been sent, it should continue compressing one more interval, before it reverts into neutral mode (i.e. immediate callback mode plus compression).
One could argue, that the current top of tree implementation of KisSignalCompressor in FIRST_ACTIVE mode is not what's intended, as signals actually are emitted more often than once per interval ms due to the effect above.
This patch should guarantee that if events arrive with a rate higher or equal than interval ms, we will output signals with a rate of interval ms. Only if the frequency of the incoming events falls below interval ms, restarts of KisRelaxedTimermight happen, and we might thus drop the event signal output rate to up to 2 * interval ms.