Skip View::update() on drag/release when mouse mode is mmUSER - #507
Skip View::update() on drag/release when mouse mode is mmUSER#507aidanmorales wants to merge 1 commit into
Conversation
|
Thanks for the PR. It's going to take me a few days to get time to look at this; I'll give some comments then. |
|
I'm reluctant to accept your PR, because someone might have a mouse handler that depends on the automatic redraw. (Though I can't think of an example, except maybe for someone who follows the advice below.) I'm not seeing much lag, but maybe my hardware is just faster. So if lag is a problem for you, then wouldn't it be best to suppress the drawing that happens in your handler, instead of suppressing the auto draw? Here's a rewrite of your handler that does that. |
|
BTW, a more general patch that skipped the redraw if the scene was known to be unchanged would be more acceptable. Then the auto redraw just wouldn't happen. But that would be harder to write, because we'd need to set some sort of flag on every change. |
|
Thanks for looking into this! I tried your |
|
This is mysterious. I added Without your patch, I see With your patch, it is still called twice within the call, but not between calls. That makes sense, the auto update is gone. With just my patch to the R function, it is being called 3 times, but the two inner ones don't actually ask for the window to be painted. So it seems like the difference in observed behaviour with your patch is too big. It removes one paint call, whereas mine removes 2. Something else is going on, but I don't know what. By the way, what platform are you using? I'm on MacOS Sequoia 15.7.7. |
|
@dmurdoch: I am running Windows 11 25H2 build 26200 on all of my test systems. I do remember specifically that my old workstation, which had a i7-8700k and an Nvidia Quadro P2000 did not have this issue on Windows 10. When I was forced to upgrade it to Windows 11 around October of last year for security reasons, the stutter appeared. All of my new devices that shipped with the latest build of Windows 11 also have the stutter issue. |
|
I've thought of a possible explanation for the strange timing. rgl normally uses double buffering for updates. It displays the "front" buffer, and future writes go to the "back" buffer. When those writes are done, it swaps buffers. This is done because on slow hardware writing to the buffer that is being displayed causes weird artifacts. On modern hardware, I wouldn't be surprised if the writes can be completed entirely before the next screen update, so your code (with an even number of writes) will never actually change the buffer being displayed. Both versions of my code have an odd number of writes, so the system will actually have to switch what is being displayed after each update. Perhaps these swaps cause some resource to be thrown away, and a garbage collection is eventually necessary. I will have to think about ways to test this. |
Hi!
I'm the maintainer of the rTwig package and use rgl extensively to visualize point clouds and 3d models of trees!
Recently, I noticed that both your and my custom implementation of
pan3d, which you can find here, have become very laggy and slow. I don't know why this changed, but I think the current reason is rgl's mouse handlers always force a redraw after every drag, even when a custom mmUSER callback (likepan_plot()) already redraws on its own. This creates multiple redraws instead of one. The reprex below should demonstrate the problem before and after the fix.