-
Notifications
You must be signed in to change notification settings - Fork 511
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
Significant performance regression in macOS 10.14 #354
Comments
Unfortunately it is not possible for me to do any fixes to SolveSpace under macOS 10.14 because I do not own any Apple hardware and so I use a VM (OSXKVM) to do all development work and there's currently no way to run anything newer than 10.12 in a VM. Worse still, anything newer than 10.9 is absurdly slow when using software rendering, and I do not have GPU passthrough working yet. |
That said, if you could use Xcode to profile SolveSpace, I might be able to fix it without even having access to a macOS 10.14 machine. |
I'm new to profiling but happy to help. I'm currently trying to follow the build instructions using the "generate an XCode project" path in order to generate a binary that I can profile at the function call level. I had to start again from "scratch" as CMake error-ed out. Looks like the error is continuing:
This is after a |
What is your cmake version? |
cmake version 3.12.2 installed as follows:
FWIW it looks like Mohave can be run underneath OSXKVM (but I haven't tried it myself). |
The CI uses 3.11.4, any chance you could try that? |
Homebrew was being ... difficult ... but also just released cmake 3.12.3 and it seems to have worked. Now I need to figure out how to make a debug build and run it under Instruments. However. Having just made a screencast (see attached) it looks like what's happening is that macOS isn't allowing screen updates until the mouse stops moving. Which has the feel (so someone like me who isn't an OpenGL person) of being one of those "one line fixes" once the cause has been identified. |
Oh! I've seen that before. I know approximately what the cause is. I'll need to think a bit about the best way to fix it. |
OK, this is the similar SDL bug: https://bugzilla.libsdl.org/show_bug.cgi?id=4272 |
Anyone got a workaround for this? |
Hi, I’m on macOS 10.14 too and actually the program doesn’t startup! I downloaded the .dmg file from GitHub. |
Currently, you need to build from source.
Not exactly. Apple has never been developer-friendly, but their latest changes are outright hostile for open-source software. Unless someone donates me hardware that can run 10.14, there will be no further updates and no support. |
Hi, thanks for the fast reply. May someone help you? I’m new to development, but I would like to help somehow. If you know what to do I can try to do it. |
You could try to "port" it to Metal using one of the OpenGL-to-Metal translation layers out there. |
Looking into it, this doesn't seem like an OpenGL issue (although there are separate OpenGL performance issues I'll get to later). For the specific problem in the video of drawing a line segment to the mouse location, the graphic of the line is for some reason tracking behind the actual mouse position. Printing out within
i.e. the mouse motion is getting picked up but it's not getting through to the rendering code (and I don't know how many steps before that). In terms of the OpenGL rendering, CPU usage is way higher than it needs to be because rendering is done into an offscreen buffer, meaning the result has to be copied from the GPU to the CPU, undergo colour-space and format conversion, be copied into a texture buffer, and then rendered again. It's a pretty simple change to render directly to the screen instead (which I think is what happens on other platforms), but some flickering occurs that I haven't figured out yet. |
Yes. I've spent a very large amount of time trying to do it without an off-screen buffer but it never worked. IIRC the main issue preventing direct rendering was the editor overlay, so please make sure that still works. |
In general this happens as a result of high CPU load. Take a look at how the |
The flickering appears to be whenever the draw calls change (including when hovering over the editor overlay). My guess would be that it's due to all the
Is there another variable that might be controlling the updates for line segment drawing? |
I haven't tried that. Before you've mentioned it I wasn't even aware that it could be a problem. Maybe the buffers could be created once, persisted inside the various
I took another look and I think what might be happening is that in |
It's definitely not recommended to be recreating buffers every frame, and although the driver should be able to handle it in the case of transient buffers (as most Windows drivers seem to) I wouldn't be surprised if that's a problem on macOS. How much it's worth addressing given OpenGL support on macOS has maybe a couple more years to live I'm not sure; however, a Metal implementation would have the same design issue. I made a start on the change in https://github.com/troughton/solvespace/tree/gl-no-buffer-genning, although I doubt I'll have more time to work on it. The core issue is that the buffer storage needs to be preallocated each frame (and the driver will reuse a previous buffer if it's large enough); you could either just set a maximum size, or you somehow need to know the total vertex/index counts in advance. That branch doesn't properly work because
I'll note that hard-coding |
Thanks. I would probably not finish this on my own any time soon either but it still might be useful in the future. |
@whitequark @troughton It's worth noting that the mouse movements are getting through to some parts of the UI: the circle tool doesn't have any lag at all. It's not the fault of the batched drawing support, either: the red outline around the line when I use the line tool is also lagging (tested by disabling OpenGl3RendererBatch::Draw). See https://drive.google.com/file/d/1LHFkRHH1MsSDFu3th4zZMXDgInU4ENI5/view?usp=sharing : The circle tool doesn't have lag, and the purple dot at the bottom-right corner of the square seems to update as the mouse moves even though the rest of the square doesn't. (MacBook Pro (Retina, 13-inch, Early 2015), macOS Mojave 10.14.4, latest master branch) Edit: I think @troughton's idea about the solver being overwhelmed might be correct. I made Solvespace ignore 3/4 of the mouse events received, and the line drawing seems to be smoother. |
Just to add another data point - the slowdown is only while initially creating a line or rectangle contour for me. After they are created, moving any control point is smooth and fast. |
Just want to add, that the performance regression only occurs on macOS Mojave when using Retina Display, if I use external monitor (FHD) it is fine - smooth as butter. However, I'm not sure about using external 4K display. |
Guys, try adding this to
Not tested it a lot but seems to speed things up a lot! |
Fixed in 9b61f98. |
Here is a macOS build from the latest master 54015b6 |
Performance on ...
... with both a fresh install of SolveSpace version 2.3 and a fresh build from GitHub has regressed to the point of not being usable. Creating a line and moving the second point results in a redraw time of roughly 1 sec.
Apple has announced that OpenGL is being deprecated starting with 10.14, but I haven't seen any references online to performance issues. In the short term I'm wondering about the possibility of a quick performance fix. In the longer term is SolveSpace still going to be feasible on macOS?
The text was updated successfully, but these errors were encountered: