Bug 109765

Summary: Reschedule shared CFRunLoopTimer instead of reconstructing it
Product: WebKit Reporter: Antti Koivisto <koivisto>
Component: PlatformAssignee: Nobody <webkit-unassigned>
Status: REOPENED    
Severity: Normal CC: darin, kling, rniwa, webkit.review.bot
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 109856, 110128    
Bug Blocks:    
Attachments:
Description Flags
patch
none
patch2 kling: review+

Antti Koivisto
Reported 2013-02-13 16:13:05 PST
It is much faster to reschedule with CFRunLoopTimerSetNextFireDate than to repeatedly delete and create timers.
Attachments
patch (3.06 KB, patch)
2013-02-13 16:20 PST, Antti Koivisto
no flags
patch2 (5.69 KB, patch)
2013-02-16 09:54 PST, Antti Koivisto
kling: review+
Antti Koivisto
Comment 1 2013-02-13 16:20:08 PST
Andreas Kling
Comment 2 2013-02-13 16:38:21 PST
Comment on attachment 188213 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=188213&action=review Hilarious! r+ from me since this looks like correct use of the API to me, though you might wanna double-check with someone with more CF knowledge. > Source/WebCore/platform/mac/SharedTimerMac.mm:154 > + static CFRunLoopTimerRef timer; > + if (!timer) { You could use dispatch_once() for this block.
Antti Koivisto
Comment 3 2013-02-13 17:05:52 PST
Darin Adler
Comment 4 2013-02-14 09:45:33 PST
When I first implemented SharedTimer I tried using CFRunLoopTimerSetNextFireDate and it didn’t work. Maybe I did it wrong. Or maybe there were CF bugs that have since been fixed. Someone should be sure to test this on the oldest OS X and iOS versions that WebKit currently supports in case that old bug is not fixed there.
Antti Koivisto
Comment 5 2013-02-14 12:48:40 PST
(In reply to comment #4) > When I first implemented SharedTimer I tried using CFRunLoopTimerSetNextFireDate and it didn’t work. Maybe I did it wrong. Or maybe there were CF bugs that have since been fixed. Someone should be sure to test this on the oldest OS X and iOS versions that WebKit currently supports in case that old bug is not fixed there. JSC already uses CFRunLoopTimerSetNextFireDate for HeapTimer.
WebKit Review Bot
Comment 6 2013-02-14 13:29:03 PST
Re-opened since this is blocked by bug 109856
Antti Koivisto
Comment 7 2013-02-14 13:31:33 PST
Antti Koivisto
Comment 8 2013-02-14 13:33:00 PST
Maybe nested event loops are causing problems or something?
Antti Koivisto
Comment 9 2013-02-16 09:54:18 PST
Created attachment 188716 [details] patch2 try to fix the inspector debugger
Andreas Kling
Comment 10 2013-02-16 21:28:56 PST
Comment on attachment 188716 [details] patch2 View in context: https://bugs.webkit.org/attachment.cgi?id=188716&action=review > Source/WebCore/platform/mac/SharedTimerMac.mm:177 > +void reinsertSharedTimer() > +{ > + // For some reason the timer won't fire in a nested runloop unless it has been freshly inserted. > + CFRunLoopTimerInvalidate(globalSharedTimer); > + CFRelease(globalSharedTimer); > + globalSharedTimer = 0; > +} This function's name seems to be at odds with its contents. Where does the timer actually get re-inserted?
Antti Koivisto
Comment 11 2013-02-17 10:39:33 PST
(In reply to comment #10) > This function's name seems to be at odds with its contents. > Where does the timer actually get re-inserted? From sharedTimer(), next time the timer is accessed. This will happen from ThreadTimers::fireTimersInNestedEventLoop() right after this call. Suggestions welcome.
Andreas Kling
Comment 12 2013-02-17 14:25:52 PST
Comment on attachment 188716 [details] patch2 View in context: https://bugs.webkit.org/attachment.cgi?id=188716&action=review r=me if you find a nicer color for the bikeshed. > Source/WebCore/platform/mac/SharedTimerMac.mm:171 > +void reinsertSharedTimer() I'd just prefer to call this removeFoo() instead of reinsertBar() since that's what it does.
Antti Koivisto
Comment 13 2013-02-18 06:30:37 PST
WebKit Review Bot
Comment 14 2013-02-18 09:00:53 PST
Re-opened since this is blocked by bug 110128
Antti Koivisto
Comment 15 2013-02-18 09:05:04 PST
The bots still see some nested runloop related failures.
Eric Seidel (no email)
Comment 16 2013-03-01 10:39:55 PST
Comment on attachment 188213 [details] patch Cleared Andreas Kling's review+ from obsolete attachment 188213 [details] so that this bug does not appear in http://webkit.org/pending-commit.
Note You need to log in before you can comment on or make changes to this bug.