Closed rakaramos closed 5 years ago
Merging #352 into master will decrease coverage by
0.02%
. The diff coverage is0%
.
@@ Coverage Diff @@
## master #352 +/- ##
========================================
- Coverage 44.03% 44% -0.03%
========================================
Files 30 30
Lines 3861 3863 +2
========================================
Hits 1700 1700
- Misses 2161 2163 +2
Impacted Files | Coverage Δ | |
---|---|---|
Sources/XiEditor/EditView.swift | 54.44% <0%> (-0.32%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 59d72e9...e9213f7. Read the comment docs.
My (limited) knowledge about macOS APIs agrees with using CADisplayLink. Maybe this should even have its own layer if it doesn't already.
@cmyr fair enough, that's correct! Also #315 is the right place for it, and with opengl dropped in favour of metal, complicates it. thanks!
@cmyr turned out to only be on multi-display when you do it a certain way that it fakes it with a timer. Most of the time it works. See the update to http://thume.ca/2017/12/09/cvdisplaylink-doesnt-link-to-your-display/
I still think an NSTimer is probably what you want here since the frequency is low. If you were doing a Sublime-style smooth fade you'd want display link.
Addresses: #320
As per @cmyr's comment, this should fix the issue.
Pitch
Something caught my attention on this class, the
cursor blink
state is managed viaNSTimer
class (doing UI work), every 1 second.IMHO, that should be done via CVDisplayLink because it's machinery allows us to run code on every frame refresh.
I would love to create a PR with these changes, but first I would like to run it by you guys. Please note that I'm not an macOS expert, I do iOS for a living and when we have a situation like that, we avoid
NSTimer
in favour ofCADisplayLink
. Just porting some knowledge that maybe makes sense on the macOS side.EDIT Further digging into
CVDisplayLink
:CVDisplayLink
is the recommended way to synchronize your drawing/animation with the refresh of the display on macOS. Many people assume it calls your app just after each displayvsync
event, unfortunately this isn’t the case at all.CVDisplayLink
just fetches the refresh rate of your display, and sets a high resolution timer to call you every 16.6ms (for a 60hz display).Source