Skip to content
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

With maps, sometimes there are too many mouse move events #86

Closed
wch opened this issue Mar 29, 2023 · 0 comments · Fixed by #98
Closed

With maps, sometimes there are too many mouse move events #86

wch opened this issue Mar 29, 2023 · 0 comments · Fixed by #98

Comments

@wch
Copy link
Collaborator

wch commented Mar 29, 2023

On the Shiny for Python web site, if you run this in one of the live example boxes, there are too many mouse events, and it can get very laggy -- sometimes taking over ten seconds to respond to subsequent input.

On my Mac, I see this behavior:

from shiny import App, ui, reactive
from shinywidgets import register_widget, output_widget
import ipyleaflet as ipyl

app_ui = ui.page_fluid(
    ui.input_select("center", label="Center", choices=["London", "Paris", "New York"]),
    output_widget("map"),
)

def server(input, output, session):
    map = ipyl.Map(zoom=4)
    register_widget("map", map)

    @reactive.Effect()
    def _():
        center = input.center()
        if center == "London":
            map.center = (51.5074, 0.1278)
        elif center == "Paris":
            map.center = (48.8566, 2.3522)
        elif center == "New York":
            map.center = (40.7128, -74.0060)

    count = 0
    @reactive.Effect()
    def _():
        nonlocal count
        count += 1
        print(str(count) + ":  " + input.shinywidgets_comm_send())

app = App(app_ui, server)

In this video, just moving the mouse in and out of the map area results in 115 mouse events -- the counter in the console goes from 357 to 471. When I do more mouse motion, it can get backed up with hundreds or even thousands of mouse events, and it takes a long time for it to finish processing these events.

mousemove720.mov

This doesn't happen, or at least doesn't happen nearly as much, with the touchpad. It also doesn't happen on the shinylive.io site, for some reason.

I believe it could be addressed by throttling this: https://github.com/rstudio/py-shinywidgets/blob/2b9bd2d8531e797691f95b3481751120a572fe0c/js/src/comm.ts#L35

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant