[Webkit-unassigned] [Bug 189335] [RunLoopGeneric] OneShotTimer should not remain "isActive" after fired

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Mar 10 13:25:45 PST 2021


https://bugs.webkit.org/show_bug.cgi?id=189335

Stephan Szabo <stephan.szabo at sony.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stephan.szabo at sony.com

--- Comment #14 from Stephan Szabo <stephan.szabo at sony.com> ---
(In reply to Yusuke Suzuki from comment #13)
> Comment on attachment 349292 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=349292&action=review
> 
> > Source/WTF/wtf/generic/RunLoopGeneric.cpp:54
> >          if (!m_isRepeating)
> > -            return false;
> > +            deactivate();
> 
> Why do we deactivate the timer before `m_function()` is called?
> Cocoa RunLoop says "A non-repeating timer is automatically invalidated after
> it fires.".

I'd just started looking at finishing up this patch, and was playing with the positioning based on this comment. However, I noticed that WTF_RunLoop.OneShotTimer failed if we move the deactivation until after the function is called as it appears to expect isActive() to be false at the time DerivedOneShotTimer's fired function is called.

Looking at some other cases, RunLoopCF seems to call CFRunLoopTimerInvalidate for the timer before calling the fired function as well if CFRunLoopTimerDoesRepeat is false which makes isActive() return false:

    m_timer = createTimer(interval, repeat, [] (CFRunLoopTimerRef cfTimer, void* context) {
        AutodrainedPool pool;

        auto timer = static_cast<TimerBase*>(context);
        if (!CFRunLoopTimerDoesRepeat(cfTimer))
            CFRunLoopTimerInvalidate(cfTimer);

        timer->fired();
    }, this);

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20210310/0436dfa0/attachment.htm>


More information about the webkit-unassigned mailing list