Bug 213771

Summary: [Cocoa] [GTK] RunLoop::Timer::isActive() is incorrect for timers while they are firing
Product: WebKit Reporter: Geoffrey Garen <ggaren>
Component: New BugsAssignee: Geoffrey Garen <ggaren>
Status: RESOLVED FIXED    
Severity: Normal CC: andersca, benjamin, cdumez, cgarcia, cmarcelo, darin, ews-watchlist, jiewen_tan, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Assertion fix none

Description Geoffrey Garen 2020-06-29 20:32:20 PDT
RunLoop::Timer::isActive() is true for one-shot timers even when they're not active
Comment 1 Geoffrey Garen 2020-06-29 20:44:41 PDT
Created attachment 403168 [details]
Patch
Comment 2 Geoffrey Garen 2020-06-30 07:44:49 PDT
Looks like a variant of gtk had this bug too.
Comment 3 Geoffrey Garen 2020-06-30 12:30:24 PDT
Created attachment 403223 [details]
Patch
Comment 4 Darin Adler 2020-06-30 17:19:33 PDT
Comment on attachment 403223 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=403223&action=review

> Source/WTF/wtf/cf/RunLoopCF.cpp:95
> +    if (!CFRunLoopTimerDoesRepeat(cfTimer))
> +        timer->stop();
> +
>      timer->fired();

Could we have put this code inside TimerBase::fired instead? Or does it not have an efficient way to check if the timer is non-repeating?

If stop() would do the trick on GLib too that would be neat.
Comment 5 Geoffrey Garen 2020-06-30 17:50:17 PDT
Glib already had the implicit stop behavior. It needed the inverse fix: be sure to restart if you are a repeating timer. 

I do think we can/should do a shared implementation of isActive in TimerBase. Windows already has all the code we need; just need to migrate it. I hope to return and do that after I finish off callOnMainThread.
Comment 6 EWS 2020-06-30 19:17:30 PDT
Committed r263783: <https://trac.webkit.org/changeset/263783>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403223 [details].
Comment 7 Radar WebKit Bug Importer 2020-06-30 19:18:14 PDT
<rdar://problem/64967584>
Comment 8 Geoffrey Garen 2020-06-30 22:00:02 PDT
Reopening to attach new patch.
Comment 9 Geoffrey Garen 2020-06-30 22:00:03 PDT
Created attachment 403265 [details]
Assertion fix
Comment 10 EWS 2020-06-30 22:21:13 PDT
Committed r263786: <https://trac.webkit.org/changeset/263786>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 403265 [details].