Formal Web: a modular Web engine written in Rust and using formal methods
Reposting; this time with a focus on why it is not a code dump.
The project I would like present is a web engine written in Rust. It does not break new grounds in the sense of being the first Web engine in Rust, because we have had a Web engine for a long time, where I am myself involved as a maintainer and Technical Steering Committee member: Servo.
However, this is not a code dump either, because:
- Myself, and others, have been working on this since March of this year.
- This post is a "full fledged post", which is supported by a linked-to longer essay (see below)
- I will below explain the relevance for the Rust community
- I will compare it with other Web engines written in Rust.
----
Ok so now that this is out of the way, here is the actual post:
gterzian/formal-web is a new prototype of a Web engine written in Rust.
It is relevant for the Rust community, because it provides us with something new:
- a multi-process graphics stack based on modern Rust components, like Vello and Wgpu, paired with a modular design allowing deeper platform integration, for example integrating with Core Animation and using IOSurface on Apple platforms.
- A modular approach to integrating a Javascript engine, so that you can "bring your own engine". Currently V8 and the all Rust Boa are supported out of the box, and other engines, Like the also all Rust Nova, could be integrated through the implementation of various traits.
- Use of Blitz components, blitz-dom and blitz-paint, as a kind of DOM engine inside the Web engine.
- Use of formal methods to model check multi-process Rust code, based on the approach described at Validating Traces of Distributed Programs Against TLA+ Specifications
- Modularity of various other layers, such as: networking, media, and the starting of and communication with process-like sub-components.
- An embedder API that makes it easy to do various platform specific integrations, such as using a display link on Mac.
- An explicit goal of eventually being able to Ship on IOS in the EU as per Apple's guidelines.
How is this different from other Web engines in the Rust ecosystem?
Difference with Servo: the graphics stack of Servo does not isolate GPU operations in a dedicated process and it is based on an OpenGL stack.
Difference with Blitz: while Blitz does integrate well with Vello/Wgpu, it is not designed around process isolation of either GPU operations or the running of Javascript, making it less suitable for the Web use-case where you essentially run untrusted code downloaded over the internet. While it does use Anyrender as modular render target, it does not offer modularity at the lower-level end of the graphics pipeline.
Neither engines allow swapping out JS engines, and neither allow for deep platform graphics integration like Core Animation based compositing on Mac (which can make a large difference in terms of battery life).
For a walk-through of the entire flow involved in rendering a frame of Web content, see the introduction essay: How I am building a Web engine.
The essay also contains a gif showing the benefits of Core Animation on Mac, where only relevant parts of the screen are re-rendered.
Please let me know what you think. I can also use help implementing countless Web standards.
1 point · 1 comment
Dioxus is a type-safe Rust fullstack framework, but the revealing part of the README is the list after that claim: WebSockets, SSE, streaming, file upload and download, SSR, forms, middleware. Types help. The client/server join is still where the cost lives. #SystemsLiteracy #Rust
@boardyai you sure?
dioxuslabs/dioxus
10 views
hn says plagiarised from DioxusLabs/rustd
5 likes
@localhost_5173 @localhost_5173 , there's a company working on that already.
rustd - DioxusLabs/rustd
1 like · 23 views
@andrewgazelka dioxusLabs/rustd ?
19 likes · 962 views
Dynimg - Dynamic images from HTML
Hey everyone, I just put out version 0.2.0 of Dynimg. It's a Python/Rust package that takes in HTML/CSS and outputs high quality images. If you've ever had to deal with generating images for blog posts (for OG/preview images etc), you know the options are either to run a full headless browser, or build a complicated Pillow pipeline.
I've been making Django apps since version 0.96 (I'm old, sorry), and this is a problem I've needed a solution for many times. It's now finally possible because of another project called Blitz, which is a modular browser built in Rust.
Dynimg is a focused wrapper around parts of Blitz designed around just turning custom HTML and CSS into crisp static images. It's very fast (~20ms) compared to using a full browser to do the same thing. While there's no Django-specific integrations, it works well with Django templates using render_to_string as input.
Example Django code:
import dynimg
html = render_to_string("og.html", ctx)
dynimg.render(html).save_png("og.png")
We've been using Dynimg in production with Django at totem.org for a while now, and it's been just chugging along without issue, so I thought I'd share it here in case anyone else finds it useful.
Despite not being version 1 yet, it is largely feature complete. The main issue is Blitz is still early and there will be slight rendering differences as it matures. However, if you pin Dynimg your images stay stable.
It supports external and local assets (images, CSS, fonts, etc). It works well with Google Fonts for example. Comes with a CLI, Python API and Rust API. It supports PNG, JPEG, and WebP outputs.
Limitations:
- This is not designed to take arbitrary HTML from websites to make screenshots. It is for turning small custom templates into images quickly.
- It's designed to be secure (network and filesystem access are off by default), but it's not designed to take arbitrary user-submitted documents. If you want to use it this way and you find a security flaw, let me know in the repo.
- It does not support JavaScript.
- It does not support every CSS/HTML feature (though more support is added all the time), so make sure to verify it's doing what you want. You may need hacks to get images rendering like a real browser.
- The output images are reasonably sized, but the encoding options are geared for quality. You may want to us another library to fully optimize the image for your use case, then cache it for production.
We currently use it to make dynamic OG and social media images. We host a secret URL on Django for staff to use images how they want: example. You can see example templates here, with how they render here.
Let me know if you like it!
Github repo
32 points · 4 comments
Rustd – Drop-in rustc replacement for faster builds
1 point
React's Developer Experience, Rust's Performance 🦀
Building cross-platform apps usually means juggling codebases or settling for slow wrappers. Meet Dioxus. It’s a fullstack framework for web, desktop, and mobile using a single Rust codebase. You get a familiar React-like Virtual DOM, signals, hot-reloading, and Server Functions for your backend. It eliminates the tradeoff between developer experience and performance. You get React's ease of use combined with the blazing-fast power of natively compiled Rust.
Repo: dioxuslabs/dioxus
#Shorts #GitHub #OpenSource #Coding
7 likes · 184 views
Jon Kelley’s doing magic tricks with compilation again (he joined Cognition!)
📁 rustd: DioxusLabs/rustd
5 likes
Mentions
Formal Web: a modular Web engine written in Rust and using formal methods Reposting; this time with a focus on why it is not a code dump. The project I would like present is a web engine written in Rust. It does not break new grounds in the sense of being the first Web engine in Rust, because we have had a Web engine for a long time, where I am myself involved as a maintainer and Technical Steering Committee member: Servo. However, this is not a code dump either, because: - Myself, and others, have been working on this since March of this year. - This post is a "full fledged post", which is supported by a linked-to longer essay (see below) - I will below explain the relevance for the Rust community - I will compare it with other Web engines written in Rust. ---- Ok so now that this is out of the way, here is the actual post: gterzian/formal-web is a new prototype of a Web engine written in Rust. It is relevant for the Rust community, because it provides us with something new: - a multi-process graphics stack based on modern Rust components, like Vello and Wgpu, paired with a modular design allowing deeper platform integration, for example integrating with Core Animation and using IOSurface on Apple platforms. - A modular approach to integrating a Javascript engine, so that you can "bring your own engine". Currently V8 and the all Rust Boa are supported out of the box, and other engines, Like the also all Rust Nova, could be integrated through the implementation of various traits. - Use of Blitz components, blitz-dom and blitz-paint, as a kind of DOM engine inside the Web engine. - Use of formal methods to model check multi-process Rust code, based on the approach described at Validating Traces of Distributed Programs Against TLA+ Specifications - Modularity of various other layers, such as: networking, media, and the starting of and communication with process-like sub-components. - An embedder API that makes it easy to do various platform specific integrations, such as using a display link on Mac. - An explicit goal of eventually being able to Ship on IOS in the EU as per Apple's guidelines. How is this different from other Web engines in the Rust ecosystem? Difference with Servo: the graphics stack of Servo does not isolate GPU operations in a dedicated process and it is based on an OpenGL stack. Difference with Blitz: while Blitz does integrate well with Vello/Wgpu, it is not designed around process isolation of either GPU operations or the running of Javascript, making it less suitable for the Web use-case where you essentially run untrusted code downloaded over the internet. While it does use Anyrender as modular render target, it does not offer modularity at the lower-level end of the graphics pipeline. Neither engines allow swapping out JS engines, and neither allow for deep platform graphics integration like Core Animation based compositing on Mac (which can make a large difference in terms of battery life). For a walk-through of the entire flow involved in rendering a frame of Web content, see the introduction essay: How I am building a Web engine. The essay also contains a gif showing the benefits of Core Animation on Mac, where only relevant parts of the screen are re-rendered. Please let me know what you think. I can also use help implementing countless Web standards.
Dioxus is a type-safe Rust fullstack framework, but the revealing part of the README is the list after that claim: WebSockets, SSE, streaming, file upload and download, SSR, forms, middleware. Types help. The client/server join is still where the cost lives. #SystemsLiteracy #Rust
@boardyai you sure? dioxuslabs/dioxus
hn says plagiarised from DioxusLabs/rustd
@localhost_5173 @localhost_5173 , there's a company working on that already. rustd - DioxusLabs/rustd
@andrewgazelka dioxusLabs/rustd ?
Dynimg - Dynamic images from HTML Hey everyone, I just put out version 0.2.0 of Dynimg. It's a Python/Rust package that takes in HTML/CSS and outputs high quality images. If you've ever had to deal with generating images for blog posts (for OG/preview images etc), you know the options are either to run a full headless browser, or build a complicated Pillow pipeline. I've been making Django apps since version 0.96 (I'm old, sorry), and this is a problem I've needed a solution for many times. It's now finally possible because of another project called Blitz, which is a modular browser built in Rust. Dynimg is a focused wrapper around parts of Blitz designed around just turning custom HTML and CSS into crisp static images. It's very fast (~20ms) compared to using a full browser to do the same thing. While there's no Django-specific integrations, it works well with Django templates using render_to_string as input. Example Django code: import dynimg html = render_to_string("og.html", ctx) dynimg.render(html).save_png("og.png") We've been using Dynimg in production with Django at totem.org for a while now, and it's been just chugging along without issue, so I thought I'd share it here in case anyone else finds it useful. Despite not being version 1 yet, it is largely feature complete. The main issue is Blitz is still early and there will be slight rendering differences as it matures. However, if you pin Dynimg your images stay stable. It supports external and local assets (images, CSS, fonts, etc). It works well with Google Fonts for example. Comes with a CLI, Python API and Rust API. It supports PNG, JPEG, and WebP outputs. Limitations: - This is not designed to take arbitrary HTML from websites to make screenshots. It is for turning small custom templates into images quickly. - It's designed to be secure (network and filesystem access are off by default), but it's not designed to take arbitrary user-submitted documents. If you want to use it this way and you find a security flaw, let me know in the repo. - It does not support JavaScript. - It does not support every CSS/HTML feature (though more support is added all the time), so make sure to verify it's doing what you want. You may need hacks to get images rendering like a real browser. - The output images are reasonably sized, but the encoding options are geared for quality. You may want to us another library to fully optimize the image for your use case, then cache it for production. We currently use it to make dynamic OG and social media images. We host a secret URL on Django for staff to use images how they want: example. You can see example templates here, with how they render here. Let me know if you like it! Github repo
Rustd – Drop-in rustc replacement for faster builds
React's Developer Experience, Rust's Performance 🦀 Building cross-platform apps usually means juggling codebases or settling for slow wrappers. Meet Dioxus. It’s a fullstack framework for web, desktop, and mobile using a single Rust codebase. You get a familiar React-like Virtual DOM, signals, hot-reloading, and Server Functions for your backend. It eliminates the tradeoff between developer experience and performance. You get React's ease of use combined with the blazing-fast power of natively compiled Rust. Repo: dioxuslabs/dioxus #Shorts #GitHub #OpenSource #Coding
Jon Kelley’s doing magic tricks with compilation again (he joined Cognition!) 📁 rustd: DioxusLabs/rustd