EinEinfach / CaSSAndRA

Cascaded sunray server and rover application
MIT License
29 stars 17 forks source link

Plotly map smoothness #59

Closed ShadedSelf closed 1 year ago

ShadedSelf commented 1 year ago

The maps are quite jarring for me, if I pan somewhere sometimes it resets back to the previous position, if a zoom in, it then zooms out. This seems to happen at every interval, so every 3 seconds it resets the where it was before. If I hold my finger down during the interval refresh then it stays where it should.

I tried removing the y_range but doesnt change much.

Any ideas? seems like this should be handled by "uirevision=True" but doesnt seem to work as expected, it would be nice to have a smooth map.

disaster123 commented 1 year ago

Same to me. I think it's related to the update from server. So if you're doing something the update / polling or something from the server interfere with the user action. But just a guess.

EinEinfach commented 1 year ago

Yes uirevision doesn't work as expected. The first interval update after reloading page always reset zoom and user interactions,. After that it seems to be ok. I did some research and tried many things out but the result isn't satisfied. Maybe someone has other ideas how to fix that

EinEinfach commented 1 year ago

I can disable interval update in idle, docked, error, charging state. It will remove jumping in most of time

ShadedSelf commented 1 year ago

Im also looking at this, not sure if it would help though.

EinEinfach commented 1 year ago

If I remove y_range and add uirevision=True in fig.update_layout at the end of /src/components/state/map.py fig.update_layout( yaxis = dict(showticklabels=False), xaxis = dict(showticklabels=False), images=imgs, annotations=mowdata, uirevision=True, ) then it seems to work, even with fast interval (1s)

Can someone else confirm that

rothnic commented 1 year ago

Glad this was brought up. I noticed the same issue and I also seemed to have trouble on the other pages (mapping, tasks). So, probably want to evaluate the same changes on those pages, as well.

Often, I'd be zooming in to edit points and it would go back to the previous zoom level about a second after zooming in.

rothnic commented 1 year ago

Im also looking at this, not sure if it would help though.

That actually looks promising as something worth looking into once we get to optimizing the app further, even if it isn't required for the plot updates. Probably need to do some performance recordings to see just all what is updating to validate that it actually is needed.

ShadedSelf commented 1 year ago

Interesting, seems a bit better in terms of jumps. Still not the smoothest experience, I get the spinner constantly now,

I still get some jumps, specially on the mapping page and if I turn the interval back to 3 secs seems the same as before for me.

EinEinfach commented 1 year ago

Is the wait spinner more often on state page? How many temporary obstacles are in Plot at the moment? You can remove obstacles by pressing cancel button

ShadedSelf commented 1 year ago

Yeah, that was with an empty map.

Maybe is because Im running Cassandra on a Pi 2 and it takes a while to update, if the interval is not long enough callbacks get queued on top of each other.

Basically it seems that any changes to the map that happens when the callback is being called (when the title changes to "updating...") get discarded.

EinEinfach commented 1 year ago

Actually now you should get less spinner time, because I deactivate interval trigger for map when rover is charging, docked or in error state (hm... maybe I shouldn't deactivate interval trigger in error state, because the robot can be still manually driven even in error state...)

ShadedSelf commented 1 year ago

OK, its fixed for me now, we dont need "uirevision, updating with Patch() seems to leave the current pan and zoom intact and its way faster than making a new "go.Figure()", Ill test a bit more and make a PR later if everything is fine.