2/4 Featured Sessions, Kandroid S/W Fundamentals Study Group

A History of Android Technology www.kandroid.org 운영자 양정수 ([email protected]) 목 차

Technology History : Two Approaches • and Derivative Works : Git & • Reinterpretation and Standard : IO &

Since 2007, The Direction of Evolution • Platform : Architecture, Measurement f/w, Programming Models • Application : Compatibility, Performance, Memory • Convergence : Android & Chrome, Platform & Service, Cross Platform

All History is Contemporary History • Lesson : What must we learn from last 6 years? • Forecast : What is the future of Android Technology? • Action : What must we act as a developer right now?

Technology History : Two Approaches

“All history is contemporary history” History as thought and as action, Benedetto Croce (1938)

gerrit

Gerrit Code Review 1. 2008 (May 28–29) 2. 2009 (May 27–28) 3. 2010 (May 19–20) 4. 2011 (May 10–11) 5. 2012 (June 27–29) 6. 2013 (May 15–17) 7. 2014(June 25-26)

2014, 13th Kandroid minmax - www.kandroid.org 3 Technology History : Git & Gerrit

Total : 416 / External : 194 (KitKat 기준) Source : 2012, 10th Kandroid Seminar Android Externals & Git Technology 中에서 (JB기준) 200 - 조병호 350 307 etc 180 300 250 platform/bootable 160 200 platform/device 150 140 platform/frameworks 100 151 platform/hadware 50 120 0 platform/packages 100 platform/prebuilts platform/tools 80 platform/system platform/external 60

40

20

0

2014, 13th Kandroid minmax - www.kandroid.org 4 Technology History : Git & Gerrit

Code Review System

It is intended to find and fix MISTAKES overlooked. - Wikipedia

Source : 2013, 11th Kandroid Seminar Goal is COOPERATION, Gerrit – 코드 리뷰 시스템 도입의 필요성 및 사용 中에서 - 차영호 not fault-finding. from Guido Google Employees

안드로이드 코드를 한줄이라도 바꿔본 직원 수 Google 전체 직원수 600여명 37000여명 Framework Commiters Apps/Extra Commiters 20% time 68명 Google Employees 69명

2014, 13th Kandroid minmax - www.kandroid.org 5 Technology History : Google I/O & Standard API

1. 2008 (May 28–29, 2008) : OpenSocial, App Engine, Android… 2. 2009 (May 27–28, 2009) : Android, App Engine, Chrome… 3. 2010 (May 19–20, 2010) : Android, App Engine, Chrome, Google TV… 4. 2011 (May 10–11, 2011) : Android, Chrome, Chrome OS 5. 2012 (June 27–29, 2012) 1. Day 1 : Android, Google+, Project Glass 2. Day 2 : Chrome, Cloud, Project Glass 3. Day 3 : Analytics 6. 2013 (May 15–17, 2013) 1. Day 1 : Android, Chrome OS, Chrome, 2. Day 2 : Apps, Google+ Development

Session Types

• 101: 101 sessions don't require previous knowledge of a particular product or technology. They include overviews of a technology and introductions into new areas. That doesn't mean they aren't technical, because most are. If you are new to a product, start with the 101 sessions and progress to 201s. • 201: 201 sessions provide a deeper dive into a technology or product. These sessions go beyond the basics and are aimed at developers already familiar with a technology. • Code Labs: Code Labs walk developers through their first experience with a product or particular aspect of a product. They are 2 hour, more hands-on sessions where engineers will walk you through actual code. • Fireside Chats: Q&A is often the best part of a session, as it gives developers a chance to ask what's on their minds. Fireside chats are a chance to talk to the product engineering teams. • Tech Talks: Google has a tradition of holding informative Tech Talks on campus that offer insight into an area. In that tradition, Google I/O features Tech Talks on subjects of interest to developers, such as computer science problems and programming languages.

2014, 13th Kandroid minmax - www.kandroid.org 6 Technology History : Google I/O & Standard API

