KEMBAR78
From HTML to pixels on the Screen | PPTX
FROM HTML TO
PIXELSON
THE SCREEN
IGORTALIC
https://www.linkedin.com/in/igortalic/
FROM HTML TO
PIXELS ONTHE
SCREEN
Igor Talić
Integrateddevicesdeveloper
/igortalic
BROWSER RENDERING ENGINE
• Rendering performance tips
• Keeping the app running at 60FPS
Sections
• Browser rendering pipeline
• Layers, 3D vs 2D difference
• Demo
BROWSERS RENDERING ENGINES
TRIDENT GECKO PRESTO WEBKIT BLINK
InternetExplorer
WindowsMobile
AOL Browsers
Mozilla Firefox
Firefox OS
Opera13
OperaMini
OperaMobile
Safari
webOS
Android
Chrome
Opera14+
Android14+
Browser rendering pipeline
HTML& CSSPARSER
• HTML parser is not trivial asCSS parser
• HTML parser tries to correct mistakes
• HTML parser can be blocked
• Process is reentrant – scripts can modify HTML
• Support for speculative parsing – Parse ahead
• End result is DOM and CSSOM
HTML& CSSPARSER
PERFORMANCE TIPS:
• Scripts, links and styles block parsing
• Fewerelements faster parsing, removecomments
• Minification helps with faster download faster unblocks parser
• Clean code– remove unused code
• Async scripts
RENDER/FRAME TREE
• Hasmultiple trees and structs
• The most complex process
• Visualrepresentation of the document
• Non-visualDOM elements willnot be inserted in the render tree, likehead or elements with
display none( but elements with visibilityhidden are )
• Style computation
• End result rules for drawing
RENDER/FRAME TREE
LAYOUT
• Sets nodes position and size
• Hasa batch model / batching dirty nodes
• Trigger by browser resize, innerHeight, fontSize, getComputedStyles…
PERFORMANCE TIP:
• Layout trashing
Layout
• https://www.youtube.com/watch?v=ZTnIxIA5KGw
PAINT
• Takes the information from render tree
• Creates layers
• Creates bitmaps for each layer and sends it to the GPU
• The SkiaGraphics Engine – Used in Blink
LAYERS
• Layersare GraphicsLayersthatbrowserusestoseparaterenderingofUI elements
Creatinglayers:
• 3D or perspective transformCSS properties
• <video> elements using acceleratedvideo decoding
• <canvas>elements witha 3D (WebGL) context or accelerated2D context
• Composited plugins (i.e. Flash)
• Elements withCSS animationfor theiropacity or using ananimatedtransform
• Elements withacceleratedCSS filters
• Element hasa descendantthathasa compositing layer (in otherwords if theelement has achildelement that’sin its ownlayer)
• Element hasa sibling witha lower z-index whichhas acompositing layer (in otherwords the it’srendered on topof a composited layer)
TRANSFORM3D vs 2D
• 3D uses the GPU
• Once on GPU translate, scale & rotate don’t trigger repaint and layout
Q&A
• https://www.html5rocks.com/en/tutorials/internals/howbrowserswork/#Render_tree_construction
• https://www.html5rocks.com/en/tutorials/speed/layers/
• https://www.chromium.org/developers/design-documents/gpu-accelerated-compositing-in-chrome
• https://www.youtube.com/playlist?list=PLAwxTw4SYaPmKmNX-INgcxQWf30KuWa_A

From HTML to pixels on the Screen