正在加载视频...

视频加载失败

A visual comparison of HTML-in-Canvas vs rasterizing DOM to a canvas texture (side-by-side below, compare average capture times) Existing approaches to pull web content into canvas are slow and lossy: - Animations glitch, or don't play at all - CSS replication is imprecise - Clogs up the main thread,...

46,665 次观看 • 7 个月前 •via X (Twitter)

21 条评论

Samsy 的头像
Samsy7 个月前

Well 30ms is still slow isn’t it ? Is there a way to run the canvas off thread and instead transfer the canvas over a worker instead ?

Robin 的头像
Robin7 个月前

It is, yeah! Plenty of optimisations you could add to speed things up, this is more just a quick comparison of the two approaches running on my fairly mid laptop My understanding is that the html in canvas approach already uses an optimal route to grab the pixel data directly from the browser’s pipeline A lot of that bloat likely comes from the various CSS animations and reflows The pretext library might actually be of use here too

Robin 的头像
Robin7 个月前

There's a link to the actual demo here (toggle in top left corner)

Yuri 的头像
Yuri7 个月前

@Samsyyyy On MacBook M1 Max, 32 GB is 0.2-0.4ms. So performance is good on mid-high devices. I do have one question: Do you use polyfill? because I'm running html-in-canvas example inside of regular Chrome.

Robin 的头像
Robin7 个月前

@Samsyyyy Yeah I need a better laptop haha 😂 Poor GPU probably doesn't help. No polyfill at the moment, though it should disable the html-in-canvas option if the appropriate flag isn't set - do you get the "Browser native" button in top left?

chau 的头像
chau7 个月前

By the end of 2026, every React app: <html> ... <canvas> <html> ... </html> </canvas> ... </html>

Robin 的头像
Robin7 个月前

95% of them probably just magnifying lenses or text swirling around too! There’s a lot more potential for what this can do tbh, I think the examples are only scratching the surface

Robin 的头像
Robin7 个月前

It’s still a way off full adoption too though, still plenty of eg security considerations, feature optimisations

unconed 🛸💫🌞 的头像
unconed 🛸💫🌞7 个月前

@gfxprogrammer FWIW I took a look at this not too long ago and reached very different conclusions. The way it's designed, it can't really act as a proper UI layer.

Douglas Lopes 的头像
Douglas Lopes7 个月前

The elements can still trigger events?

Robin 的头像
Robin7 个月前

Like onclick etc? I believe so - they're real DOM elements. I know there's some issues with clickthrough, hover using the canvas approach but it's still early in development. But yeah the idea is that eventually it's as usable as true DOM elements but rendered within canvas

Douglas Lopes 的头像
Douglas Lopes7 个月前

Very interesting feature...

Tim Williams 的头像
Tim Williams7 个月前

This is going to solve a LOT of problems. More than just render speed.

Kuwazy 的头像
Kuwazy7 个月前

very nice

Knight Yoshi 的头像
Knight Yoshi7 个月前

Okay, but I’m not gauging performance off of multiple resizing, and I don’t know anyone else who is

Robin 的头像
Robin7 个月前

It's not a practical example, more exploring the best way to benchmark the techniques html-in-canvas would be replacing. Also if you're trying to run animations or interactivity within that canvas, you'd need low lag regardless.

yunocode 的头像
yunocode7 个月前

What are the stats of this (memory and cpu usage)?

Robin 的头像
Robin7 个月前

Relatively minimal, it's not a particularly intensive process, the newer method simply hooks into the data the browser already prepares for display anyway, so should run smoother.

Chekoy 的头像
Chekoy7 个月前

I'd love to see the web is hardware accelerated with GPU instead of rendering it via CPU. My 16 y.o laptop can handle GLSL on WebGL really well. And yeah as expected, doing the 2D canvas on it really puts it to a hell LOL.

Johnny Lewis, RN 的头像
Johnny Lewis, RN7 个月前

i’m so happy! skeumorphism can return

Shane 的头像
Shane7 个月前

Love this side by side

相关视频