2008 2009 2010 2011 2012 2013 2014

AOSP M D E F G H I J K Branch

SDK 1 23 45 6 7 8 9 10 13 1415 16 17 1819 (API Level)

NDK 1 2 3 4 5 6 7 8 9 9c (Revision)

RenderScript android.support.. Extras android-support-v13.jar android-support-v7.jar Support Lib. (+USB Drivers) r1 r2 r3 r4 r6 r8r9 r10 r11 r13 r18 android-support-v4.jar (OHA) T-Mobile USA SKT Mobile Operators Open Access Traffic Qualcomm MSM7201a Semiconductor Multi-Core GPU / 64Bit Companies HTC G1 Handset Partnership New Platform Manufacturers with Google Inc. Strategy

2014, 13th Kandroid minmax - www.kandroid.org 7 목 차

Technology History : Two Approaches • Source Code and Derivative Works : Git & Gerrit • Reinterpretation and Standard : Google IO & APIs

Since 2007, The Direction of Evolution • Platform : Architecture, Measurement f/w, Programming Models • Application : Compatibility, Performance, Memory • Convergence : Android & Chrome, Platform & Service, Cross Platform

All History is Contemporary History • Lesson : What must we learn from last 6 years? • Forecast : What is the future of Android Technology? • Action : What must we act as a developer right now?

Platform : Architecture

Since 2007, The Direction of Evolution User Phone & Nfc(JB) App Space DRMServer (JB) Launcher Platform (User App) • Architecture MediaServer • Measurement f/w SurfaceFlinger • Programming Models SystemServer Application • Compatibility • Performance Framework Service • Memory • System Services • Hardware Services Convergence • Android & Chrome VM Service • Platform & Service Manager • Cross Platform Native Service • Sersor Service ( Binder • Surface Flinger Context Manager )

libbinder.so (libcutils.so, libutils.so)

/dev/binder

Kernel Binder Ashemem Space

2014, 13th Kandroid minmax - www.kandroid.org 9 Platform : Architecture

Since 2007, The Direction of Evolution Application Test Thread Case test.apk Platform Instrumentation • Architecture • Measurement f/w • Programming Models TLS Application Hello Application Android • Compatibility Activity

Activity .apk • Performance H • Memory Thread

dispatchMessage() Window Views Convergence Views • Android & Chrome Views • Platform & Service Looper • Cross Platform Choreographer Service $FrameHandler Threaded Binder dispatchMessage() Task Object Message Queue ContentProvider

Receiver Intent

Binder AsyncTask Android Resources Thread Thread Manifest. Pool Pool

2014, 13th Kandroid minmax - www.kandroid.org 10 Platform : Architecture

Since 2007, The Direction of Evolution

Move Engineers from PalmSource (Dianne Hackborn, etc…) Platform • Architecture • Measurement f/w • Programming Models

Application • Compatibility • Performance OpenBinder Binder • Memory next generation BeOS Cobalt system Android Convergence • Android & Chrome • Platform & Service • Cross Platform 2001 2005

The Binder communicates between processes using a small custom kernel module.

This is used instead of standard Linux IPC facilities so that we can efficiently model our IPC operations as "thread migration".

That is, an IPC between processes looks as if the thread instigating the IPC has hopped over to the destination process to execute the code there, and then hopped back with the result.

Source : http://www.angryredplanet.com/~hackbod/openbinder/docs/html/BinderIPCMechanism.html

2014, 13th Kandroid minmax - www.kandroid.org 11 Platform : Architecture

Since 2007, The Direction of Evolution Main Event Loop and IPC Thread Migration

Platform • Architecture • Measurement f/w Context TLS • Programming Models Activity Thread Application bindService() H • Compatibility handleMessage() • Performance Looper • Memory Service Connection Convergence • Android & Chrome onService Service • Platform & Service Connected Message • onCreate() • Cross Platform (IBinder) • onBind() Queue • onUnbind()

• onDestory()

