Professional Documents
Culture Documents
Android WebView
Nicolas Roard
1 Friday, June 29, 2012
2 Friday, June 29, 2012
What are we going to talk about?
2 Friday, June 29, 2012
WebKit timeline
3
KDE
KHTML
1998
WebCore
+
Safari
2003
WebKit
open sourced
2005
Chrome
+
Android
2008
3 Friday, June 29, 2012
Architecture Architecture
4 Friday, June 29, 2012
5 Friday, June 29, 2012
WebKit
5 Friday, June 29, 2012
Overview
6
6 Friday, June 29, 2012
Overview
6
WebKit
WebCore
layout engine
JavaScriptCore
6 Friday, June 29, 2012
Overview
7
7 Friday, June 29, 2012
Overview
7
WebKit
7 Friday, June 29, 2012
Resources
(images,
html,...)
Overview
7
WebKit
7 Friday, June 29, 2012
Resources
(images,
html,...)
Overview
7
WebKit
7 Friday, June 29, 2012
Resources
(images,
html,...)
Overview
7
WebKit
DOM
7 Friday, June 29, 2012
Resources
(images,
html,...)
Overview
7
WebKit
DOM
Javascript
7 Friday, June 29, 2012
Resources
(images,
html,...)
Overview
7
WebKit
DOM
Javascript
Layout
7 Friday, June 29, 2012
Resources
(images,
html,...)
Overview
7
WebKit
DOM
Javascript
Layout
Platform
7 Friday, June 29, 2012
Resources
(images,
html,...)
Overview
7
WebKit
DOM
Javascript
Layout
Rendering
Platform
7 Friday, June 29, 2012
8 Friday, June 29, 2012
Platform
8 Friday, June 29, 2012
Platform implementation
9
9 Friday, June 29, 2012
Platform implementation
9
Network / Disk access
9 Friday, June 29, 2012
Platform implementation
9
Network / Disk access System integration
9 Friday, June 29, 2012
Platform implementation
9
Network / Disk access System integration
Graphics / Rendering
9 Friday, June 29, 2012
Platform implementation
9
Network / Disk access
Javascript engine
System integration
Graphics / Rendering
9 Friday, June 29, 2012
System integration
Eclair
- Database API support
- Application cache support (o!ine webapps)
- Geolocation API
- HTML5 video (fullscreen)
Honeycomb
- Media capture (camera)
- Device Orientation
10
10 Friday, June 29, 2012
Sunspider benchmark, Nexus S
11
0
1400
2800
4200
5600
7000
Android 2.3 (Gingerbread - API 9) Android 4.0 (ICS - API 14) Android 4.1 (JellyBean - API 16)
2743
4069
6223
(lower is better)
11 Friday, June 29, 2012
Sunspider benchmark
12
0
600
1200
1800
2400
3000
Nexus S Galaxy Nexus Laptop
268
1521
2743
(lower is better)
12 Friday, June 29, 2012
13 Friday, June 29, 2012
Rendering
13 Friday, June 29, 2012
Resources
(images,
html,...)
Overview
14
WebKit
DOM
Javascript
Layout
Rendering
Platform
14 Friday, June 29, 2012
Rendering Loop
15
15 Friday, June 29, 2012
Rendering Loop
15
Event
15 Friday, June 29, 2012
Paint
Rendering Loop
15
Event
15 Friday, June 29, 2012
Paint
Rendering Loop
15
Event Draw
15 Friday, June 29, 2012
Paint
Rendering Loop
15
Event Draw
15 Friday, June 29, 2012
Rendering
16
Document
16 Friday, June 29, 2012
Rendering
16
Document
Viewport
16 Friday, June 29, 2012
Rendering
16
Document
Viewport
16 Friday, June 29, 2012
Rendering
16
Document
Viewport
16 Friday, June 29, 2012
Rendering
16
Document
Viewport
16 Friday, June 29, 2012
17 Friday, June 29, 2012
Before Honeycomb
17 Friday, June 29, 2012
Rendering Picture
Resources
(images,
html,...)
Android WebView Software Rendering
18
WebKit
DOM
Javascript
Layout
Platform
18 Friday, June 29, 2012
Rendering Picture
Resources
(images,
html,...)
Android WebView Software Rendering
18
WebKit
DOM
Javascript
Layout
Platform
18 Friday, June 29, 2012
Picture
Vector representation of the entire page (not just the visible area)
No need to go back to webkit when:
- Scrolling
- Zooming
19
19 Friday, June 29, 2012
Multithreading
20
UI
Thread
WebCore
Thread
Picture
20 Friday, June 29, 2012
Multithreading
20
UI
Thread
WebCore
Thread
Events
Picture
20 Friday, June 29, 2012
Multithreading
20
UI
Thread
WebCore
Thread
Events
Picture Picture
20 Friday, June 29, 2012
Multithreading
20
UI
Thread
WebCore
Thread
Events
Picture
20 Friday, June 29, 2012
Problems with software rendering
21
21 Friday, June 29, 2012
Problems with software rendering
Speed is highly dependent on the time spent traversing and rasterizing the PictureSet
- Scroll and Zoom smoothness can vary depending on the website
21
21 Friday, June 29, 2012
Problems with software rendering
Speed is highly dependent on the time spent traversing and rasterizing the PictureSet
- Scroll and Zoom smoothness can vary depending on the website
Doesnt support 3D operations (i.e. for CSS3D)
21
21 Friday, June 29, 2012
Problems with software rendering
Speed is highly dependent on the time spent traversing and rasterizing the PictureSet
- Scroll and Zoom smoothness can vary depending on the website
Doesnt support 3D operations (i.e. for CSS3D)
Poor support of inline plugins or video (cannot have HTML content above a plugin/video;
position not in sync when scrolling/zooming)
21
21 Friday, June 29, 2012
22 Friday, June 29, 2012
Honeycomb and beyond
Adding Hardware Acceleration
22 Friday, June 29, 2012
Software wont keep up
0
220
440
660
880
1100
G1 Droid N1 NS XOOM
memcpy (MiB/s)
Pixel count
23
23 Friday, June 29, 2012
Tiling Content
24 Friday, June 29, 2012
Paint
Software Rendering
25
Scroll Draw
25 Friday, June 29, 2012
Paint
Software Rendering
25
Scroll Draw
16.66ms
25 Friday, June 29, 2012
Paint Paint
Software Rendering
25
Scroll Draw
16.66ms
25 Friday, June 29, 2012
26
Software Rendering
Viewport
Viewport
Viewport
Viewport
26 Friday, June 29, 2012
26
Software Rendering
Viewport
Viewport
Viewport
Viewport
26 Friday, June 29, 2012
26
Software Rendering
Viewport
Viewport
Viewport
Viewport
26 Friday, June 29, 2012
26
Software Rendering
Viewport
Viewport
Viewport
Viewport
26 Friday, June 29, 2012
Ideally...
27
Scroll Draw
<16.66ms
27 Friday, June 29, 2012
Hardware Rendering
28
Scroll
Draw Tiles
28 Friday, June 29, 2012
Hardware Rendering
28
Scroll
Draw Tiles
Thread 2
Thread 1
28 Friday, June 29, 2012
Hardware Rendering
28
Paint
Scroll
Draw Tiles
Thread 2
Thread 1
28 Friday, June 29, 2012
Hardware Rendering
28
Paint
Scroll
Draw
New Tiles
Tiles
Thread 2
Thread 1
28 Friday, June 29, 2012
Hardware Rendering
28
Paint
Scroll
Draw
New Tiles
Tiles
Paint
Thread 2
Thread 1
28 Friday, June 29, 2012
Hardware Rendering
28
Paint
Scroll
Draw
New Tiles
Tiles
Paint
Thread 2
Thread 1
28 Friday, June 29, 2012
29
Viewport
Tiled Rendering
29 Friday, June 29, 2012
29
Viewport
Tiled Rendering
29 Friday, June 29, 2012
29
Viewport
Tiled Rendering
29 Friday, June 29, 2012
29
Viewport
Tiled Rendering
29 Friday, June 29, 2012
29
Viewport
Tiled Rendering
29 Friday, June 29, 2012
29
Viewport
Tiled Rendering
29 Friday, June 29, 2012
29
Viewport
Tiled Rendering
29 Friday, June 29, 2012
29
Viewport
Tiled Rendering
29 Friday, June 29, 2012
Tiles Generation
30
WebCore
Thread
UI
Thread
30 Friday, June 29, 2012
Tiles Generation
30
Texture
Generation
Thread
WebCore
Thread
UI
Thread
30 Friday, June 29, 2012
Tiles Generation
30
Texture
Generation
Thread
WebCore
Thread
Picture
UI
Thread
30 Friday, June 29, 2012
Tiles Generation
30
Texture
Generation
Thread
WebCore
Thread
Picture
UI
Thread
30 Friday, June 29, 2012
Tiles Generation
30
Texture
Generation
Thread
WebCore
Thread
Picture
UI
Thread
30 Friday, June 29, 2012
Tiles Generation
30
Texture
Generation
Thread
WebCore
Thread
Picture
UI
Thread
30 Friday, June 29, 2012
Tiles Generation
30
Texture
Generation
Thread
WebCore
Thread
Picture
UI
Thread
30 Friday, June 29, 2012
A few additional things...
Slower at Painting, Faster at Drawing
- Software Rendering still useful
Precaching of tiles
- Prefetch of surrounding tiles
- Direction dependent
Content visibility
- Schedule low-res tiles (ICS -- API 14)
Memory usage
- Use a limited number of tiles (device dependent)
- Tiles are 256x256 (...so far!)
- Check if plain colors (JB -- API 16)
31
31 Friday, June 29, 2012
WebKit Layers
32 Friday, June 29, 2012
Moving content
33
33 Friday, June 29, 2012
Moving content
33
33 Friday, June 29, 2012
Moving content
33
33 Friday, June 29, 2012
Moving content
34
34 Friday, June 29, 2012
Moving content
35
35 Friday, June 29, 2012
Moving content
36
36 Friday, June 29, 2012
Moving content
37
37 Friday, June 29, 2012
Moving content
38
38 Friday, June 29, 2012
Moving content - with a layer
39
39 Friday, June 29, 2012
Moving content - with a layer
39
39 Friday, June 29, 2012
40 Friday, June 29, 2012
41 Friday, June 29, 2012
42 Friday, June 29, 2012
43 Friday, June 29, 2012
44 Friday, June 29, 2012
45 Friday, June 29, 2012
46 Friday, June 29, 2012
Base Layer
Video Layer Clip Layer
Scrollable Layer
47 Friday, June 29, 2012
Layers
Allow to composite elements of the page on their own surfaces
Faster to move things around (no need to invalidate/repaint)
Allow support for scrollable areas
Nice way of integrating foreign content (e.g. video, plugins) into a render tree
48
48 Friday, June 29, 2012
WebKit CSS 3D
49 Friday, June 29, 2012
50 Friday, June 29, 2012
51 Friday, June 29, 2012
52 Friday, June 29, 2012
WebKit Layers
...on Android
53 Friday, June 29, 2012
Architecture
54
UI
Thread
WebCore
Thread
Events
Picture Picture
54 Friday, June 29, 2012
Architecture
55
UI
Thread
WebCore
Thread
Events
Layers Layers
CSS Animations
55 Friday, June 29, 2012
CSS Animations
56
56 Friday, June 29, 2012
CSS Animations
CSS property to animate HTML elements
Supported on WebKit-based browsers, Firefox
High-level speci"cation of an animation
Allow complex animations
56
56 Friday, June 29, 2012
CSS Animations
CSS property to animate HTML elements
Supported on WebKit-based browsers, Firefox
High-level speci"cation of an animation
Allow complex animations
56
on Android
Hardware accelerated
- runs in parallel to webkit, on the UI thread
- V-Synced
Much faster than JavaScript...
- No need to execute webkit or javascript code
- No repaint -- elements are put onto layers
56 Friday, June 29, 2012
57 Friday, June 29, 2012
Keyframes animations / transform
@-webkit-keyframes x-spin {
0% { -webkit-transform: rotateX(0deg); }
50% { -webkit-transform: rotateX(180deg); }
100% { -webkit-transform: rotateX(360deg); }
}
58
58 Friday, June 29, 2012
Taking advantages of Layers
On mobile, our main problem is to go talk to WebKit and do the repaint/inval cycle
Moving elements to layers allow us to do things without having to go to WebKit
- Fixed Positioned elements
Asynchronously update webkit, no need to wait for WebKit to paint things
- Smooth interaction and immediate reactivity
59
59 Friday, June 29, 2012
Brought to you by Layers
Seamless integration of inline HTML5 video
Fixed positioned elements
IFrames support
Over#ow-scroll elements
CSS 3D
Fixed background elements
60
60 Friday, June 29, 2012
61 Friday, June 29, 2012
62 Friday, June 29, 2012
63 Friday, June 29, 2012
Some additional things...
Same code path as base surface
Memory usage
- Limited number of tiles
Drawing
- We merge layers
- Content check
Painting
- Fast invals
64
64 Friday, June 29, 2012
Using WebView
65 Friday, June 29, 2012
What can it do
Desktop-class HTML support
Viewport metatag support
IFrames, Scrollable elements
Fixed positioned elements
CSS Fixed background
CSS3D / CSS animations / Layers
HTML5 Video / Audio
Embedded fonts
Complex text: Japanese / Arabic text / etc
66
66 Friday, June 29, 2012
When...
67
Eclair
Database API support, for client-side databases using SQL.
Application cache support, for offline applications.
Geolocation API support, to provide location information about
the device.
<video> tag support in fullscreen mode.
viewport tag support
Froyo
Layers
Device Orientation
CSS3D transforms
IFrames
Overow-scroll elements
Inline video
Accessibility