New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SR-2023] Frequency of callbacks on Swift 3 DispatchSource timer event handlers is limited #44632
Comments
cc phabouzit (JIRA User) |
Comment by Pierre Habouzit (JIRA) {{ calls into {{ which looks completely correct to me. so investigating |
Comment by Pierre Habouzit (JIRA) When I trace in the debugger dispatch_source_set_timer() is called with the right interval value, but clearly the code runs at 6Hz and not 60 |
Comment by Pierre Habouzit (JIRA) This is a project bug: DispatchQueue.global(attributes: DispatchQueue.GlobalAttributes(rawValue: DispatchQueueAttributes.qosUserInteractive.rawValue)) is using rawValues that aren't compatible. GlobalAttributes are NOT DIspatchQueueAttributes. DispatchQueue.global(attributes: [ .qosUserInteractive ])) will fix it. |
Comment by Daniel A. Steffen (JIRA) I filed |
Comment by Brett Walker (JIRA) Thanks for catching my mistake, Pierre. Mea culpa. I do agree with Daniel that the new dispatch timer API is quite a mouthful and could be improved. The use of rawValue here doesn't seem to be very Swifty as it encourages the kind of mistake I just made, instead of enforcing stricter type checking. |
Attachment: Download
Environment
Xcode 8 beta 2 (8S162m) / Swift 3
Additional Detail from JIRA
md5: 399932a2429f24cdabecfc676c3870ac
Issue Description:
The frequency of DispatchSource.timer event handler callbacks is being limited in Swift 3. For example, with a scheduled interval of 1.0/60.0, the eventHandler set to the dispatch timer is only called roughly 12 times a second instead of the expected 60 times.
This behavior is (coincidentally or not) similar to a bug concerning NSTimer and CADisplayLink that I filed during Xcode 8b1 (radar #26833801 – fixed in beta 2), except this behavior occurs both on device and Simulator, and does not occur with Swift 2.3 or Objective-C. This may point to something specific within the GCD implementation in Swift 3.
I've attached two test case projects; one is Swift 3 (exhibits the bug), and one is Swift 2.3 (callbacks are as expected).
The text was updated successfully, but these errors were encountered: