News for hackers. Stuff that matters.
Re:Google Docs will now use canvas based rendering by worldsayshi on Wednesday May 12, 2021 @11:43AM (#27131614)
Switching to canvas sounds like a very roundabout way to handle an issue related to the dom growing out of hand. Surely unmounting pages that you you're not currently looking at should work?

Of course there could be many reasons but we're left to speculate...

Re:Google Docs will now use canvas based rendering by cellularmitosis on Wednesday May 12, 2021 @01:09PM (#27132624)
You can ditch the off-screen rendered pages but you are still stuck with the entire 1000-page data structure. Should your current line be on page 997 or 998? You have to calculate the size of every line of every page to answer that.
Re:Google Docs will now use canvas based rendering by hctaw on Wednesday May 12, 2021 @01:30PM (#27132894)
Efficient 3 dimensional position or range queries (line/column/page) is a pretty well studied problem. You don't need to query every point of the space to answer anything.
Re:Google Docs will now use canvas based rendering by jasim on Wednesday May 12, 2021 @01:59PM (#27133255)
I could not find clear references with an initial search. Can you expand a bit more about this approach? Thanks.
Re:Google Docs will now use canvas based rendering by hctaw on Wednesday May 12, 2021 @04:14PM (#27134597)
It's a task more commonly found in computational geometry (3D range query == find all the points in a data set enclosed by a cube).

There are numerous data structures that are well suited for various geometric queries like ranges/lookups (interval trees, quadtrees) as well as more text-oriented operations like cut/copy/paste/insert/merge/etc (like ropes).

I'm not familiar with the operations required to put a cursor at the right place in a document, but knowing how much research has gone into storing similar data and looking up what you need efficiently the idea of "going through all the text every time" is a big code smell.

Re:Google Docs will now use canvas based rendering by ctoth on Wednesday May 12, 2021 @02:57PM (#27133861)
I've used a segment tree[0] for a similar problem before. For 3D queries an R-tree may be more appropriate.

[0]: https://en.wikipedia.org/wiki/Segment_tree

Re:Google Docs will now use canvas based rendering by williamscs on Wednesday May 12, 2021 @01:23PM (#27132808)
But does switching to using canvas solve that problem?
Re:Google Docs will now use canvas based rendering by nwsm on Wednesday May 12, 2021 @02:14PM (#27133397)
The argument is that the application would be much more performant, and would handle that issue better, not necessarily avoid it.