-
-
Notifications
You must be signed in to change notification settings - Fork 313
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
Mouse responsivness drops with large plotting loads #2779
Comments
I guess it's because of this: Makie.jl/GLMakie/src/events.jl Line 226 in 641023c
Could the delay not be constant? this means the render time is paid twice for mouse events - first in the handler receiving the event and then in viewing the update it causes. |
I don't notice delay on mouseclicks, though it seems that mouseposition updates can consumed by something so the normal axis drags don't work. On render_tick - you can check how often these happen with something like map(_ -> println("tick"), c.fig.scene.current_screens[1].render_tick) Since #2336 / #2397 rendering only happens when necessary (if you use the default renderloop) so without visual changes you shouldn't be slowed down by rendering. And if you were having render_tick on some async timer wouldn't really help you. It would just move the update to the sleep/yield part of the renderloop. Maybe you would get something out of using callbacks, but I'm not sure if GLFW keeps events in strict order for those. I also don't really see the point in having more updates then rendering opportunities. That'd just be extra work that never gets displayed, wouldn't it? |
Maybe, but there just is a delay on mouseclicks events because the update rate is tied to rendering. Noticing it will depend on your hardware. Dragging is more generally noticeable because you can see the gap with the cursor. What is unnecessary is to pay the rendering delay twice on mouseclicks. The CPU is so underutilised in this example that giving it more work is not a problem at all. A 0.1 second delay in mouse click response is a real UX problem compared to 0.05 seconds. |
Even if we polled every half frame you'd see the same gap since the polling happens immediately before rendering right now. This would be more an issue of event processing or rendering being too slow, or maybe vsync.
I don't see why we would be paying twice. render_tick is triggered once a frame, triggering the updater to get the current mouse position (which as far as I know is actually current, not from the last frame or the last GLFW.PollEvents) which then causes all the observable updates to happen. After that you get the same for all the callbacks via GLFW.PollEvents and then the frame is rendered.
Yea that's not nice. Maybe it would be useful to do some timings in Makie.jl/GLMakie/src/screen.jl Lines 860 to 881 in 4bebd86
to figure out where you're actually spending time? |
Ok I guess I don't understand the GPU/CPU interaction here and how the updating happens, except that there is very little CPU activity. I'll try your script when I get time. It may be better to just work on other optimisations so this is less likely to happen E.g. subsampling the heatmap removes this problem #973 |
I'll use a MakieDraw.jl
GeometryCanvas
as an easy example:The MakieDraw.jl code is and event handler like this:
https://github.com/rafaqz/MakieDraw.jl/blob/8cb95a4fa018f3159f66e3af2233bdc9de2d6016/src/geometry_canvas.jl#L266
Also notice MakieDraw is printing to the REPL (to debug this) when the click even is triggered. But once there is the heatmap plotted there is a big delay before the
on
handler actually receives the click - so the delay is not from plotting the clicked points, but lag in mouse input events arriving to the handler.Also interesting is that WGLMakie.jl is faster than GLMakie.jl. It's still slower once there is a heatmap, but the event is registered in maybe half the time.
There is also basically zero CPU use happening, so I'm assuming it's related to rendering.
The text was updated successfully, but these errors were encountered: