perf: A bunch of render path improvements - #19
Conversation
|
Thanks for the PR - I went through it and the changes look good to me. The render-path optimizations are nicely scoped and I don’t see anything blocking the merge. I’m going to merge this one first since #16 also touches |
|
In my personal version I draw "deadzones" where low arc shots can't reach and height contour lines and more and in that version I've added even more improvements + offloaded some things to webworkers to speed it up even more, so it's at the point where I can maintain 120fps on my macbook. I'll see if I can port some of those over aswell once more of my PRs are merged |
|
If you want to compare: Open https://wardogs-map.olm.pet, toggle on all layers and then in the devtools run |
Render path improvements
draw()is now arequestAnimationFramescheduler and the old synchronous body isdrawNow(), so all ~46 call sites coalesce without being edited.resize()stays synchronous to avoid a blank frame on everyResizeObservertick.renderer.js,grid.jsandoverlays.jsreadgetComputedStyle(document.documentElement)on every paint; nowcssVar()memoises them, invalidated fromapplyTheme().createImageBitmap()for same-origin tiles,new Image()plusimg.decode()for cross-origin ones —fetchis subject to CORS where an<img>load is not.TILE_CACHEbecomes a 256-entry LRU thatclose()s evicted bitmaps instead of growing unbounded.devicePixelRatioat 2 via a sharedrenderScale(), also used by the contour raster so it cannot disagree with the canvas.