Top Banner
EXPERIENCES ADOPTING EFL IN SERVO (A NEW WEB BROWSER ENGINE) Lars Bergstrom Mozilla Research
18

[E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Jul 17, 2015

Download

Software

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

EXPERIENCES ADOPTING EFL IN SERVO (A NEW WEB BROWSER ENGINE)

Lars Bergstrom Mozilla Research

Page 2: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Why a new web browser?• Support new types of applications and new platforms

• All modern browser engines (Safari, Firefox, Chrome) originally designed pre-2000

• Coarse parallelism

• Tightly coupled components

• Vast majority of security issues are related to the C++ memory model

Page 3: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Servo• Architected for parallelism

• Coarse (per-tab), ala Chrome

• Lightweight (intra-page), too

• Written in a memory-safe systems language, Rust

Page 4: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

How a browser worksHTMLCSSJS

DOM Flow Tree

Display Lists

Script

Styling LayoutParsing

More details: https://github.com/larsbergstrom/papers/blob/master/icfp15-servo-submitted.pdf

Script & Interactions

Layers

Rendering

FinalOutput

Compositing

Page 5: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

How a browser worksHTMLCSSJS

DOM Flow Tree

Display Lists

Script

Styling LayoutParsing

More details: https://github.com/larsbergstrom/papers/blob/master/icfp15-servo-submitted.pdf

Script & Interactions

Layers

Rendering

FinalOutput

CompositingEcore?

Page 6: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

How a browser worksHTMLCSSJS

DOM Flow Tree

Display Lists

Script

Styling LayoutParsing

More details: https://github.com/larsbergstrom/papers/blob/master/icfp15-servo-submitted.pdf

Script & Interactions

Layers

Rendering

FinalOutput

CompositingEcore?

Evas?

Page 7: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Rest of this talk• Toolkit investigations

• Suitability of Ecore

• Attempts to build it

• Attempts to write a Rust wrapper

• Graphics exploration

• Evas as a flow tree replacement

• Evas as a display list replacement

Page 8: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Toolkit requirements in Servo• Open a window

• Handle mouse/keyboard/etc. events

• Raw graphics buffer handles

• Bonus points for cross-process secure APIs

• Multi-platform

• Linux, OSX, Android, Linux embedded, Windows, X11 remote, MESA

Page 9: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

How does Ecore measure up?

Toolkit Window Events Raw Secure Platforms

Ecore Yes Yes Yes Yes ?

SDL Yes Yes Yes No Yes

Glut Yes Yes Yes No No

Glfw Yes Yes Yes No No

Glutin Yes No Yes No No

Page 10: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Using Ecore• Packages missing or massively out of date

• Occasional packages on various Linux distros, all at least 2 versions old

• Homebrew (for OSX) were even older, basically just called configure and died due to lack of dependencies

• Android…

Page 11: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Building Ecore“I found the libraries to be pretty intimidating. Whilst it seemed like they were going for a modular approach, in practice you needed tons of dependencies, and needed to opt out of lots of seemingly unnecessary things. I mean, why on earth does one need *bullet physics* or freetype in a context creation/input library? And turning stuff off caused harsh rebukes on the IRC and from the build system itself. And for something that is meant to be cross-platform, the experience on OS X was pretty bad - apparently only one person was working on it, and they weren’t a regular committer.”

Page 12: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Bad times on IRCA - why don't you just follow the wiki page A - that already explains everythingy ou need to do

B - that page is 6 months old B - I have no idea who wrote it

bjz searches for osx in the wiki search bar - "No search results”

A - bjz, btw, update the wiki page if you see anything wrong there

Page 13: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Better times on IRCbjz -yeah, we handle the opengl calls and font rendering and all that C - and once you know a click happened, you have your own stuff to know where that click happened C - so from a very basic point of view, you'll have an Evas canvas with an image taking the whole thing where you'll draw with your own stuff C - and you want to listen to ecore_input events and pass them to your own handlers bjz - C: ok bjz - C: awesome, this is helpful

Page 14: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Wrapping Ecore in Rust

“And creating bindings for it was a pain. If you wanted to do I high quality wrapper like I normally do, you virtually had to wrap a large portion of the library… all the custom datatypes and object system… “

Page 15: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Now… Graphics!• Browser terminology

• Flow tree - the actual boxes/fragments resulting from applying styles to the DOM nodes

• Display list - hierarchical (z-index-respecting) lists of positioned elements

• Layers - content rendered into memory or GPU buffers

Page 16: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

Challenges with replacing the flow tree

• Specifications are quite persnickety about the final display

• CSS 2.1 17.6.2.1 Border conflict resolution“The rule of thumb is that at each edge the most "eye catching" border style is chosen, except that… “

• Also quite particular about stacking orders

• CSS 2.1 Appendix E Stacking Contexts“The painting order for the descendants of an element generating a stacking context…” followed by 10 steps, with up to 19 substeps each

Page 17: [E-Dev-Day-US-2015][2/9] Experiences Adopting EFL in Servo, a New Web Browser Engine (Lars Bergstrom)

So, how about that display list?• Just a few items (even when Servo is complete)

• SolidColor, Text, Image, Border, Gradient, Line, BoxShadow

• Challenges

• Serialize these across processes so that we can isolate the graphics drivers (insecure) from the content and script

• Do we still get benefits if the animations, etc. are at a higher level?