jupyter-widgets / ipyleaflet

A Jupyter - Leaflet.js bridge
https://ipyleaflet.readthedocs.io
MIT License
1.47k stars 359 forks source link

bug: GeoData.on_hover() freezes when updates are too frequent #1172

Open NickCrews opened 5 months ago

NickCrews commented 5 months ago

repro:

  1. run https://github.com/jupyter-widgets/ipyleaflet/blob/55d108be4905b76eb3247da2759f1ea7d29a871a/examples/GeoJson_EU_on_hover.ipynb
  2. drag my mouse very quickly around the map, causing the hover HTML to update very quickly. Zooming out helps force the updates to happen quicker.

If I do this for ~5 seconds, the hover display HTML freezes, and will show the stats on a random country. Panning or zooming the map does not fix this.

I'd imagine this is a performance thing, so if you have a more/less powerful box, it might be hard to reproduce. I confirmed it has to do with the frequency of updates: If I slowly move the mouse over the map, I can get several hundred updates (I monkeypatched in a little counter to show the number of updates) with no freezing. However, once I start moving the mouse quickly, I can get a freeze to happen after ~60 updates.

On this example notebook, I have to move the mouse very quickly. If that aggrsesive behavior was needed to trigger the bug, then I might say ignore it. But on the real dataset I'm using, which is larger, I don't have to move the mouse that fast to trigger this bug, and it is very likely an average user would encounter it.

I'm running this is VS Code. I looked in developer console, but found no error logs. Also looked in Output > Jupyter and nothing there either. If you point me where else to look, I can help look for logs.

Apple M1 Max 64Gb MacOS 14.1.1 VS Code 1.85.1 from 2023-12-13