안드로이드 웹뷰의 모든것
이형욱
NAVER / Whale Core
웨일 브라우저 TL로 웨일 브라우저 개발 및 관련 기술을 연구하고 있습니다. 웹엔진 (WebKit, Blink) 오픈소스 활동을 하고 있으며, 현재 브라우저 렌더링 성능 및 메모리 최적화에 관심이 있습니다.
6. Web content in a box
Powers browsers such as AOSP Browser
Displays almost all mobile banner ads
Can be used to create portable HTML-based apps
Often intermixed imperceptibly with native Views
<- Android View
<- Android WebView
1. 안드로이드 웹뷰란 무엇인가?
8. • 안드로이드 제조사에서 경쟁적으로 WebKit을 Customization
• 안드로이드 버전별 서로 다른 WebKit을 사용하고 있음
1) Android 4.3 이전 버전은 WebKit 기반의 렌더링 엔진을 사용
2) Android 4.4 부터는 Blink 기반의 렌더링 엔진으로 교체
• 현재는 사용자 웹뷰 업데이트 유무에 따라 서로 다른 버전을 사용
HTML5 Test.com CSS3 Test.com
삼성 갤럭시 S4 472 59%
삼성 갤럭시 노트 2 404 47%
엘지 옵티머스 G 395 45%
엘지 옵티머스 뷰 395 45%
팬택 베가 No 6 318 45%
갤럭시 넥서스 (AOSP) 267 45%
3. 안드로이드 웹뷰와 파편화
9. 4. WebKit 브라우저 엔진의 역사
KHTML, KJS (1999.05 ~)
Blink (2013.04 ~)
WebKit (2001 ~)
Open Source in 2005
Apple Forks KHTML, KJS in 2001
Google Forks WebKit in 2013
10. 5. 안드로이드 웹뷰의 구조
Blink
(웹엔진)
Content
(멀티 프로세스 지원 레이어)
Content API
Blink
Chromium
Android
WebView
Framework
Browser
Framework
11. Google Chrome Chromium
Logo Colorful Blue
Crash reporting Yes, if you turn it on None
User metrics Yes, if you turn it on No
Video and audio tags AAC, MP3, Vorbis and Theora Vorbis and Theora by default
Adobe Flash
custom (non-free) plugin
included in release
supports NPAPI plugins,
including the one from Adobe
PDF support
custom (non-free) plugin
included in release
downloads and displays with
system PDF viewer
Code Tested by Chrome developers May be modified by distributions
Sandbox Always on Depending on the distribution
Quality Assurance
New releases are tested before
sending to users
Depending on the distribution
6. 크롬과 크로미움의 차이점
12. Chapter 2. How chromium works
[Source: http://alien.slackbook.org/blog/watch-netflix-video-in-your-chromium-browser-this-time-for-real/]
14. DOM: Document Object Model
• Document = HTML, well-formed XML
• Object Model = Data + Method
Standard way for accessing and manipulating
2. HTML Parser
15. CSSOM: CSS Object Model
• DOM과 비슷하게 CSS도 CSSOM이 있음
• CSS는 HTML Element의 스타일을 정의
• 외부 링크로 정의된 경우 렌더링이 블로킹 됨
• Cascade down 개념을 구현하기 위해 트리 구조
3. CSS Parser
17. Recalculate Style의 결과
• Render Tree = DOM Tree + CSSOM Tree
• DOM Tree와 Render Tree는 1:1 관계가 아님
• 화면에 보이는 요소들을 중심으로 구성
5. Render Tree (1/2)
18. 5. Render Tree (2/2)
DOM CSSOM
Render Tree
[Source: Critical Rendering Path By llya Grigorik]
19. Layout 알고리즘
• 각 박스의 넓이는 viewport (ICB)기준
• 각 박스의 높이는 contents (fonts)를 기준
• 윈도우 사이즈를 변경 하거나 폰트 변경 시 Global Layout
• Dirty bit system으로 incremental layout
6. Layout
26. A modern 2D graphics library
SkPicture, SkPicturePlayBack:
Records and replay draw operations.
[http://www.dorothybrowser.com/parallelizing-canvas-rendering/]
8. VSync 기반 멀티 쓰레드 렌더링 (6/6)
27. Chapter 3. How chromium powered WebView works
[Source: https://play.google.com/apps/testing/com.google.android.webview ]