Live data from Hacker News

Google Docs will now use canvas based rendering

workspaceupdates.googleblog.com

941–950 of 953 posts

Re: Google Docs will now use canvas based rendering

#941

Maybe because I am out of loop with web development, but this sounds like a huge change to me. So instead of HTML elements, there will be just one big element, and everything will be rendered there? How will text selection work for example? Will Google Docs basically implement a GUI library like GTK, which renders everything itself, but for the web?

I'm not sure but what you are suggesting is not outside the realm of possibility. There are already projects like https://makepad.dev/ which implement their GUI on top of WebGL. (Which is arguably more challenging than implementation on top of Canvas 2D.)

Ran well for a few minutes on my iPhone, but froze up and then again after refresh. But very responsive and crisp. Obviously not yet optimized for touch devices; have to tap and hold the scrollbar to scroll, native iOS stuff didn’t come up after text selection. Very cool and while imperfect according to other comments, this is not bad at all.

Re: Google Docs will now use canvas based rendering

#942
post #308

I wrote the terminal canvas renderers in VS Code that has been called out a few times here. Initially I implemented a canvas renderer using just a 2d context to draw many textures which sped things up "5 to 45 times"[1] over the older DOM renderer. Since then I moved onto a WebGL renderer[2] which was mostly a personal project, it's basically the first canvas renderer but better in every way since it works by organiz…

> Supporting screen readers will probably also negate the benefits of using canvas to begin with since you need to maintain the DOM structure anyway (the Accessibility Object Model DOM API should help here) The fact that the DOM elements are invisible (don't affect layout) should eliminate the majority of the performance cost, right?

They can't be display: none as that would mean the screen reader can't access them. To do this properly and help low vision people, you need to make sure the textarea is synced with the cursor position and that all the text is positioned roughly where the text on screen is. By doing this the screen reader will correctly outline the element being read.

There may also be additional costs like the string manipulation required to build the row text in the terminal, this is nothing that can't be optimized but then that's more memory and cache invalidation to worry about.

Re: Google Docs will now use canvas based rendering

#943

I think this is actually one of the few cases where canvas-based rendering makes sense as a replacement for the DOM. Docs is a full-featured application which already has to re-implement a lot of DOM-like features in order to fulfill its primary function (things like text formatting and layout, spell checking, etc). Doing it all in canvas doesn't sound significantly more difficult than what they're already doing. The…

This is a great example of a comment written by a developer or some otherwise technical person who is so used to thinking and speaking in terms of trees that they can't see the forest, let alone the village it's situated next to and the people inhabiting it. Google Docs may be an app, but a big part of the app, and confirmed to be one of the reasons for the migration here, is the part that renders the document to the…

[deleted]

Re: Google Docs will now use canvas based rendering

#944

This reminds me a lot of those websites that used to be implemented in Flash. It's just one giant opaque blob that gets downloaded and can do whatever it wants. When this stuff inevitably starts being used by every news and shopping website I wonder how search engines will be able to index it.

meta tags, and crawlers will use headless browsers or another thing and OCR on top of that. Google already handles SPAs where the content isn’t available until the JS is run. I wouldn’t be surprised if they already have tested or use a modified chromium and for crawling, plus OCR if necessary.

Re: Google Docs will now use canvas based rendering

#945
post #903

It is surprising to me how blind Google is to the second-order effects of this is. Suppose that this model of rendering pixels to canvas is a success. Suppose it is adopted by various content serving systems like WordPress, JavaScript frameworks, etc. Now Google Search has nothing to index! The whole web just became completely unsearchable. Google Search, and all web search as a concept, becomes mostly useless. You m…

Google’s crawler, or rather the component that processes pages, is much more advanced now. I’ve read it has no problem handling complex SPAs where only a “shell” page is initially returned and no information is available until JS runs. They probably have a modified chromium and maybe employ OCR to digest some content since there are now a gazillion ways to display a page and its content, aside from canvas.

Re: Google Docs will now use canvas based rendering

#946

On multiple levels it seems nuts to use canvas for a stylized text editor. There are layout consistency issues across browser and OS. The place I’ve seen this is page breaks changing between computers (or even zoom levels). Line length isn’t controlled solely by the browser, IIRC both kerning (letter spacing) and word spacing is determined by the OS. I implemented something like Docs myself, but with the goal of tota…

You can render the fonts and do the text shaping yourself. You don’t even have to use any of the Canvas API except putImageData, or WebGL. Also you can use your own curve drawing algorithms so you own all pixels of the application.

Re: Google Docs will now use canvas based rendering

#947

I've been playing around with pure-canvas web apps that are set up as follows: Client -> Server: Raw event stream (keyboard/mouse/touch/resize events) Server -> Client: Canvas draw batch stream The server provides a small javascript shim that bootstraps a websocket & subscribes to all required event sources. It also subscribes to the server issued batch events and has logic to dispatch draw commands to the canvas ele…

I’ve considered making something similar, but I’ve thought: what’s the advantage? Just more computation for the server that could be done client side. Why not just have the app on the client.

I’ve dubbed this the “cloud gaming” approach, lol.

Re: Google Docs will now use canvas based rendering

#948

Canvas will become de-facto, just like React did. Once that happens, indexing and scraping the web won't be trivial anymore. One would have to "opt-in" to using HTML/CSS to make sure that their page would be indexable. Clearly also indicates that Google is willing to give up on its web-indexing capabilities in the long term, now that they have a stronghold on the Mobile app marketplace. Most likely spells doom for we…

Their crawlers are more advanced now. They already handle SPAs with # URLs and content that’s only fetched once the JS is executed, and likely use some OCR and more powered by AI magic.

Re: Google Docs will now use canvas based rendering

#949

Earlier quoted context omitted.

Well, it’s clearly what the Google docs team wants. And it would yield higher performance for other similarly complex web apps (eg Figma). And allow native UI development in more languages (Blazor). It also looks to be the sort of thing the Flutter team want for web builds. And it could work well for the base system of chromeOS too. For whatever reason, Google invests hundreds of millions each year into chrome, and t…

Chrome has been pushing Houdini [1] for years. It doesn't have special WASM integration right now AFAICT but it is basically a lower level layout & rendering API for the browser. [1] https://ishoudinireadyyet.com/

I've looked at Houdini again and I'm not convinced.

First, because it's more like OpenGL 3 (add more powerful APIs) than Vulkan (clean room design).

Second, it seems mostly abandoned. The page you cited lists multiple sub-proposals that have "No signal" even from the Chrome team. All mentions of Houdini I can find on developers.google.com are from 2018. I can't find anything about Houdini integration with WebAssembly, which is what I'd expect if development was ongoing.

Overall, I'm seeing everything I would expect to see in the timeline where Mozilla has no intention of ever implementing Houdini, and Google has decided it's not worth pursuing beyond what's already implemented.

Re: Google Docs will now use canvas based rendering

#950
post #140

Earlier quoted context omitted.

"Ad blockers" need a new name. I don't consider uBlock Origin an "ad blocker". It's a proper user agent (like a browser is supposed to be) that gives the user control over what is allowed to happen on their machine. That just happens to have the side effect of not allowing most ads to render because the way they're typical delivered. It won't matter if everyone starts using canvas unless they also stop using my machi…

They also aren't obligated to serve you free content.

No one said they are.
Post reply on HN