Skip to content(if available)orjump to list(if available)

Rebuilding Prime Video UI with Rust and WebAssembly

badlibrarian

Runs great on an underpowered Roku in HTML and JavaScript. But I guess why not. Developers gotta developer.

My main issue is having to buy my parents a bigger TV every few years because the fonts keep getting smaller and their eyes keep getting worse.

jeroenhd

But this also runs in the browser. Using HTML and Javascript. Except now it's done slightly differently in a way that's easier for browsers to optimize, if done well.

WebAssembly and Rust may be massive overkill for most web applications, but so is React or Vue or whatever Javascript framework is popular these days. When the inevitable rewrite happens, we might as well enjoy the benefits of the new, faster-than-the-old-evolved-moloch web UI.

If anything the move from the old system (React+WebAssembly) to the new one (Rust+minimal JS+WebAssembly) will make the web application itself smaller and easier to grasp.

YmiYugy

They don't really use browsers. They have basically build their own react-native version, but instead of using system UI as the backend they have a backend abstraction layer with implementations for their own rendering engine or alternatively a browser on platforms that don't support WebAssembly. They only use WebAssembly rather than native because updating native code typically requires an app update via the platforms update mechanism which is slow and unreliable. It looks like the new Rust UI version just swaps out their react fork for rust code and it looks like they are dropping browser support altogether.

wewxjfq

Rust is no panacea and rewriting a web application in Rust should not lead to any performance gains per se, unless your web application is doing number crunching in the mouse move handler. In most cases, you should be lucky to see no performance hits after a rewrite, because pleasing the borrow checker makes things unnecessarily more complicated.

A valid reason to switch to Rust should be a better developer experience, but it will require lots of upfront effort to realize the benefits. I doubt that it's worth it for small to medium-sized web applications.

Also, React itself is very much lightweight and fast, it's the developers who use it to program slow websites.

iLoveOncall

I have tested the reactivity difference between the current UI and the Rust rewrite and it is staggeringly faster, this is not just a dumb pet project.

badlibrarian

Just to make sure we're on the same page here, this is the app that lets me move a highlighted rectangle using a controller with 300ms latency to select the next episode of Reacher, right?

iLoveOncall

Yes, and the difference is incredible. It leads to a much less frustrating experience when navigating around the app overall.

jackothy

Wish they had said something about open sourcing their SDK.

They mentioned Leptos as an inspiration but this is clearly very different and has a lot of interesting features.

gozzoo

I'm not familiar with Rust or WebAssembly, but isn't Flutter more appropriate specifically for such applications?

jeroenhd

My experience with Flutter applications in the browser is absolutely terrible. Rather unfortunate, as the things Flutter promised would make it excellent for web applications like these.

The concept behind the way these platform renders is very similar, so the new Amazon UI may be terrible as well, but I wouldn't expect whoever made the GUI framework they use now to make the same mistakes Flutter made.

Edit: after looking into this some more, it looks like the approach Amazon took is quite different from most Rust UI libraries. They have written their own framework that basically re-implements React but entirely on the WebAssembly side. I don't think it works by throwing a <canvas> onto the screen and implementing a browser rendering engine in JS+WASM like Flutter does. They also seem to target native code where they do all the rendering themselves, but probably faster because they control all the layers and don't need to build a general-purpose UI engine for their video player with extra steps.

mixmastamyk

Why is a browser required for "living room devices?"

mathgeek

From the article:

> … but also in browsers because some living room devices today have just an HTML5 browser and don't even have flash space big enough to put our native C++ engine.

j45

It would be helpful to know what version of flutter you experienced this with, your comment caught my attention at least, thanks.

bickfordb

It's a similar effort. Flutter is a cross platform Dart UI framework that compiles to WASM for the web and also has Android/iOS build targets. The web version can be laggy on trivial examples. I would guess this younger Rust framework is less featureful than Flutter but is more efficient/faster (one of the stated goals in the article).

mathgeek

While it's possible to use Flutter for _some_ smart TVs and the like, it's not generally at the top of the recommendations.

j45

Happy to learn what might be - especially from the one codebase to everywhere perspective.

ainiriand

No, it is not.

6SixTy

Wikipedia says that Flutter can be transpiled to WebAssembly for web deployment.

echelon

Rust is finding itself everywhere. It's fantastic on the server. It's shaping up to be fantastic for UI.

It's fast, ergonomic, and the code has fewer defects than code written in other languages. (Google did a study on this.)

It's not as unapproachable as the memes make it seem. It's no harder or less productive than Java or Golang to write. (Google also did a study on this.)

The Rust WASM deploy story is sublime and is going to help it take over the world.

CyanLite2

WASM Components levels the playing field across all languages.

You can mix and match a C# Blazor component and a Rust component, and a Python component and they all compile to WASM and runs at equal speed.

nilslice

sounds like someone hasn’t actually tried or benchmarked this :)

echelon

Those other languages will have a GC.

hu3

Is this satire? I have difficulty identifying those.

ghurtado

I only hope that it is, but you never know.

null

[deleted]

rgbrgb

is it just me or does the prime video player seem to have a bug in chrome where the UI shows over the video and never goes away after pausing in full screen?

wondering if that’s the UI in question

greatgib

[dead]

MeetingsBrowser

I'm not familiar with Prime or its Video UI. Wouldn't a YouTube front end be more appropriate to rebuild with this tech stack?

iLoveOncall

This isn't about someone building this as a side-project, it's something Prime Video is working on. Which would be clear if you had even just opened the article.

a3w

Opened it. Skimmed it. Got to the conclusion, that it sells a "how to build something like the Amazon UI as a tutorial" course.

Not just my predecessor was confused by the wording and categories put on the page.