-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
3D plot redraw() inside a listener cause a recursive loop #1025
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
Comments
Again here, providing a fully-reproducible example would help us help you. |
Sorry again, here you go the example. Clicking on a point, the browser page basically crash because of a recursive loop. |
Thanks for the report. |
This bug is reproducible since version 1.10.0. |
Ok, how I see problem. in 1.6.0 version was presented fix for issue #240. It added click events for 3D scattergl. But it was done in strange way: clicks are firing on each redrawing while mouse button is down. For example, in same case 2D event is fired once mouse is up. But this is only part of issue. Somewhere between 1.9.0 and 1.10.0 some change was done that makes things go recursively: now, if mouse was down and in it's callback was redrawing event fires and fires again even after mouse was released, so May be it was force redrawing, may be - some other change. I hope, that info will help somebody to fix that problem, I still can't get root of problem, what need to change. And while we are using both 2d and 3d scenes it's hard to make easy way to overcome that problem. |
Thanks for your investigation work @kelegorm 🔬 |
May I ask if anyone found a workaround for the problem? Thanks! |
I got around this using a setTimeout of 100ms in the click handler |
Thank you! |
Hi,
|
Additional report from @Luthaf in #4513 See https://codepen.io/luthaf/pen/mdyvGLR for a reproduction. Clicking on one of the points fire the event in a loop and the script ends up killed by the browser (too much recursion on firefox). I find it strange that calling Plotly.restyle would send a plotly_click event, hence this issue! |
I've found an awful workaround for this issue: place the call to Plotly.redraw/Plotly.restyle in a timeout with a small delay: setTimeout(() => Plotly.restyle( ... ), 200) Sometimes I still get multiple calls, but it stops the infinite event loop. I'll take a shower, I feel dirty... |
Still experiencing it with 2.1.0 |
Another workaround is to just use newPlot instead of redraw, but this obviously redraws the whole plot and requires rebinding the click event |
This still is still a problem in 2024. Here's my workaround: Use a boolean handlersActive to determine, if the click and selection handlers should do anything. Below is an example. Although incomplete excerpts copied from my code, you'll get the idea. These are my handlers in my vue-plotly wrapper:
And here's the update function:
Hope that helps |
I have the following code to be executed:
It just adds a 3D point (x,y,z) to a trace and then it redraws the plot.
If I do like this, as far as I seen, the redraw method somewhere trigger again the plotly_click event and this cause a recursive loop.
I used an ugly workaround to fix this, which is the following:
But it's not hte best way. Am I do correctly redrawing the graph in a listener? Is there any other way (maybe the right one) to redraw a graph after a point selection? Is this allowed?
Thank you
The text was updated successfully, but these errors were encountered: