Bug 169537

Summary: [WTF] Clean up RunLoop and WorkQueue with Seconds and Function
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: New BugsAssignee: Yusuke Suzuki <ysuzuki>
Status: RESOLVED FIXED    
Severity: Normal CC: benjamin, cdumez, cmarcelo, commit-queue, dbates, keith_miller, mark.lam, msaboff, saam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch cgarcia: review+

Description Yusuke Suzuki 2017-03-12 21:08:07 PDT
[WTF] Clean up RunLoop and WorkQueue with Seconds and Function
Comment 1 Yusuke Suzuki 2017-03-12 21:09:42 PDT
Created attachment 304220 [details]
Patch
Comment 2 Yusuke Suzuki 2017-03-13 11:27:21 PDT
Comment on attachment 304220 [details]
Patch

Thanks!
Comment 3 WebKit Commit Bot 2017-03-13 11:56:58 PDT
Comment on attachment 304220 [details]
Patch

Clearing flags on attachment: 304220

Committed r213858: <http://trac.webkit.org/changeset/213858>
Comment 4 WebKit Commit Bot 2017-03-13 11:57:05 PDT
All reviewed patches have been landed.  Closing bug.
Comment 5 Carlos Garcia Campos 2017-03-14 04:05:11 PDT
Comment on attachment 304220 [details]
Patch

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

> Source/WTF/wtf/glib/RunLoopGLib.cpp:-198
> -    auto intervalDuration = std::chrono::duration<double>(fireInterval);
> -    auto safeDuration = std::chrono::microseconds::max();
> -    if (intervalDuration < safeDuration)
> -        safeDuration = std::chrono::duration_cast<std::chrono::microseconds>(intervalDuration);

Something like this is still needed. GSoure works with microseconds, when std::numeric_limits<double>::infinity() is passed here (like XMLHttpRequest does to disable network timeouts), we will overflow later when trying to convert infinity to microseconds
Comment 6 Carlos Garcia Campos 2017-03-14 04:18:46 PDT
Comment on attachment 304220 [details]
Patch

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

> Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp:42
> -    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.count()), m_dispatchQueue, BlockPtr<void ()>::fromCallable([protectedThis = makeRef(*this), function = WTFMove(function)] {
> +    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.nanoseconds()), m_dispatchQueue, BlockPtr<void()>::fromCallable([protectedThis = makeRef(*this), function = WTFMove(function)] {

This could also overflow now, I think. It doesn't probably happen because dispatchAfter is never called with infinity or a long enough value.
Comment 7 Yusuke Suzuki 2017-03-14 04:52:10 PDT
Reopening to attach new patch.
Comment 8 Yusuke Suzuki 2017-03-14 04:52:15 PDT
Created attachment 304372 [details]
Patch
Comment 9 Yusuke Suzuki 2017-03-14 05:38:04 PDT
Created attachment 304373 [details]
Patch
Comment 10 Carlos Garcia Campos 2017-03-14 06:09:56 PDT
Comment on attachment 304373 [details]
Patch

This looks good to me. Thanks.
Comment 11 Yusuke Suzuki 2017-03-14 06:21:07 PDT
Committed r213896: <http://trac.webkit.org/changeset/213896>