-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
With --no-native-titlebar, requestAnimationFrame runs at 500 FPS #9431
Comments
/System/Library/Frameworks/AppKit.framework/Versions/C/Headers/NSWindow.h about
|
Doc says:
I think this is why it's not working. But I don't know enough about Cocoa to understand what needs to be done here. Not sure if that helps in anyway, but calling @glennw - any idea? |
Cocoa or Core Animation might be setting the swap interval to zero when layers are being used. (When If this is the case, I don't know to get it to stop doing that. We could try to reset the swap interval back to 1 ourselves, but that might cause Core Animation to break somehow, or CA might try to reset it back to 0. Failing that, it might be best to use some other method to disable the title bar that doesn't get Core Animation involved. |
The problem here seems to be that, when a window is layer-backed, OpenGL contexts created for the window's content view are offscreen contexts displayed by drawing to an off-screen buffer and swapping that buffer onto the screen via Core Animation. This is a problem because, since the contexts are offscreen, There are two realistic options here that I can see: (1) keep the current state of affairs and use a @paulrouget, what do you think? How do you feel about implementing the traffic light buttons in browser.html? |
We can do that (we actually already have such HTML buttons). What should be done in Glutin to have a titlebar-less window with an on-screen context? Do you think we should use your |
|
I tried that in the past. But without |
Here's how we do this in Firefox: We don't mess with the window mask at all - we don't add As you already found out, this causes the window buttons to disappear. Moreover, our OpenGL drawing is not clipped to the rounded window corners. We fix both of those things up in a DrawWindowOverlay function that gets called by the compositor on every composite. There is a "titlebar" texture that contains the window buttons (and the titlebar highlight line, and in some cases even the window title text), and there's a "corner mask" texture that we use to mask out the four corners (using operator destination-in). This is a fair bit of complexity. I'd try to avoid it if possible. Using a layer-backed view and having two compositors doesn't sound all that bad, as long as the performance is still good. (Is it?) There shouldn't be tearing because I'm pretty sure CoreAnimation has the swap interval enabled on its OpenGL context. So if you use |
It seems like a real shame to double our GPU ROP count just for this, though, and missing frames seems bad. (I was actually just in meetings with web developers who were complaining that they can't get good animation performance due to, ultimately, |
After doing some research, I think the corners may actually be something we have to do in WebRender. The reason is that the way Mac OS X draws corners is one of: (1) Use Quartz clipping regions to clip out the corner areas when doing 2D vector drawing of our window; or (2) Use Core Animation corners on a layer. I assume the way this works is that WebRender ultimately draws to a texture, then this texture gets either alpha masked or stenciled to draw the corners in Core Animation. (2) is easier for us, but it's not the most efficient way to draw corners, and it'll cause us to have to fall back to Shadows should be easy to get back; Apple has some sample code for this: https://developer.apple.com/library/mac/samplecode/RoundTransparentWindow/Introduction/Intro.html |
Related: #7659 |
because that disables the swap interval. This hack is very simple but a little evil. We get the superview of the content view, which is the `NSThemeFrame`, and install an OpenGL context into it. `NSThemeFrame` is a private class, but we only call public `NSView` APIs on it here, so this seems OK in terms of being supported by Apple going forward. The reason for using this hack as opposed to `NSFullSizeContentViewWindowMask` is that the latter forces the window to be Core Animation-backed, which results in us rendering to an off screen surface. Not only does this inject another compositor into the system, but it also results in us rendering to an off-screen surface, disabling the swap interval. This depends on a `cocoa-rs` upgrade to add a binding to the `-[NSView superview]` method. Known issues: * The traffic light buttons are not drawn but still function if you click on them. This can be worked around in browser.html. * The top border is not rounded, although the shadow properly displays. This should be able to be worked around in browser.html. * The title bar reappears if you go to full screen and then go back. This is the most serious issue, but I suspect it'll be fixable and it's better than what we have right now. This should fix servo/servo#9431.
because that disables the swap interval. This hack is very simple but a little evil. We get the superview of the content view, which is the `NSThemeFrame`, and install an OpenGL context into it. `NSThemeFrame` is a private class, but we never speak its name, we get to it with public APIs, and we only call public `NSView` APIs on it, so this seems OK in terms of being supported by Apple going forward. Additionally, we remove the standard window buttons so that they disappear and the user can't click them. This can also be done using public APIs. The reason for using this hack as opposed to `NSFullSizeContentViewWindowMask` is that the latter forces the window to be Core Animation-backed, which results in us rendering to an off screen surface. Not only does this inject another compositor into the system, but it also results in us rendering to an off-screen surface, disabling the swap interval. This depends on a `cocoa-rs` upgrade to add a binding to the `-[NSView superview]` method. Note that the top edge of the window is not rounded, although the shadow is. Applications that wish to use this mode will need to round the top edge themselves if they wish. (This is how Cocoa internally works: rounding is done by the app, not the window manager.) This should fix servo/servo#9431.
I've got a proposed fix for this in servo/glutin#68. It uses only public APIs and is only ~30 lines of code. |
Stop using `NSFullSizeContentViewWindowMask` to get borderless windows, because that disables the swap interval. This hack is very simple but a little evil. We get the superview of the content view, which is the `NSThemeFrame`, and install an OpenGL context into it. `NSThemeFrame` is a private class, but we only call public `NSView` APIs on it here, so this seems OK in terms of being supported by Apple going forward. The reason for using this hack as opposed to `NSFullSizeContentViewWindowMask` is that the latter forces the window to be Core Animation-backed, which results in us rendering to an off screen surface. Not only does this inject another compositor into the system, but it also results in us rendering to an off-screen surface, disabling the swap interval. This depends on a `cocoa-rs` upgrade to add a binding to the `-[NSView superview]` method. Known issues: * The traffic light buttons are not drawn but still function if you click on them. This can be worked around in browser.html. * The top border is not rounded, although the shadow properly displays. This should be able to be worked around in browser.html. * The title bar reappears if you go to full screen and then go back. This is the most serious issue, but I suspect it'll be fixable and it's better than what we have right now. This should fix servo/servo#9431. r? @jdm <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/glutin/68) <!-- Reviewable:end -->
because that disables the swap interval. This hack is very simple but a little evil. We get the superview of the content view, which is the `NSThemeFrame`, and install an OpenGL context into it. `NSThemeFrame` is a private class, but we never speak its name, we get to it with public APIs, and we only call public `NSView` APIs on it, so this seems OK in terms of being supported by Apple going forward. Additionally, we remove the standard window buttons so that they disappear and the user can't click them. This can also be done using public APIs. The reason for using this hack as opposed to `NSFullSizeContentViewWindowMask` is that the latter forces the window to be Core Animation-backed, which results in us rendering to an off screen surface. Not only does this inject another compositor into the system, but it also results in us rendering to an off-screen surface, disabling the swap interval. This depends on a `cocoa-rs` upgrade to add a binding to the `-[NSView superview]` method. Note that the top edge of the window is not rounded, although the shadow is. Applications that wish to use this mode will need to round the top edge themselves if they wish. (This is how Cocoa internally works: rounding is done by the app, not the window manager.) This should fix servo/servo#9431.
because that disables the swap interval. This hack is very simple but a little evil. We get the superview of the content view, which is the `NSThemeFrame`, and install an OpenGL context into it. `NSThemeFrame` is a private class, but we never speak its name, we get to it with public APIs, and we only call public `NSView` APIs on it, so this seems OK in terms of being supported by Apple going forward. Additionally, we remove the standard window buttons so that they disappear and the user can't click them. This can also be done using public APIs. The reason for using this hack as opposed to `NSFullSizeContentViewWindowMask` is that the latter forces the window to be Core Animation-backed, which results in us rendering to an off screen surface. Not only does this inject another compositor into the system, but it also results in us rendering to an off-screen surface, disabling the swap interval. This depends on a `cocoa-rs` upgrade to add a binding to the `-[NSView superview]` method. Note that the top edge of the window is not rounded, although the shadow is. Applications that wish to use this mode will need to round the top edge themselves if they wish. (This is how Cocoa internally works: rounding is done by the app, not the window manager.) This should fix servo/servo#9431.
because that disables the swap interval. This hack is very simple but a little evil. We get the superview of the content view, which is the `NSThemeFrame`, and install an OpenGL context into it. `NSThemeFrame` is a private class, but we never speak its name, we get to it with public APIs, and we only call public `NSView` APIs on it, so this seems OK in terms of being supported by Apple going forward. Additionally, we remove the standard window buttons so that they disappear and the user can't click them. This can also be done using public APIs. The reason for using this hack as opposed to `NSFullSizeContentViewWindowMask` is that the latter forces the window to be Core Animation-backed, which results in us rendering to an off screen surface. Not only does this inject another compositor into the system, but it also results in us rendering to an off-screen surface, disabling the swap interval. This depends on a `cocoa-rs` upgrade to add a binding to the `-[NSView superview]` method. Note that the top edge of the window is not rounded, although the shadow is. Applications that wish to use this mode will need to round the top edge themselves if they wish. (This is how Cocoa internally works: rounding is done by the app, not the window manager.) This should fix servo/servo#9431.
Probably a glutin/cocoa issue.
I'll investigate.
The text was updated successfully, but these errors were encountered: