GNimrodG / simrail-map-optimized

A feature rich and optimized online map for Simrail.
https://smo.data-unknown.com
GNU Affero General Public License v3.0
3 stars 1 forks source link

Performance Issue When Following A Train #25

Open EMREOYUN opened 3 months ago

EMREOYUN commented 3 months ago

When you follow a train, follow action uses too much CPU, affecting other apps, including SimRail.

image

EMREOYUN commented 3 months ago

Note: This issue happens with hardware acceleration

GNimrodG commented 3 months ago

I've heard of this issue before, but it's the same usage as on map.simrail.app. image It shouldn't impact your game, usually on my system SMO starts lagging before the game.

I've looked into this and simply moving the map is the most performance hungry thing that happens. (CPU usage sits around 20 for me when not moving the map) I tried using different moving function like setView instead of panTo but that didn't help. I'm open for suggestions if you have any.

EMREOYUN commented 3 months ago

There is also some odd behavior I noticed. When the train is moving, if you move the map, the train movement animation is delayed. With the following function enabled movement animation makes the train go outside of its track and go back after the following animation is done.

GNimrodG commented 3 months ago

That's probably because leaflet-drift-marker uses the container's coords instead of the lat-lon coordinates so if you move the map while it moves it doesn't line up anymore. The solution for that is to use the react-leaflet-drift-marker's built in keepAtCenter prop which moves the map with the marker, the only problem with that is that it's not as smooth as when using the map.panTo function.