XVimProject / XVim

Xcode plugin for Vim keybindings
MIT License
5.16k stars 596 forks source link

Poor text rendering performance with retina #637

Open damian0815 opened 10 years ago

damian0815 commented 10 years ago

I just upgraded my quasi-Mac Pro to 4k resolution, and I'm experiencing spectacularly bad text drawing performance in Xcode as a result (along the lines of 1fps while typing, with the main thread is blocked, so I'm getting a maximum of 1 keypress per second in to the editor). If I drag the Xcode window onto my non-4k monitor where Retina rendering is disabled, the problem goes completely away.

Tracing with Instruments, it seems to be caused by _drawInsertionPointInRect:color: drawInsertionPointInRect:color:turnedOn: internally calling [base drawRect:]. If I comment out the calls to [base drawRect:] in these functions:

https://gist.github.com/damiannz/61cc3703ad2eeda6270d

my text rendering performance shoots up, to the point where Xcode is usable again. The only issue so far is that the caret doesn't blink, but I can live with that.

I'm not very familiar with Cocoa, but it looks to me like these lines are re-rendering the entire window. Is this really necessary? Couldn't we create a clipping rect that isolates the caret, and only draw that?

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

JugglerShu commented 10 years ago

Thanks for the report. Yea it is non necessary rendering and I wanted to remove. Actually in 'develop' branch it is already removed. Try that branch if you need it now.

The reason why I couldn't redraw only the area of the caret is because the actual caret rect is held internally in NSTextView. This is not visible from outside. (I need a little hacky code to access it.)

damian0815 commented 10 years ago

Ahh, ok - thanks! I'll give it a try.

damian0815 commented 10 years ago

Hmm, performance isn't better in develop, and I have a flickering issue where, when the caret should blink, the entire window clears and the only part being drawn is the area around the caret :(