1 of 47

What I Talk About When I Talk About Running on the Web

Jack Moffitt // jack@metajack.im // @metajack

Mozilla Research

PolyConf 2017

2 of 47

One: Space Jam is forever

3 of 47

“Describing why the Web is horrible is like describing why it’s horrible to drown in an ocean composed of pufferfish that are pregnant with tiny Freddy Kruegers”

James Mickens, “To Wash It All Away”

4 of 47

Omnipresence

5 of 47

6 of 47

Low barrier to entry

most technology

the web

7 of 47

Most developers are web developers

8 of 47

Web developers want to make apps

9 of 47

Web developers are ambitious

10 of 47

11 of 47

Two: We were not tall enough

12 of 47

13 of 47

1994 Pentium

14 of 47

2002 Pentium IV

15 of 47

2008 Nehalem

16 of 47

Web pages are fractal

17 of 47

18 of 47

Let’s rewrite C++ from scratch so that we can rewrite a browser from scratch.

19 of 47

Rust triforce

Fast, reliable, productive: pick three.

20 of 47

A safer web with Rust

  • WebAudio implementation in Firefox had 34 security critical bugs
  • All were array out of bounds or use after free errors
  • All would have been prevented by the Rust compiler

21 of 47

How do we make Servo fast?

  • Parallel styling
  • Parallel layout
  • Constellation
  • WebRender
  • (more on the way)

22 of 47

Parallel layout visualized

23 of 47

Monolithic engine

24 of 47

Multi-process engine

25 of 47

Servo pipeline

26 of 47

Servo constellation

27 of 47

cross-domain iframe from as.jivox.com

28 of 47

2008 Nehalem

29 of 47

2016 Skylake

30 of 47

WebRender Key Ideas

  • Retained mode instead of immediate mode
  • Designed for rendering CSS content
  • Draw the whole frame every frame
  • Use GPU for tasks it’s better at; free up CPU

pub enum SpecificDisplayItem {

Rectangle(...),

Text(...),

Image(...),

YuvImage(...),

WebGL(...),

Border(...),

BoxShadow(...),

Gradient(...),

Iframe(...),

PushStackingContext(...),

PopStackingContext,

PushScrollLayer(...),

PopScrollLayer,

}

31 of 47

32 of 47

Three: Problems of many sizes and shapes

33 of 47

Browser

34 of 47

Browser.html

35 of 47

Webviews

36 of 47

Apps

37 of 47

More apps

38 of 47

Other craziness

39 of 47

Existing options

  • WebKit API
  • UIWebView (iOS), WebView (Android)
  • Chrome Custom Tabs (Android)
  • Chromium Embedded Framework (CEF)
  • xulrunner
  • Electron

40 of 47

What do we need?

  • Lower-level API suitable for things that aren’t browser-like
  • Higher-level API needed that web developers can use

41 of 47

Four: Never stop never stopping

42 of 47

Browser.html

43 of 47

Runtime design

Runtime engine

Added APIs

Servo engine

44 of 47

Starling

45 of 47

Atom with Markdown preview

46 of 47

Starling ideas

  • The easiest or obvious way is the right way
  • Integration with Rust
  • Structure apps as communicating async services
  • Built on top of Streams and Tokio
  • Optimize JS / Rust boundary

47 of 47

How to get involved