IService.Stub. Custom 구현 asInterface Binder (IBinder); Thread IService.stub() { • getValue() BT #1 • setValue() IService.Stub. } Proxy() { } BT #N HelloAndroid.apk

User application Process User application Process

2014, 13th Kandroid minmax - www.kandroid.org 12 Platform : Measurement Framework

Since 2007, The Direction of Evolution General Performance Performance Monitoring

Sensitive Paths Tools / APIs Platform • Architecture • Measurement f/w • Programming Models

Application Event StrictMode • Compatibility • Performance • Memory

Bitmap Networking • systrace Convergence Invalidate Adapter • Android & Chrome Decoding and I/O • TraceView • Platform & Service • Cross Platform • getView() Measurem ent - Dump • HierarchyViewer - Recycling - ViewHolder • Tracer for OpenGL ES • Setting App (Dev Opt.) Layout

Update Draw Swap Draw dumpsys DisplayList DisplayList Buffers

2014, 13th Kandroid minmax - www.kandroid.org 13 Platform : Measurement Framework

Since 2007, The Direction of Evolution

Platform • Architecture • Measurement f/w • Programming Models Tracing Point

Application Java Native • Compatibility • Performance • Memory atrace ATRACE_CALL() android.os.Trace Convergence ATRACE_INT() • Android & Chrome start stop dump • Platform & Service Trace Trace Trace jni • Cross Platform

android_os_Trace ScopedTrace

adbd Tracer systrace (python)

tracing_on … trace trace_marker adb Linux Kernel (ftrace feature)

2014, 13th Kandroid minmax - www.kandroid.org 14 Platform : Measurement Framework

Since 2007, The Direction of Evolution

Activity Platform Set • Architecture Something Event Property Invalidate • Measurement f/w Happens • Programming Models Value

Application • Compatibility • Performance Draw • Memory Display List Convergence • Android & Chrome • Platform & Service Measure Prepare Update Draw Swap • Cross Platform & Draw DisplayList DisplayList Buffers Layout

Dequeue Enqueue Buffer Buffer

Display Composite Post Windows Buffer

SurfaceFlinger

2014, 13th Kandroid minmax - www.kandroid.org 15 Platform : Programming Models

Since 2007, The Direction of Evolution

Platform • Architecture • Measurement f/w • Programming Models Comparison and Analysis of Application the Three Programming Models • Compatibility • Performance in Google Android (2012, Intel) • Memory

Convergence • Android & Chrome • Platform & Service • What are the Three Programming Models ? • Cross Platform • Working Flow Comparison • Execution Model Comparison • Performance Difference and Analysis • Differences in Development and Deployment • Conclusion & Unified Programming Model

Source : http://people.apache.org/~xli/papers/applc2012-android-programming-models.pdf

2014, 13th Kandroid minmax - www.kandroid.org 16 Platform : Programming Models

Since 2007, The Direction of Evolution

Platform • Architecture Performance Analysis : Multiple Worker Thread • Measurement f/w • Programming Models

Application • Compatibility 70 • Performance • Memory 60

Convergence • Android & Chrome 50 • Platform & Service • Cross Platform SDK 40 SDK-MT 30 NDK NDK-MT 20

10

0 200 300 400 500 600 700 800 900 1000

Source : http://people.apache.org/~xli/papers/applc2012-android-programming-models.pdf

2014, 13th Kandroid minmax - www.kandroid.org 17 Platform : Programming Models

Since 2007, The Direction of Evolution

Platform • Architecture Performance Analysis : Runtime design diff. • Measurement f/w • Programming Models

Application • Compatibility 70 • Performance • Memory 60 Convergence • Android & Chrome 50 • Platform & Service • Cross Platform 40 SDK-MT NDK-MT 30 Renderscript 20

10

0 200 300 400 500 600 700 800 900 1000

Source : http://people.apache.org/~xli/papers/applc2012-android-programming-models.pdf

2014, 13th Kandroid minmax - www.kandroid.org 18 Platform : Programming Models

Since 2007, The Direction of Evolution Source : 12th Kandroid Conference

High Performance Apps Development with RenderScript Platform • Architecture • Measurement f/w 2 • Programming Models Class Sub Class SDK NDK RS NDK + RS Application 3 • Compatibility Memory O X X X • Performance Management • Memory Programmability Library O O X O Convergence Extensibility • Android & Chrome • Platform & Service Portability O △ O O • Cross Platform Strong Typing Security O X X 3 X and Verification 1 Vector Type X △ O O

Performance Thread Pool O △ O O

OpenGLES O O X O

1. Is it possible to support vector type without changing the JNI implementation? 2. Why did Google make RS separate from NDK? 3. Are Memory Management and Strong Typing critical issues?

2014, 13th Kandroid minmax - www.kandroid.org 19 Application : Compatibility

Since 2007, The Direction of Evolution PDK (Platform Development Kit) is a reduced set of Android release provided to chipset vendors and OEMs before a new android platform is released. The goal of the PDK release is to help chipset vendors and OEMs to Platform • Architecture migrate to a new release. • Measurement f/w • Programming Models

Application Compatibility Program Overview • Compatibility • Memory The Android compatibility program makes it easy for mobile • Performance device manufacturers to develop compatible Android devices. Convergence • Android & Chrome Program goals • Platform & Service • Provide a consistent application and • Cross Platform hardware environment to application developers. • Enable a consistent application experience for consumers. • Enable device manufacturers to differentiate while being compatible. • Minimize costs and overhead associated with compatibility.

Key components • The source code to the Android software stack(AOSP Source) • The Compatibility Definition Document(CDD), representing the "policy" aspect of compatibility • The Compatibility Test Suite(CTS), representing the "mechanism" of compatibility + Compatibility Test Suite Verifier (CTS Verifier)

2014, 13th Kandroid minmax - www.kandroid.org 20 Application : Compatibility

Since 2007, The Direction of Evolution

Platform Support Library : Backward-compatibility • Architecture • Measurement f/w • Programming Models 2008 2009 2010 2011 2012 2013 2014 Application • Compatibility • Memory • Performance M C D E F G H I J K

Convergence • Android & Chrome • Platform & Service • Cross Platform 1 2 3 4 5 6 7 8 9 10 13 14 15 16 17 18 19

1 2 3 4 5 6 7 8 9 9c

Extras android.support.v8.renderscript Support Lib. android-support-v13.jar android-support-v7.jar r1 r2 r3 r4 r6 r8r9 r10 r11 r13 r18

android-support-v4.jar

2014, 13th Kandroid minmax - www.kandroid.org 21 Application : Memory

Since 2007, The Direction of Evolution

Platform Memory Leak vs. Memory Overload • Architecture Java Footprint vs. External Limit • Measurement f/w • Programming Models

Application 40,000 • Compatibility • Memory 35,000 • Performance

Convergence 30,000 • Android & Chrome • Platform & Service Java Footprint • Cross Platform 25,000 Java

20,000 Java curAlloc

15,000

10,000 External 5,000

- 1 4 7 10 13 16 19 22 25 28 31 34 37 40 43 46 49 52 55 58 61 64 67 70 73 76 79 82 85 88 91

2014, 13th Kandroid minmax - www.kandroid.org 22 Application : Memory

Since 2007, The Direction of Evolution

Platform • Architecture Historical Analysis for Native and GPU Memory • Measurement f/w • Programming Models

Application 180,000,000 • Compatibility • Memory 160,000,000 • Performance

Convergence 140,000,000 • Android & Chrome Total • Platform & Service 120,000,000 • Cross Platform Alloc

100,000,000 Free NPss 80,000,000 OPss TextureCount 60,000,000 TextureSize 40,000,000

20,000,000

-

2014, 13th Kandroid minmax - www.kandroid.org 23 Application : Memory

Since 2007, The Direction of Evolution

Historical Analysis for Cocos2d-x Memory Platform • Architecture • Measurement f/w D/cocos2d-x debug info(697): OpenGL Error 0x0505 ? • Programming Models 60000000 Application • Compatibility • Memory 50000000 • Performance

Convergence 40000000 • Android & Chrome • Platform & Service • Cross Platform 30000000 Total Alloc 20000000 Free NPss 10000000 OPss

0

drawFrame[3] drawFrame[3] drawFrame[1] drawFrame[5] drawFrame[7] drawFrame[9] drawFrame[1]

LoadTexture[2] LoadTexture[4] LoadTexture[6] LoadTexture[8]

LoadBitmap[1] LoadBitmap[3] LoadBitmap[5] LoadBitmap[7] LoadBitmap[9]

LoadTexture[10]

BitmapRecycle[1] BitmapRecycle[3] BitmapRecycle[5] BitmapRecycle[7] BitmapRecycle[9]

2014, 13th Kandroid minmax - www.kandroid.org 24 Application : Memory

kmemtracer : Since 2007, The Direction of Evolution https://code.google.com/p/kmemtracer/

Platform • Architecture Test Case • Measurement f/w test.apk • Programming Models Application Instrumentation Thread Application Application • Compatibility TLS Hello • Memory • Performance Activity Android

Activity .apk Convergence • Android & Chrome Thread H • Platform & Service Window Views Views • Cross Platform dispatchMessage() Views Looper Service

Choreographer Threaded Binder $FrameHandler Task Object

Message dispatchMessage() ContentProvider Queue

Receiver Intent

Android Binder AsyncTask Resources Thread Pool Thread Pool Manifest.xml

2014, 13th Kandroid minmax - www.kandroid.org 25 Application : Performance

Since 2007, The Direction of Evolution General Performance Performance Monitoring

Sensitive Paths Tools / APIs Platform • Architecture • Measurement f/w • Programming Models

Application Event StrictMode • Compatibility • Memory • Performance

Bitmap Networking • systrace Convergence Invalidate Adapter • Android & Chrome Decoding and I/O • TraceView • Platform & Service • Cross Platform • getView() Measurem ent - Dump • HierarchyViewer - Recycling - ViewHolder • Tracer for OpenGL ES • Setting App (Dev Opt.) Layout

Update Draw Swap Draw dumpsys DisplayList DisplayList Buffers

2014, 13th Kandroid minmax - www.kandroid.org 26 Application : Performance

Since 2007, The Direction of Evolution

Platform • Architecture • Measurement f/w • Programming Models

Application • Compatibility • Memory Event A • Performance B Convergence • Android & Chrome Adapter Async Bitmap Network • Platform & Service Adapter Storage • Cross Platform View Drawable Decoding I/O (Invalidate)

Measurement • getView() • If an AdapterView has many children, part A is as important as part B. Dumb Layout • If the AdapterView has few children, part B becomes a bottleneck. Recycle • Bitmap decoding and Networking are responsible. Draw View Holder

2014, 13th Kandroid minmax - www.kandroid.org 27 Convergence : Android & Chrome

Since 2007, The Direction of Evolution

Project Butter vs. Chrome Incognito Platform • Architecture • Measurement f/w • Programming Models

Application • Compatibility • Memory • Performance

Convergence • Android & Chrome • Platform & Service • Cross Platform

2014, 13th Kandroid minmax - www.kandroid.org 28 Convergence : Android & Chrome

Since 2007, WebKit vs. Chrome The Direction of Evolution

Platform • Architecture Why Google did develop Chrome? • Measurement f/w • Programming Models

Application • Compatibility • Memory • Performance Chrome browser : Chromium Convergence uses multiple processes ! • Android & Chrome • Platform & Service • Cross Platform safer Sandbox the web app’s process

faster Separate threads for separate web apps Fast rendering engine, small footprint, … Optimized JS engine, v8 many opportunities Separate address spaces more stable for separate web apps

Chromium OS

2014, 13th Kandroid minmax - www.kandroid.org 29 Convergence : Android & Chrome

Since 2007, The Direction of Evolution

VSync and Chromium Powered WebView Platform • Architecture • Measurement f/w • Programming Models

Application • Compatibility Improved VSync Scheduling on Android • Memory New Architecture • Performance

Convergence • Android & Chrome • Platform & Service ~3.2ms • Cross Platform System VSync internal timer’s tick

Render Browser Process Process

2014, 13th Kandroid minmax - www.kandroid.org 30 Convergence : Android & Chrome

Since 2007, The Direction of Evolution

Platform • Architecture Google Play Developer Console: • Measurement f/w a better distribution experience • Programming Models

Application • Compatibility • Memory • Performance Beta testing and staged rollouts

Convergence • Android & Chrome • Platform & Service • Cross Platform

Localization improvements • App translation service • Optimization tips

New Analytics and monetization features

2014, 13th Kandroid minmax - www.kandroid.org 31 Convergence : Android & Chrome

Since 2007, The Direction of Evolution

Platform • Architecture • Measurement f/w • Programming Models 3.1 Application • Compatibility services • Memory • Performance • Achievements • Social and public leaderboards Convergence • Cloud saves • Android & Chrome • Real-time multiplayer • Platform & Service Location APIs • Cross Platform • Fused location provider • Geofencing APIs • Activity recognition API • New registration API • Cloud Connection Server (CCS) over XMPP • User Notifications API Google+ Cross-Platform Single Sign On • Authentication • Over-the-air installs • Interactive posts • Profile & social graph access • App activities in

2014, 13th Kandroid minmax - www.kandroid.org 32 Convergence : Cross Platform

Since 2007, The Direction of Evolution

Platform • Architecture • Measurement f/w programming overview • Programming Models (Android to Windows) Application • Compatibility • Memory • Performance

Convergence • Android & Chrome • Platform & Service • Cross Platform

Source : http://msdn.microsoft.com/en-us/library/windows/apps/dn263251.aspx

2014, 13th Kandroid minmax - www.kandroid.org 33 Convergence : Cross Platform

Since 2007, The Direction of Evolution

Platform Beyond Android • Architecture • Measurement f/w • Programming Models

Application With the current market saturation, is it possible to create • Compatibility a new platform? • Memory • Performance • B2G, Tizen, LG Web OS, Mobile

Convergence • Android & Chrome The successful development of a new platform could lead • Platform & Service • Cross Platform to advances. Nevertheless, it would be just one more in an already saturated market. So, we must streamline the market and focus on cross-platform compatibility with the status quo.

• Web-based (e.g. PhoneGap) • Native-based (e.g. Cocos2d-x) • VM-based (e.g. Mono)

Source : High Performance Android App. Development http://deview.kr/2013/detail.nhn?topicSeq=9

2014, 13th Kandroid minmax - www.kandroid.org 34 목 차

Technology History : Two Approaches • Source Code and Derivative Works : Git & Gerrit • Reinterpretation and Standard : Google IO & APIs

Since 2007, The Direction of Evolution • Platform : Architecture, Measurement f/w, Programming Models • Application : Compatibility, Performance, Memory • Convergence : Android & Chrome, Platform & Service, Cross Platform

All History is Contemporary History • Lesson : What must we learn from last 6 years? • Forecast : What is the future of Android Technology? • Action : What must we act as a developer right now?

All History is Contemporary History

Lesson : What must we learn from last 6 years? Google IO 2012 Forecast : What is the future of Android Technology? Project Butter Action : What must we act as a developer right now?

New Business Model

Traditional Service/Game Company

Traditional Manufacturer kandroid s/w membership (2012) kandroid s/w fundamentals study group (2013) kandroid s/w fundamentals study group (2014)

1. How SoC Works? 2. How Linux Works? 3. How Toolchain Works? 4. How Works? 5. How Chrome Browser Works?

2009 2012

2014, 13th Kandroid minmax - www.kandroid.org 36 2/4 Featured Sessions, Kandroid S/W Fundamentals Study Group

Q & A www.kandroid.org 운영자 양정수 ([email protected])