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
Fix problems with non-native fullscreen and mac 10.12 #405
Conversation
(updated, now with 30% less code-churn) |
b7ea2aa
to
d11480b
Compare
updated to support the whole |
👍 on the surface, building with these commits seems to work! I'll continue to test and see if I can find anything. |
This appears to get rid of the disappearing text problem, but it's really herky-jerky on about half of all switches between full and non-full screens, particularly if one does not have Even with it set to 0.0 (which I like), there are occasional delayed reactions going into or coming out of fullscreen, or times when the window won't respond to a request to switch. Nevertheless, this is a good start! I'm glad someone is finally working on fixing this problem. It's single-handedly preventing me from upgrading to Sierra. |
@chdiza mind doing a quick screen cap so I can see what you're talking about more specifically? |
👍 It looks good it looks similar with Chromium implementation https://chromium.googlesource.com/chromium/chromium/+/master/content/browser/renderer_host/backing_store_mac.mm Could you update scrolling part as Chromium's? Apparently no need to clone CGLayer in 10.6 and later. https://chromium.googlesource.com/chromium/chromium/+/master/content/browser/renderer_host/backing_store_mac.mm#190 |
@splhack ok, will see if drawing from layer -> layer's own context works. looks like it should. re: revert unrelated, the only unrelated change here is the
happy to put that in a separate PR if you like tho. re: code formatting -- didn't find a style guide, just followed best I could. What do you need here? |
@splhack yup, it worked to draw the existing layer on top of its own context. Also cleaned and squashed some. |
@chdiza yeah ok, I see what you mean now; after the fade to black it sometimes re-presents the view at its old size for too long. |
@@ -1468,7 +1519,8 @@ - (void)clearBlockFromRow:(int)row1 column:(int)col1 toRow:(int)row2 | |||
|
|||
- (void)clearAll | |||
{ | |||
CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; | |||
[self releaseLayer]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why releaseLayer here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm basically using it as a stand-in for resize code: when we're in live-resize, I need to keep the old (smaller or larger) layer around in order to draw smoothly -- so I can't release (to resize) the layer and re-initialize it on a window-resize event, I have to wait until we've got the batch for the resized window.
I suppose I coulda also hooked into SetTextDimensionsMsgID
or something like that, but I'd be less sure of the timing of all the various events; might be jittery or racy.
|
||
CGContextRef context = [self getLayerContext]; | ||
CGImageRef cgImage = [signImg CGImageForProposedRect:&r | ||
context:[NSGraphicsContext currentContext] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context:nil will work, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup, worked, updated.
When you set a borderless style on a subclasses window in 10.12, the original behavior in which you could progressively draw partially on a stale window seems to be gone; it blanks the thing after each draw. It's totally unclear to me whether the CoreText engine as written was ever "correct", or maybe it just "accidentally worked" -- no documentation on the internets seems to indicate you're allowed to only draw CoreGraphics updates to a window in drawRect. This PR works around that by drawing onto a persistent background layer which we then blit to the screen. This PR also makes resizing a CoreGraphics view much smoother; the old code was pretty flickery. addreses macvim-dev#312.
@chdiza is this branch any help to the jerking problems? osheroff#1 I honestly can't really tell. |
I can't get the osheroff#1 patch to apply.
|
yeah, the patch is on top of the |
OK, I won't have time to test until tomorrow. |
Was able to test just now. It doesn't help, and indeed even seems worse in the few minutes of playing. Also it spams a bunch of stuff to the terminal when started with |
ok with fade-time of 0.0 it's pretty glitchy. I think it kinda makes it better with the default fade time. |
The opposite. I forgot to mention that my "worse" result (in the osheroff repo) was with default fade time. I did not test it with my preferred 0.0 (which is mostly working fine in this PR). |
huh. plz do do a screen-cap (or maybe just record yr screen with your phone, for me screen cap doesn't get the fade-out), I'm just not sure I'm seeing what you're seeing. |
at any rate, I wouldn't think the full-screen jerks should block a merge (given 10.12 is busted in this config without the patch). What you say @splhack? Mergable? |
@osheroff I thought it's mergable but I felt some rendering lag when I tested this diff on 10.11.6. Maybe need runtime version check (10.12 or later) to enable this backing CGLayer. |
I don't know how to record my screen, and I don't have a mobile device. When I get a chance, I will try to describe in detail what I see. |
The present PR, built and used on El Cap, and MMFullScreenFadeTime of 0.0, results in a small visual regression. Specifically, once the full screen is painted with the background color, but before any of the text in the Vim window gets displayed, there is the quick blink of a small rectangle that is exactly the size of the cursor. This blink happens in a strange place, namely about 1/3 of the way down from the top of the screen, which is of course not where the real cursor ends up once the Vim window's text gets drawn atop the fullscreen background. My colorscheme is dark background/white cursor, so what blinks is a little white rectangle, cursor shaped. I don't recall this glitch being present when I built this PR on Sierra. I'll look for it when I get a chance. |
It is there on Sierra too. It happens upon exiting fullscreen mode. To reproduce (Sierra and ElCap), set the MMFullScreenFadeTime to 0.0 (I doubt this has anything to do with it, but you never know). Then The location of the blink is influenced in some way by the size of the MacVim window prior to entering fullscreen. If the MacVim window is really tall to start with (like full height of screen), the blink happens an inch or two from the top of the screen. If it's a bit shorter, the blink happens further down (two or three inches). If the MacVim window starts out around half the height of the screen, the blink occurs near the bottom of the window. If the MacVim window starts out short (e.g., 25 rows), the blink is invisible, probably because it's "happening" below the last line of the MacVim window. |
@splhack pointers on how to do a portable runtime OS check? I'm really quite new to osx coding. The other option regarding latency; it seemed at some point that painting on the layer inside |
I've been using this for a couple days and I think it's at least worth merging in its current state since it fixes a major issue. Improvements to performance and improving the transitions could come in later PRs. |
@splhack I tried to reproduce lag issues on a 10.9 box with no luck. I am upgrading it to 10.11 to see, but it seemed just as fast as the master branch. |
@chdiza I did a survey of three different full-screen-entering code paths: https://github.com/osheroff/macvim/tree/smoothout_fullscreen_enter As you can see, both the master branch and this branch have roughly the same problem with drawing intermediate results; it doesn't seem like this branch makes the situation all that much worse than it was in the master branch. The approach of "blank out the text view until we've resized" appears to show promise; I think I got the timing better than in the last patch, at it doesn't show much intermediate state. |
I'll add runtime version check for the rendering lag. |
- Native full screen: Use the last externally-set window size. This lets Split View work without slowly growing or shrinking. - Non-native full screen: Use the size of the full screen window. - Not full screen: Use [vimView desiredSize] (unchanged). This is somewhat nasty, but the different full screen code paths behave differently enough that there doesn't seem to be one universally-correct answer. It would be great to simplify them.
When you set a borderless style on a subclassed window in 10.12, the
original behavior in which you could progressively draw partially on a
stale window seems to be gone; it blanks the thing after each draw. It's
totally unclear to me whether the CoreText engine as written was ever
"correct", or maybe it just "accidentally worked" -- no documentation on
the internets seems to indicate you're allowed to only draw partial
updates to a raw window in drawRect.
This PR works around that by drawing onto a persistent background layer
which we then blit to the screen.
nn-fullscreen seems to work, as do most common operations. This PR also
makes resizing a CoreGraphics view much smoother; the old code was
pretty flickery.
I haven't dealt with DrawSignDrawType yet; not sure how to trigger that
code path.
maintainers: am I on the right track here? Any tips?
addreses #312 (though not fully, yet).