-
Notifications
You must be signed in to change notification settings - Fork 3k
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
cocoa: layer backed view #4391
cocoa: layer backed view #4391
Conversation
I did a couple of tests, and generally it works very well (it seems to solve the flickering overlays issue, the fs animation looks really smooth and has a "native" feel) but I seem to have stumbled upon a remarkable regression playing this clip: https://a.pomf.cat/kdhdza.mp4 (For the sake of thoroughness, I can play the clip smooth in fs with this branch using the dGPU or a barebones configuration (basically cutting out opengl-hq), yet the Iris Pro should be more than able to handle this stress, as it's shown by the fact it's capable to do it with the current master). |
For testing display-sync, check the usual frame statistics like vsync-jitter and vsync-ratio. |
a performance regression isn't something i would have expect tbh. though since it replaces the backing storage with the 'layer', it could be that the layer itself is just slower since it can be animated via Core Animation. i was thinking of replacing the CALayer with a CAOpenGLLayer/NSOpenGLLayer, though the latter wants that all rendering is done in its drawInCGLContext/drawInOpenGLContext method which makes it really hard to use. theoretical it might be possible to get mpv to sync to it or to use a shared context, a frame buffer and render that frame buffer to the OpenglLayer's context. for the latter i have no clue how do it (yet). |
@AirPort i made a small test app with libmpv and a CAOpenGLLayer. so i was wondering if you can build and test it. if you built mpv with libmpv you just need to call |
Sure, as soon as I'll get back home I'll try it and report. |
Unfortunately I have to say that the test program changes nothing over the previous results. Yesterday though, I tried to collected some numerical data with the clip I linked before. So in the end it seems that, whatever performance regression is happening, mpv is actually unaware of it. Maybe there are some system tools that could help me shedding some light on what's happening behind the scenes? |
i first thought it might be related to the layer not 'syncing' properly as seen in one of the issues i mentioned. though i am pretty sure that my example app, which uses CAOpenGLLayer, properly syncs and since you still get that problem it is probably something else. which is kinda bad since now i have no idea what can be done about it. i pushed something to my cocoa_animation branch, removing the kCGLPFAAllowOfflineRenderers and kCGLPFABackingStore attributes from the context creation. i doubt they cause the performance regression but can't hurt trying without them. if you could test it again it would be appreciated. |
very weird issue. anyway my recent commit should fix it. |
Getting better, but still not perfect. It switches to a proper rendering almost instantly, but getting a quarter rendering at the beginning of a playback. Calling |
hence why i said it's weird and why i change it. |
unfortunately i can also reproduce some performance regressions. vsync jitter drastically increases from under 0.03 to 0.03-0.3 (very unstable) causing quite a lot mistimed and delayed frames. though visually it's really hard to spot so i wonder if the layer might mess with the statistics somehow. |
Unlike before, as far as I can see now with the test app and the 60 fps clip the playback is perfectly smooth both in fs and resizing the window! (Just to be sure and not lead you astray, since I have no clue about the libmpv API and I have no way to check: it does pick up the VO options from my config, right?) |
yeah i made sure it loads the config file from ~/.config/mpv. if you have stats.lua in your scripts folder you can toggle it visible via since it works for you and it also improved the performance for me drastically this seems to be the only way to go. we have to use CAOpenGLLayer somehow and also have to use a 'discouraged' way of updating that layer to make it work properly. the big problem here though is that opengl-cb/libmpv use a different different way of rendering, which is the opposite of how mpv internally works. so it's sadly non-trivial to use a CAOpenGLLayer and might not work at all. |
going to close this, since i too see some bad performance regressions and we need a completely different approach with a CAOpenGLLayer. |
this is a WIP so there is still some debugging shit in the commits and the commit messages don't conform to the standard yet.
i am doing it this way since it potentially fixes 7 issues and i kinda want a central place where issues can be reported and fix confirmations can be posted. the issues in question that most likely will be fixed are:
#2217
#2392
#2873
#3739 - confirmed fixed
#3746 - confirmed fixed
#3944
#3978 - confirmed fixed (most likely)
known issues of this WIP branch:
since there is a dislike for animations and the native fullscreen (#4014) i will also add a none native fs after everything has been worked out.