-
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
[BUG/Request] OS X OpenGL compatibility issue #3364
Comments
Can you link the workarounds these other projects added? |
I'm not sure of the exact method that developers use but here's some examples: |
This "bug" is quite strange. The sad truth is we have no idea how to work around it. I even tried to implement full screen using mission control but it doesn't seem to fix the problem for everyone (here's the commit if you feel like testing it 31a80aa) Reducing the view/window size by 1px is not really acceptable. |
if this is related to issue #2392 following patch/hack/workaround should help with the issue. this really is only for testing purpose, since it will cut 1px at the bottom and top if the video aspect ratio is smaller than display aspect ratio (example 4:3 video on 16:9 display). what could be done/tried though is nesting the view in another one and add some 'padding' to it to make the window at least 1 px bigger then the 'video view'. i didn't test if this works.
also to sum up my last few comments on issue #2392 it seems that the fullscreen issue is (nearly completely) fixed with 10.12 (beta) + native-fs but is still broken on 10.11 + native-fs. in that regard we might just give up on fixing this issue on 10.11 (lost cause) and concentrate on 10.12 when it's released. i will test everything again when 10.12 comes out. also on a side note, since native-fs is the most promising, the current branch still needs some fixes before it could be merged. |
Just did some testing on MacOS Sierra 10.12 beta 3. GPU power flowLockfocus branch + native-fs: Lockfocus branch: Native-fs branch: Master + native-fs: Master: Cause:I believe the cause is still this: https://developer.apple.com/library/mac/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_fullscreen/opengl_cgl.html "OS X automatically attempts to optimize this context’s performance. For example, when your application calls flushBuffer on the NSOpenGLContext object, the system may swap the buffers rather than copying the contents of the back buffer to the front buffer" Possible workaround/fix"These performance optimizations are not applied when your application adds the NSOpenGLPFABackingStore attribute to the context." |
i am on vacation atm so i can't test it. though if you want you can test my cocoa_pixelformat branch. it adds kCGLPFABackingStore which should be the equivalent to NSOpenGLPFABackingStore. |
Looks like it's true: https://developer.blender.org/T46993 EDIT: nope, they removed the flag, while we want to add it? |
Progress (Temporary workaround):I was able to get fullscreen GPU usage down to similar numbers to windowed by removing this attribute from context_cocoa.c of mpv-master on 10.12 Sierra beta 3: I will be doing more tests around this but so far, it appears to fix performance on both Native and MPV fullscreen.
This is the modified context_cocoa file (with kCGLPFAAccelerated also removed for testing): Tests done so far on a 720p video: Master (windowed): Master (patched + fullscreen - native and MPV): (This would be so much easier if xCode instruments worked on 10.12 and I can have actual numbers instead of measure power usage... Currently, xCode crashes with this: Crashing on exception: -[NSNib _initWithNibNamed:bundle:options:] could not load the nibName: XRStrategiesToolbarViewController in bundle (null).) Bugs&fixes:
Note: Tbh I feel like I have way to much time to spend testing this just to get fullscreen working when I have actual work I'm supposed to be doing lol. If the patch breaks anything else please let me know. I'm not certain of this but I think this should also work for OS X 10.11 EDIT:
|
I think I may have found something pertinent to this issue. When I examined an OpenGL trace of mpv master, executed with
This could potentially be causing a large performance hit, especially with interpolation, because
See https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/CGL_OpenGL/index.html#//apple_ref/c/func/CGLFlushDrawable for more detail. Using breakpoints, the call stacks for the two commands are:
and
That fact that the removal of the
|
So does removing the glFlush fix it? The glFlush was once added because it actually improved rendering performance on some Linux GL drivers, but I suppose we can drop it or disable it by default if it really makes such a difference. That said, a glFlush shouldn't normally have a bad influence on performance if it happens only once per frame. By the way, didn't someone claim that the newest Sierra betas fix this performance issue anyway? |
Yes, I've read that here as well, a while ago. Not sure where this comment is now, though. |
the comment was here #2392 (comment). i briefly tested it on Beta 5 too and some of the issues disappeared though i will only thoroughly test it again when it's out of beta. |
Doing this:
seems to help with some of the issues that seem more directly tied to some of the weird behavior that the OSD sometimes exhibits with the cocoa backend. A good example would be the stalls and user perceived lag that can occur with a resume from a paused state or with a resize of the window of some sort. Unfortunately, it doesn't seem to really do much to improve the actual performance of the opengl vo. However, that element hopefully will be much improved with macOS Sierra, as @Akemi has seen so far. Still, it would be interesting if someone with the beta installed tried something like this, just to see if it perhaps even improves things further by working more 'correctly' with Apple's os specific opengl implementation. (and therefor the Cocoa frameworks) @wm4 From the way I understand how CGLFlushDrawable works, calling a glFlush right before it would essentially be quite similar to calling glFlush itself twice on the frame. I think CGLFlushDrawable may have some mechanisms to try and mitigate that cost a bit, though. However, one cannot look at the source to see what the case really is unfortunately. That said you understand all of this much better than I do, so if you think I am mistaken or chasing a red herring, pay me no heed. EDIT: |
MPV 0.18.1 on OS X 10.11.5-10.11.6
OS X has a hard time handling OpenGL when window resolution matches display resolution. This is due to changes apple made in OS X 10.6. This results in absurdly high GPU usage when using fullscreen, although it stops if anything else is onscreen so MPV isn't taking up the whole screen. Making the window resolution 1 px smaller than display will also stop the high gpu usage (example: 1280x799 instead of 1280x800). This does not apply to all OpenGL apps, only certain ones like MPV, PPSSPP, and Spritekit apps. Because of this, Apple doesn't see this as "their problem" and instead put the responsibility on app developers to make sure this doesn't happen.
Reproduced on:
MBP 2015 late 13' OSX 10.11.6
MPV settings:
vo=opengl
Hwdec = no (same with videotoolbox)
Open a video; look at windowed gpu usage; go into full screen; look at gpu usage.
Monitored with Instruments xCode.
Expected behavior
Windowed but maximized should have similar GPU usage to fullscreen.
Actual behavior
Windowed maximized: GPU - 12%
Fullscreen: GPU - 83%
0:14 - 0:28: Fullscreen with nothing else onscreen. 0:28 - 0:51: Fullscreen with cursor at top of screen with menu bar on screen.
The text was updated successfully, but these errors were encountered: