-
Notifications
You must be signed in to change notification settings - Fork 62
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
refactor: optimize waypoint drawing #2561
Conversation
Bobbles are the end/mid points of the lines. They do show up on main and should be left in. I also only see the jump up when dragging a token. This is due to it keeping it outside the token while dragging then moving it to the center spot on release. This is on purpose as we want the text off the token as we drag it and the text close to the vertex when we drag the token again. With this PR you currently get a very large gap when dragging a gargantuan creature. For example this PR: vs main: Mostly the performance issue for the ruler is when dragging tokens with the console open - not the ruler function itself. Since people don't play with the console open I've ignored it. I agree it'd be nice if it was better but I think this has to do with the token dragging function more then the ruler function. This is originally why it had to be specifically enabled when dragging tokens - although there's been improvements since then that mostly eliminated that issue and contained it to having the console open. Happy to have some of these other changes if they improve performance while maintaining the other functionality above. As a note in testing this PR I have noticed sometimes a multi segmented ruler (ruler tool + right click) fails to keep it's first segment positioned correctly but I don't think it's related to this PR. |
Thanks, I'm gonna revert the bubbles and labelX/labelY changes. I drag and measure with tokens much more than with standalone ruler, so both performance and the jump seem to bug me more than you) |
Fair - I also have token drag measurement on all the time I just don't see performance issues on my end except with the dev tools open. Mind you I do play with a bunch of people who have higher end gaming PCs so it's pretty easy for us to miss those things. As far as I can tell the dev tools don't like removing/adding the ruler dom elements repeatedly while dragging a token (the svg stuff since they don't update when just changing the values - and canvas is a non-option due to scaling blurring the text and was also less performant when we did use canvas).
Edit: Alternatively have it only jump up when the token is picked up again - so midpoints still have their label close by. Otherwise it stays below the token as it fades. I might like this option most tbh. I can also take a look at doing this depending on if you want to pick it up. |
Figured out why they did not show up on firefox. Firefox thinks that Well, I just tried fixing it and it half-worked, the lines would be drawn correctly only if I go into devtools and uncheck/recheck the rules. That's hella weird. I'm just not gonna touch that, firefox will have to cry in a corner. F |
I hadn't noticed that in firefox - I merged a PR into main that should fix that. There was a couple other places where the units were missing in the css like you mentioned. It definitely should always have units on one side of the calculation - was just missed in this case. I applied the same changes manually to this PR and it seems to be fine. I'll do some more testing and merge in a bit if you think it's ready to merge. Looks like this in firefox for me now (no dev tool editing). |
Merged main in, checked it out in firefox, bobbles show up now. lgtm) |
I've realized it would take ages merging these one by one. You can review each commit one by one, each is self contained.
First I did not like the performance of the drawWaypointSegment function and did the first thing that came to mind - avoid jquery selector duplications.
Whist testing that, I realized that
ruler-svg-bobbles
never actually show up on the screen, so they could just be removed.After doing that, I noticed that
drawWaypointSegment
is called in a loop and moved everything up, and replaced it with nativegetElementById
which was much faster than jquery operations.While doing that, I noticed that
midlineLabels
was always false, so I removed it.Finally, I felt like I knew enough about how this works to fix another thing that has been bugging me: the label would jump up as soon as I release LMB because fadeaway redrawing did not remember the
labelX
andlabelY
args.You can look at flamegraph for
draw
before my changes in #2560.After all changes it looks like this: