Fix a crash at EditView _blinkInsertionPoint #352
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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