SlideShare une entreprise Scribd logo
1  sur  49
Télécharger pour lire hors ligne
Web Engine-Aware 
Performace Optimization of 
HTML5 Games for Mobile Devices 
Sang Seok Lim (sangseok.lim@sk.com), 
Director, SK planet
Agenda 
● Web Engine Internal 
● Web Engine Performance Analysis 
● HTML5 Game Basics 
● Performace Optimization Techniques 
● Case study
Commercial Use Cases of HTML5 Games 
● In-app HTML5 games 
○ OK Cashbag Arcade (June, 2014) 
○ Syrup Plant Pop (October, 2014) 
● In-app means a hybrid app 
○ embedded through WebView 
○ not for a browser which is incapable of enabling BM 
● Goal from the business viewpoint 
○ user rentention for keeping/increasing UV of native 
apps
HTML5 Game Architecture Overview 
● from the viewpoint of performance, 
DOM/JavaScript APIs of HTML5 are tightly 
coupled to underlying SW/HW layers 
Game Logic (HTML/CSS/JavaScript) 
Game Engine (JavaScript, WebWorker) 
DOM/JavaScript API 
Webview Widget 
Webkit/Blink Engine 
Android/iOS 
HW(ARM CPU, OpenGL ES GPU)
Chrome Browser Architecture 
similar to Chrome Webview
HTML5 Game RunTime: WebKit 
● Layout/Rendering 
○ 2D, 3D graphics by GPU, text rendering 
● Sound 
○ <audio>, WebAudio 
● Physics 
○ Javascript engine, JIT, multi-core by WebWorker 
DOM <canvas> Physics Engine 
Parser Layout Rendering 
2D 
graphics 
3D 
graphics 
Text 
Rendering 
JavaScript Engine 
(JIT) 
multimedia 
(sound) 
Game 
Web 
engine 
Platform
Parsing before Rendering
WebKit Internal: Layout 
● Calculate left top, 
width, height of all 
DOM nodes 
contained in a 
HTML document 
● Group a set of 
DOM nodes then, 
stack the resultant 
groups accordingly 
left, top, width, height 
ordering layers 
https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context
Internal Data Structure for Rendering
WebKit Internal: Rendering 
● DOM Rendering 
○ Image + text 
○ CSS 2D/3D rendering 
■ GPU Acceleration 
● 2D graphics 
○ canvas/SW 
○ canvas/OpenGL ES 
● 3D graphics 
○ WebGL/OpenGL ES
DOM Rendering: Image + Text 
● It’s all about handling a image 
○ <img> tag represent a image 
○ text is broken into a serises of images 
Penguin 
P e 
n 
g 
u 
i 
n
DOM Rendering: CSS2D/3D 
● 2D/3D transform matrix 
rotate 
scale translate 
skew
DOM Rendering: CSS2D/3D 
● RenerLayers are selectively mapped into 
GPU textures for being rendered by GPU
DOM Rendering: CSS2D/3D by HW acceleration 
● 2D/3D transform of DOM nodes by GPU 
Penguin 
Penguin 
Penguin 
Texture generation by CPU Texture based animation by GPU
Texture Visualization by Inspector
<canvas> Rendering 
● 2D primitive 
○ path, curve, polygon 
○ fill, stroke 
○ image manipulation 
○ pixel manipulation 
● <canvas> primitive HW acceleraton 
○ image manipulation 
● <canvas> buffer itself is a GPU texture
WebGL Rendering 
● JavaScript wrapper of OpenGL
Compatibility across Mobile Devices 
● Not all of the rendering models can be used 
for mobile devices right now 
● Compatibility summary 
○ CSS 2D/3D (HW) 
■ ICS 4.0 >, iOS 4.0 > 
○ canvas (SW) 
○ Android 2.3 <= 
● canvas (HW) 
○ Android 4.0 >, iOS 5.0 > 
● WebGL 
○ iOS 8.0 > 
○ Android L >
OS Distribution of Customers 
OK Cashbag App (June, 2014) 
the critical 
defect by 
Google
General Rendering Back-end 
for Mobile Devices 
● <canvas> 2D for Game object rendering 
○ HW acceleration 
● DOM for Game UI 
○ 2D/3D by GPU
App-embedded Branded Casual Game 
● In-app play for user retention 
● No app update via app store
<canvas> based Game Development 
Browser limitations 
● Browser engine as a game platform 
○ rendering 
■ <canvas>, WebGL, DOM 
○ sound 
■ <audio> 
■ WebAudio 
○ resource loading 
■ XHR/<img> 
○ input 
■ touchstart, touchmove, touchend 
○ DPI management 
■ image resource scale up/down
<canvas> based Game Development 
Into Reality 
● The limitations of open source game engine 
○ only for PC chrome/Firefox 
○ does not meet the hard requirements for mobile OS 
● In-house game engine development 
○ to achieve stable 20 fps on our customer’s device 
■ higher is better even on android 2.3 and iOS 5.0 
○ reasonable touch response delay 
○ no garbage collection whiling playing 
● Further information 
○ http://www.slideshare.net/senxation/html5-ok-33344593
<canvas> Game Main Loop 
● As easy as animation by flipping pages
Representaion of Game Objects 
● Two approaches 
○ static image generation: offline image based 
○ dynamic image generation: drawing primitive 
combination based 
● Each approach has its own pros and cons 
○ performance 
○ design-constraint
Image based Object Representation 
● A series of sprite image cropping/scaling 
○ ctx.drawImage(src, dest) 
○ the performance of game is decided by drawImage() 
● Static image generation (offline) 
○ one for each low, mid, high resolution devices
Drawing Primitive Combination 
● Dynamic image generation 
○ draw an object onto a buffer with the prior 
knowledge of device DPI, target pixel dimension 
○ minimize image scaling during rendering 
http://simeonvisser.hubpages.com/hub/HTML5-Tutorial-Drawing-Circles-and-Arcs
Summary of Pros and Cons 
● Image based (offline) 
○ overall performance limited by image scaling 
primitive 
○ designer-friendly 
● Drawing primitive based (online) 
○ higher performance 
○ be an enemy to a developer with lower IQ 
○ be an enemy to a designer
Performance of <canvas> in Detail 
in WebView for Hybrid App 
● The killing bottleneck is “PAINTING” 
● Performance challenges 
○ no <canvas> HW acceleration: android 2.3, iOS 4.0 
○ Kitkat Chrome Webview’s critical error by Google 
■ no HW acceleration on 4.4, 4.4.2 Chrome 
Webview 
■ fixed at 4.4.3 
■ but market share of 4.4.2 in Korea → 65%
The Problem Definition 
when it comes to developing <canvas> game for mobile devices 
● Android 2.3 without canvas HW acceleration 
○ together with canvas acceleration 
● Android /4.4[0-2]/ without canvas HW 
acceleration
Performance Analysis of Kitkat Webview 
● To find the performance limiting factors 
○ painting size 
○ the number of drawing primitive calls 
○ DOM tree complexity 
● System under test 
○ Optimus G Pro (4.4.2) 
○ Nexus 5 (4.4)
Performan Analysis I 
● Partial rendering 
○ reuse the content of a previous frame buffer 
● Full rendering 
○ reset a frame buffer every rendering 
painting area size 
fps 
The Larger, The Slower
Performance Analysis II 
● Increase the number of painting areas 
○ a painting area size is fixed to 25x25 
fps 
the number of painting area
Performance Analysis III 
● Impact analysis with respect to DOM complexity
Performance Analysis V 
● Impact analysis with respect to DOM complexity 
● Severe fps fluctuation
Summary of Performance Analysis 
● In proportion to the size of painting area, 
painting performance (fps) is decreased 
● The more complex DOM tree containing 
<cavas> is, the more severely fps fluctuates
Performance Improvement 
● 5 practical techniques 
○ DOM/<canvas> hybrid rendering for game objects 
○ Static object pool for keeping garbage collector 
asleep 
○ Smart repaint by tracing invaldated areas 
○ Image resource offline manipulation 
○ Minimize a DOM tree complexity 
● not all of them are applicable at the same 
time 
○ depending on game scenario, game performance 
requirement, smart repaint/hybrid rendering can be 
selectively applicable
DOM/<canvas> Hybrid Rendering 
painting size minimization 
● Selectively separate game objects contained in 
<canvas>, and then paint them through DOM 
canvas only canvas/DOM Hybrid
DOM/<canvas> Hybrid Rendering 
implementation detail: DOM node pool 
● Manage/reuse a set of DOM nodes with a 
background image of a game object
Smart Repaint 
Repaint Region Trace 
● Reuse the content of the frame buffer of n-1 
frame for rendering n frame 
● Trace the invalidated area, paint only 
invalidated area
Source Image Size Matters A LOT! 
● A sprite image is generally used to minimize # of 
network req 
● Performance anomaly 
○ the larger the source image is, the slower fps is, even when the 
destination size is fixed 
separate
Garbage Collector Stops The World 
● All objects are allocated from a object pool 
● Implementation of a object pool matters 
○ single Array, double Array, linked list 
○ http://jsperf.com/objectpool-performance-comparison
Static Object Pool Performance Comparision 
● Single array by Array.push/pop is the best 
○ poor performance of Array.spice() 
● Complete suppression of GC is impossible
Dive into Resolution Issue 
● A designer-generated image is scaled 
up/down 4 times at most implicitly 
○ canvas.width, canvas.height 
○ canvas.style.width, canvas.style.height 
○ ctx.drawImage(source, destination) 
○ window.devicePixelRatio 
● Try not to scale canvas.width/height, canvas. 
style.width/height 
○ how to adapt device resolution in performant way 
○ no fitting/add padding is good for performance 
○ sub optimal display for a user
<canvas> Isolation 
● fps swing around 30% up and down, when 
<canvas> is contained within a document 
with complex DOM tree 
● Seprate <canvas> from DOM based game UI 
○ not easy in the real field where designers/publisher 
and developers from different teams are co-working
Case Study: Flappy Ball 
● DOM/<canvas> hybrid 
● Smart repaint, sprite image separation
2048 
● DOM/GPU only 
● Keeping GPU textures as long as possible
Space 2014 
● Radically reuse a previous frame without 
clearance 
○ Android 2.3 
● clearRect/fillRect
Closing Remark 
● For commercialization on mobile devices, 
performance matters a lot 
○ understading Web-engine internals is essential for 
developing commercial level game successfully 
● open sourced 
○ http://skpla.net/bPqc

Contenu connexe

Tendances

Hardware Acceleration in WebKit
Hardware Acceleration in WebKitHardware Acceleration in WebKit
Hardware Acceleration in WebKitJoone Hur
 
Chromium ui framework(shared)
Chromium ui framework(shared)Chromium ui framework(shared)
Chromium ui framework(shared)gnomekr
 
Chrome Internals: Paint and Composition
Chrome Internals: Paint and CompositionChrome Internals: Paint and Composition
Chrome Internals: Paint and CompositionDzmitry Varabei
 
Html5 features: location, history and offline apps
Html5 features: location, history and offline appsHtml5 features: location, history and offline apps
Html5 features: location, history and offline appsKonstantin Delchev
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applicationsSC5.io
 
[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523NAVER D2
 
Building a Next Generation Mobile Browser using Web technologies
Building a Next Generation Mobile Browser using Web technologiesBuilding a Next Generation Mobile Browser using Web technologies
Building a Next Generation Mobile Browser using Web technologiesn_adam_stanley
 
Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)Bin Chen
 
Chrome & Webkit overview
Chrome & Webkit overviewChrome & Webkit overview
Chrome & Webkit overviewBin Chen
 
Introducing Kendo UI
Introducing Kendo UIIntroducing Kendo UI
Introducing Kendo UIJohn Bristowe
 
Introduction to Browser Internals
Introduction to Browser InternalsIntroduction to Browser Internals
Introduction to Browser InternalsSiva Arunachalam
 
LCU14 208- Chromium-Blink Migration for RDK
LCU14 208- Chromium-Blink Migration for RDKLCU14 208- Chromium-Blink Migration for RDK
LCU14 208- Chromium-Blink Migration for RDKLinaro
 
Single Page WebApp Architecture
Single Page WebApp ArchitectureSingle Page WebApp Architecture
Single Page WebApp ArchitectureMorgan Cheng
 
Sg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleySg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleyn_adam_stanley
 
Kendo UI presentation at JsConf.eu
Kendo UI presentation at JsConf.euKendo UI presentation at JsConf.eu
Kendo UI presentation at JsConf.euAlexander Gyoshev
 
Sencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampSencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampn_adam_stanley
 
The Internal Architecture of Chrome Developer Tools
The Internal Architecture of Chrome Developer ToolsThe Internal Architecture of Chrome Developer Tools
The Internal Architecture of Chrome Developer ToolsMiroslav Bajtoš
 

Tendances (20)

Hardware Acceleration in WebKit
Hardware Acceleration in WebKitHardware Acceleration in WebKit
Hardware Acceleration in WebKit
 
Chromium ui framework(shared)
Chromium ui framework(shared)Chromium ui framework(shared)
Chromium ui framework(shared)
 
Chrome Internals: Paint and Composition
Chrome Internals: Paint and CompositionChrome Internals: Paint and Composition
Chrome Internals: Paint and Composition
 
Web components api + Vuejs
Web components api + VuejsWeb components api + Vuejs
Web components api + Vuejs
 
Html5 features: location, history and offline apps
Html5 features: location, history and offline appsHtml5 features: location, history and offline apps
Html5 features: location, history and offline apps
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applications
 
[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523[D2 오픈세미나]2.browser engine 이형욱_20140523
[D2 오픈세미나]2.browser engine 이형욱_20140523
 
Building a Next Generation Mobile Browser using Web technologies
Building a Next Generation Mobile Browser using Web technologiesBuilding a Next Generation Mobile Browser using Web technologies
Building a Next Generation Mobile Browser using Web technologies
 
Eureko frameworks
Eureko frameworksEureko frameworks
Eureko frameworks
 
Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)Browsers on Android (Webkit,chromium)
Browsers on Android (Webkit,chromium)
 
Chrome & Webkit overview
Chrome & Webkit overviewChrome & Webkit overview
Chrome & Webkit overview
 
Introducing Kendo UI
Introducing Kendo UIIntroducing Kendo UI
Introducing Kendo UI
 
Introduction to Browser Internals
Introduction to Browser InternalsIntroduction to Browser Internals
Introduction to Browser Internals
 
LCU14 208- Chromium-Blink Migration for RDK
LCU14 208- Chromium-Blink Migration for RDKLCU14 208- Chromium-Blink Migration for RDK
LCU14 208- Chromium-Blink Migration for RDK
 
Single Page WebApp Architecture
Single Page WebApp ArchitectureSingle Page WebApp Architecture
Single Page WebApp Architecture
 
Web Components and PWA
Web Components and PWAWeb Components and PWA
Web Components and PWA
 
Sg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanleySg conference multiplatform_apps_adam_stanley
Sg conference multiplatform_apps_adam_stanley
 
Kendo UI presentation at JsConf.eu
Kendo UI presentation at JsConf.euKendo UI presentation at JsConf.eu
Kendo UI presentation at JsConf.eu
 
Sencha touchonbb10 bootcamp
Sencha touchonbb10 bootcampSencha touchonbb10 bootcamp
Sencha touchonbb10 bootcamp
 
The Internal Architecture of Chrome Developer Tools
The Internal Architecture of Chrome Developer ToolsThe Internal Architecture of Chrome Developer Tools
The Internal Architecture of Chrome Developer Tools
 

En vedette

The comprehensive guide for optimizing the performance of mobile HTML5 Web ap...
The comprehensive guide for optimizing the performance of mobile HTML5 Web ap...The comprehensive guide for optimizing the performance of mobile HTML5 Web ap...
The comprehensive guide for optimizing the performance of mobile HTML5 Web ap...Sang Seok Lim
 
[C1]웹서비스, 빠를수록 좋다
[C1]웹서비스, 빠를수록 좋다[C1]웹서비스, 빠를수록 좋다
[C1]웹서비스, 빠를수록 좋다NAVER D2
 
NAVER의 웹/HTML5환경 대응 현황
NAVER의 웹/HTML5환경 대응 현황NAVER의 웹/HTML5환경 대응 현황
NAVER의 웹/HTML5환경 대응 현황NAVER Engineering
 
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다동수 장
 
2015 FOSScon NAVER OSS Governance
2015 FOSScon NAVER OSS Governance2015 FOSScon NAVER OSS Governance
2015 FOSScon NAVER OSS GovernanceNAVER Engineering
 
2016 네이버sw기술소개
2016 네이버sw기술소개2016 네이버sw기술소개
2016 네이버sw기술소개NAVER Engineering
 
HTML5 관점에서 본 2014 모바일 웹 앱 개발 동향과 사례 및 발전 방향 전망
HTML5 관점에서 본 2014 모바일 웹 앱 개발 동향과 사례 및 발전 방향 전망HTML5 관점에서 본 2014 모바일 웹 앱 개발 동향과 사례 및 발전 방향 전망
HTML5 관점에서 본 2014 모바일 웹 앱 개발 동향과 사례 및 발전 방향 전망Sang Seok Lim
 
W3C HTML5 Conference 2015 - NAVER 웹 기술 및 환경 전망
W3C HTML5 Conference 2015 - NAVER 웹 기술 및 환경 전망W3C HTML5 Conference 2015 - NAVER 웹 기술 및 환경 전망
W3C HTML5 Conference 2015 - NAVER 웹 기술 및 환경 전망NAVER Engineering
 
Web app 개발 방법론
Web app 개발 방법론Web app 개발 방법론
Web app 개발 방법론Sang Seok Lim
 
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유Sang Seok Lim
 
HTML5 관점에서 2015년 웹 앱 개발 동향과 사례 및 2016년 발전 방향 저...
HTML5 관점에서 2015년 웹 앱 개발 동향과 사례 및 2016년 발전 방향 저...HTML5 관점에서 2015년 웹 앱 개발 동향과 사례 및 2016년 발전 방향 저...
HTML5 관점에서 2015년 웹 앱 개발 동향과 사례 및 2016년 발전 방향 저...Sang Seok Lim
 
Web Framework (웹 프레임워크)
Web Framework (웹 프레임워크)Web Framework (웹 프레임워크)
Web Framework (웹 프레임워크)Junsu Kim
 

En vedette (13)

The comprehensive guide for optimizing the performance of mobile HTML5 Web ap...
The comprehensive guide for optimizing the performance of mobile HTML5 Web ap...The comprehensive guide for optimizing the performance of mobile HTML5 Web ap...
The comprehensive guide for optimizing the performance of mobile HTML5 Web ap...
 
[C1]웹서비스, 빠를수록 좋다
[C1]웹서비스, 빠를수록 좋다[C1]웹서비스, 빠를수록 좋다
[C1]웹서비스, 빠를수록 좋다
 
NAVER의 웹/HTML5환경 대응 현황
NAVER의 웹/HTML5환경 대응 현황NAVER의 웹/HTML5환경 대응 현황
NAVER의 웹/HTML5환경 대응 현황
 
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
웹 애플리케이션 프레임웍의 과거,현재 그리고 미래 - 봄날은 간다
 
2015 FOSScon NAVER OSS Governance
2015 FOSScon NAVER OSS Governance2015 FOSScon NAVER OSS Governance
2015 FOSScon NAVER OSS Governance
 
2016 네이버sw기술소개
2016 네이버sw기술소개2016 네이버sw기술소개
2016 네이버sw기술소개
 
HTML5 관점에서 본 2014 모바일 웹 앱 개발 동향과 사례 및 발전 방향 전망
HTML5 관점에서 본 2014 모바일 웹 앱 개발 동향과 사례 및 발전 방향 전망HTML5 관점에서 본 2014 모바일 웹 앱 개발 동향과 사례 및 발전 방향 전망
HTML5 관점에서 본 2014 모바일 웹 앱 개발 동향과 사례 및 발전 방향 전망
 
W3C HTML5 Conference 2015 - NAVER 웹 기술 및 환경 전망
W3C HTML5 Conference 2015 - NAVER 웹 기술 및 환경 전망W3C HTML5 Conference 2015 - NAVER 웹 기술 및 환경 전망
W3C HTML5 Conference 2015 - NAVER 웹 기술 및 환경 전망
 
Web app 개발 방법론
Web app 개발 방법론Web app 개발 방법론
Web app 개발 방법론
 
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
Angularjs, ionic, cordova 기반 syrup store app 개발 사례 공유
 
HTML5 관점에서 2015년 웹 앱 개발 동향과 사례 및 2016년 발전 방향 저...
HTML5 관점에서 2015년 웹 앱 개발 동향과 사례 및 2016년 발전 방향 저...HTML5 관점에서 2015년 웹 앱 개발 동향과 사례 및 2016년 발전 방향 저...
HTML5 관점에서 2015년 웹 앱 개발 동향과 사례 및 2016년 발전 방향 저...
 
Web Framework (웹 프레임워크)
Web Framework (웹 프레임워크)Web Framework (웹 프레임워크)
Web Framework (웹 프레임워크)
 
2017 ict 대전망 framework
2017 ict 대전망 framework2017 ict 대전망 framework
2017 ict 대전망 framework
 

Similaire à Korea linuxforum2014 html5game-sangseoklim

Running HTML5 Mobile Web Games at 60fps
Running HTML5 Mobile Web Games at 60fpsRunning HTML5 Mobile Web Games at 60fps
Running HTML5 Mobile Web Games at 60fpsApoorv Saxena
 
Parallel programing in web applications - public.pptx
Parallel programing in web applications - public.pptxParallel programing in web applications - public.pptx
Parallel programing in web applications - public.pptxGuy Bary
 
New Ranking Metrics by Google
New Ranking Metrics by GoogleNew Ranking Metrics by Google
New Ranking Metrics by GooglePhil Marx
 
Овчаренко Євген “Відеоігри це ефективність”
Овчаренко Євген “Відеоігри це ефективність”Овчаренко Євген “Відеоігри це ефективність”
Овчаренко Євген “Відеоігри це ефективність”Lviv Startup Club
 
High Performance Rust UI.pdf
High Performance Rust UI.pdfHigh Performance Rust UI.pdf
High Performance Rust UI.pdfmraaaaa
 
Performance & dev tools
Performance & dev toolsPerformance & dev tools
Performance & dev toolsGuy Yogev
 
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian BallantyneWT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian BallantyneAMD Developer Central
 
Ustream Techtalks: Google Chrome Developer Tools
Ustream Techtalks: Google Chrome Developer ToolsUstream Techtalks: Google Chrome Developer Tools
Ustream Techtalks: Google Chrome Developer ToolsMáté Nádasdi
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentDavid Galeano
 
Using JavaScript to write Native Mobile Applications
Using JavaScript to write Native Mobile ApplicationsUsing JavaScript to write Native Mobile Applications
Using JavaScript to write Native Mobile ApplicationsDerek Anderson
 
AAA 3D GRAPHICS ON THE WEB WITH REACTJS + BABYLONJS + UNITY3D by Denis Radin ...
AAA 3D GRAPHICS ON THE WEB WITH REACTJS + BABYLONJS + UNITY3D by Denis Radin ...AAA 3D GRAPHICS ON THE WEB WITH REACTJS + BABYLONJS + UNITY3D by Denis Radin ...
AAA 3D GRAPHICS ON THE WEB WITH REACTJS + BABYLONJS + UNITY3D by Denis Radin ...DevClub_lv
 
JS Fest 2019. Денис Радин. AAA 3D графика в Web с ReactJS, BabylonJS и Unity3D
JS Fest 2019. Денис Радин. AAA 3D графика в Web с ReactJS, BabylonJS и Unity3DJS Fest 2019. Денис Радин. AAA 3D графика в Web с ReactJS, BabylonJS и Unity3D
JS Fest 2019. Денис Радин. AAA 3D графика в Web с ReactJS, BabylonJS и Unity3DJSFestUA
 
Responsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebResponsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebHarvard Web Working Group
 
WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...
WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...
WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...AMD Developer Central
 
Towards shipping Ozone/Wayland (BlinkOn 10)
Towards shipping Ozone/Wayland (BlinkOn 10)Towards shipping Ozone/Wayland (BlinkOn 10)
Towards shipping Ozone/Wayland (BlinkOn 10)Igalia
 

Similaire à Korea linuxforum2014 html5game-sangseoklim (20)

Html5 (games)
Html5 (games)Html5 (games)
Html5 (games)
 
(2) gui drawing
(2) gui drawing(2) gui drawing
(2) gui drawing
 
Running HTML5 Mobile Web Games at 60fps
Running HTML5 Mobile Web Games at 60fpsRunning HTML5 Mobile Web Games at 60fps
Running HTML5 Mobile Web Games at 60fps
 
Parallel programing in web applications - public.pptx
Parallel programing in web applications - public.pptxParallel programing in web applications - public.pptx
Parallel programing in web applications - public.pptx
 
New Ranking Metrics by Google
New Ranking Metrics by GoogleNew Ranking Metrics by Google
New Ranking Metrics by Google
 
(2) gui drawing
(2) gui drawing(2) gui drawing
(2) gui drawing
 
#PDR15 - Pebble Graphics
#PDR15 - Pebble Graphics#PDR15 - Pebble Graphics
#PDR15 - Pebble Graphics
 
Овчаренко Євген “Відеоігри це ефективність”
Овчаренко Євген “Відеоігри це ефективність”Овчаренко Євген “Відеоігри це ефективність”
Овчаренко Євген “Відеоігри це ефективність”
 
High Performance Rust UI.pdf
High Performance Rust UI.pdfHigh Performance Rust UI.pdf
High Performance Rust UI.pdf
 
Performance & dev tools
Performance & dev toolsPerformance & dev tools
Performance & dev tools
 
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian BallantyneWT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
WT-4066, The Making of Turbulenz’ Polycraft WebGL Benchmark, by Ian Ballantyne
 
Ustream Techtalks: Google Chrome Developer Tools
Ustream Techtalks: Google Chrome Developer ToolsUstream Techtalks: Google Chrome Developer Tools
Ustream Techtalks: Google Chrome Developer Tools
 
mloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game developmentmloc.js 2014 - JavaScript and the browser as a platform for game development
mloc.js 2014 - JavaScript and the browser as a platform for game development
 
Using JavaScript to write Native Mobile Applications
Using JavaScript to write Native Mobile ApplicationsUsing JavaScript to write Native Mobile Applications
Using JavaScript to write Native Mobile Applications
 
AAA 3D GRAPHICS ON THE WEB WITH REACTJS + BABYLONJS + UNITY3D by Denis Radin ...
AAA 3D GRAPHICS ON THE WEB WITH REACTJS + BABYLONJS + UNITY3D by Denis Radin ...AAA 3D GRAPHICS ON THE WEB WITH REACTJS + BABYLONJS + UNITY3D by Denis Radin ...
AAA 3D GRAPHICS ON THE WEB WITH REACTJS + BABYLONJS + UNITY3D by Denis Radin ...
 
JS Fest 2019. Денис Радин. AAA 3D графика в Web с ReactJS, BabylonJS и Unity3D
JS Fest 2019. Денис Радин. AAA 3D графика в Web с ReactJS, BabylonJS и Unity3DJS Fest 2019. Денис Радин. AAA 3D графика в Web с ReactJS, BabylonJS и Unity3D
JS Fest 2019. Денис Радин. AAA 3D графика в Web с ReactJS, BabylonJS и Unity3D
 
Responsive Design: Building for a Modern Web
Responsive Design: Building for a Modern WebResponsive Design: Building for a Modern Web
Responsive Design: Building for a Modern Web
 
WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...
WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...
WT-4067, High performance WebGL games with the Turbulenz Engine, by Ian Balla...
 
Towards shipping Ozone/Wayland (BlinkOn 10)
Towards shipping Ozone/Wayland (BlinkOn 10)Towards shipping Ozone/Wayland (BlinkOn 10)
Towards shipping Ozone/Wayland (BlinkOn 10)
 
Zoomcharts @ DevClub.lv
Zoomcharts @ DevClub.lvZoomcharts @ DevClub.lv
Zoomcharts @ DevClub.lv
 

Dernier

Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxchumtiyababu
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdfKamal Acharya
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxSCMS School of Architecture
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdfKamal Acharya
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARKOUSTAV SARKAR
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxNadaHaitham1
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueBhangaleSonal
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesMayuraD1
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersMairaAshraf6
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxmaisarahman1
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptDineshKumar4165
 

Dernier (20)

Verification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptxVerification of thevenin's theorem for BEEE Lab (1).pptx
Verification of thevenin's theorem for BEEE Lab (1).pptx
 
Hostel management system project report..pdf
Hostel management system project report..pdfHostel management system project report..pdf
Hostel management system project report..pdf
 
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptxS1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
S1S2 B.Arch MGU - HOA1&2 Module 3 -Temple Architecture of Kerala.pptx
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Online food ordering system project report.pdf
Online food ordering system project report.pdfOnline food ordering system project report.pdf
Online food ordering system project report.pdf
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKARHAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
HAND TOOLS USED AT ELECTRONICS WORK PRESENTED BY KOUSTAV SARKAR
 
Wadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptxWadi Rum luxhotel lodge Analysis case study.pptx
Wadi Rum luxhotel lodge Analysis case study.pptx
 
Double Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torqueDouble Revolving field theory-how the rotor develops torque
Double Revolving field theory-how the rotor develops torque
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
DeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakesDeepFakes presentation : brief idea of DeepFakes
DeepFakes presentation : brief idea of DeepFakes
 
Computer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to ComputersComputer Lecture 01.pptxIntroduction to Computers
Computer Lecture 01.pptxIntroduction to Computers
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptxA CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
A CASE STUDY ON CERAMIC INDUSTRY OF BANGLADESH.pptx
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Thermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.pptThermal Engineering -unit - III & IV.ppt
Thermal Engineering -unit - III & IV.ppt
 

Korea linuxforum2014 html5game-sangseoklim

  • 1. Web Engine-Aware Performace Optimization of HTML5 Games for Mobile Devices Sang Seok Lim (sangseok.lim@sk.com), Director, SK planet
  • 2. Agenda ● Web Engine Internal ● Web Engine Performance Analysis ● HTML5 Game Basics ● Performace Optimization Techniques ● Case study
  • 3. Commercial Use Cases of HTML5 Games ● In-app HTML5 games ○ OK Cashbag Arcade (June, 2014) ○ Syrup Plant Pop (October, 2014) ● In-app means a hybrid app ○ embedded through WebView ○ not for a browser which is incapable of enabling BM ● Goal from the business viewpoint ○ user rentention for keeping/increasing UV of native apps
  • 4. HTML5 Game Architecture Overview ● from the viewpoint of performance, DOM/JavaScript APIs of HTML5 are tightly coupled to underlying SW/HW layers Game Logic (HTML/CSS/JavaScript) Game Engine (JavaScript, WebWorker) DOM/JavaScript API Webview Widget Webkit/Blink Engine Android/iOS HW(ARM CPU, OpenGL ES GPU)
  • 5. Chrome Browser Architecture similar to Chrome Webview
  • 6. HTML5 Game RunTime: WebKit ● Layout/Rendering ○ 2D, 3D graphics by GPU, text rendering ● Sound ○ <audio>, WebAudio ● Physics ○ Javascript engine, JIT, multi-core by WebWorker DOM <canvas> Physics Engine Parser Layout Rendering 2D graphics 3D graphics Text Rendering JavaScript Engine (JIT) multimedia (sound) Game Web engine Platform
  • 8. WebKit Internal: Layout ● Calculate left top, width, height of all DOM nodes contained in a HTML document ● Group a set of DOM nodes then, stack the resultant groups accordingly left, top, width, height ordering layers https://developer.mozilla.org/en-US/docs/Web/Guide/CSS/Understanding_z_index/The_stacking_context
  • 9. Internal Data Structure for Rendering
  • 10. WebKit Internal: Rendering ● DOM Rendering ○ Image + text ○ CSS 2D/3D rendering ■ GPU Acceleration ● 2D graphics ○ canvas/SW ○ canvas/OpenGL ES ● 3D graphics ○ WebGL/OpenGL ES
  • 11. DOM Rendering: Image + Text ● It’s all about handling a image ○ <img> tag represent a image ○ text is broken into a serises of images Penguin P e n g u i n
  • 12. DOM Rendering: CSS2D/3D ● 2D/3D transform matrix rotate scale translate skew
  • 13. DOM Rendering: CSS2D/3D ● RenerLayers are selectively mapped into GPU textures for being rendered by GPU
  • 14. DOM Rendering: CSS2D/3D by HW acceleration ● 2D/3D transform of DOM nodes by GPU Penguin Penguin Penguin Texture generation by CPU Texture based animation by GPU
  • 16. <canvas> Rendering ● 2D primitive ○ path, curve, polygon ○ fill, stroke ○ image manipulation ○ pixel manipulation ● <canvas> primitive HW acceleraton ○ image manipulation ● <canvas> buffer itself is a GPU texture
  • 17. WebGL Rendering ● JavaScript wrapper of OpenGL
  • 18. Compatibility across Mobile Devices ● Not all of the rendering models can be used for mobile devices right now ● Compatibility summary ○ CSS 2D/3D (HW) ■ ICS 4.0 >, iOS 4.0 > ○ canvas (SW) ○ Android 2.3 <= ● canvas (HW) ○ Android 4.0 >, iOS 5.0 > ● WebGL ○ iOS 8.0 > ○ Android L >
  • 19. OS Distribution of Customers OK Cashbag App (June, 2014) the critical defect by Google
  • 20. General Rendering Back-end for Mobile Devices ● <canvas> 2D for Game object rendering ○ HW acceleration ● DOM for Game UI ○ 2D/3D by GPU
  • 21. App-embedded Branded Casual Game ● In-app play for user retention ● No app update via app store
  • 22. <canvas> based Game Development Browser limitations ● Browser engine as a game platform ○ rendering ■ <canvas>, WebGL, DOM ○ sound ■ <audio> ■ WebAudio ○ resource loading ■ XHR/<img> ○ input ■ touchstart, touchmove, touchend ○ DPI management ■ image resource scale up/down
  • 23. <canvas> based Game Development Into Reality ● The limitations of open source game engine ○ only for PC chrome/Firefox ○ does not meet the hard requirements for mobile OS ● In-house game engine development ○ to achieve stable 20 fps on our customer’s device ■ higher is better even on android 2.3 and iOS 5.0 ○ reasonable touch response delay ○ no garbage collection whiling playing ● Further information ○ http://www.slideshare.net/senxation/html5-ok-33344593
  • 24. <canvas> Game Main Loop ● As easy as animation by flipping pages
  • 25. Representaion of Game Objects ● Two approaches ○ static image generation: offline image based ○ dynamic image generation: drawing primitive combination based ● Each approach has its own pros and cons ○ performance ○ design-constraint
  • 26. Image based Object Representation ● A series of sprite image cropping/scaling ○ ctx.drawImage(src, dest) ○ the performance of game is decided by drawImage() ● Static image generation (offline) ○ one for each low, mid, high resolution devices
  • 27. Drawing Primitive Combination ● Dynamic image generation ○ draw an object onto a buffer with the prior knowledge of device DPI, target pixel dimension ○ minimize image scaling during rendering http://simeonvisser.hubpages.com/hub/HTML5-Tutorial-Drawing-Circles-and-Arcs
  • 28. Summary of Pros and Cons ● Image based (offline) ○ overall performance limited by image scaling primitive ○ designer-friendly ● Drawing primitive based (online) ○ higher performance ○ be an enemy to a developer with lower IQ ○ be an enemy to a designer
  • 29. Performance of <canvas> in Detail in WebView for Hybrid App ● The killing bottleneck is “PAINTING” ● Performance challenges ○ no <canvas> HW acceleration: android 2.3, iOS 4.0 ○ Kitkat Chrome Webview’s critical error by Google ■ no HW acceleration on 4.4, 4.4.2 Chrome Webview ■ fixed at 4.4.3 ■ but market share of 4.4.2 in Korea → 65%
  • 30. The Problem Definition when it comes to developing <canvas> game for mobile devices ● Android 2.3 without canvas HW acceleration ○ together with canvas acceleration ● Android /4.4[0-2]/ without canvas HW acceleration
  • 31. Performance Analysis of Kitkat Webview ● To find the performance limiting factors ○ painting size ○ the number of drawing primitive calls ○ DOM tree complexity ● System under test ○ Optimus G Pro (4.4.2) ○ Nexus 5 (4.4)
  • 32. Performan Analysis I ● Partial rendering ○ reuse the content of a previous frame buffer ● Full rendering ○ reset a frame buffer every rendering painting area size fps The Larger, The Slower
  • 33. Performance Analysis II ● Increase the number of painting areas ○ a painting area size is fixed to 25x25 fps the number of painting area
  • 34. Performance Analysis III ● Impact analysis with respect to DOM complexity
  • 35. Performance Analysis V ● Impact analysis with respect to DOM complexity ● Severe fps fluctuation
  • 36. Summary of Performance Analysis ● In proportion to the size of painting area, painting performance (fps) is decreased ● The more complex DOM tree containing <cavas> is, the more severely fps fluctuates
  • 37. Performance Improvement ● 5 practical techniques ○ DOM/<canvas> hybrid rendering for game objects ○ Static object pool for keeping garbage collector asleep ○ Smart repaint by tracing invaldated areas ○ Image resource offline manipulation ○ Minimize a DOM tree complexity ● not all of them are applicable at the same time ○ depending on game scenario, game performance requirement, smart repaint/hybrid rendering can be selectively applicable
  • 38. DOM/<canvas> Hybrid Rendering painting size minimization ● Selectively separate game objects contained in <canvas>, and then paint them through DOM canvas only canvas/DOM Hybrid
  • 39. DOM/<canvas> Hybrid Rendering implementation detail: DOM node pool ● Manage/reuse a set of DOM nodes with a background image of a game object
  • 40. Smart Repaint Repaint Region Trace ● Reuse the content of the frame buffer of n-1 frame for rendering n frame ● Trace the invalidated area, paint only invalidated area
  • 41. Source Image Size Matters A LOT! ● A sprite image is generally used to minimize # of network req ● Performance anomaly ○ the larger the source image is, the slower fps is, even when the destination size is fixed separate
  • 42. Garbage Collector Stops The World ● All objects are allocated from a object pool ● Implementation of a object pool matters ○ single Array, double Array, linked list ○ http://jsperf.com/objectpool-performance-comparison
  • 43. Static Object Pool Performance Comparision ● Single array by Array.push/pop is the best ○ poor performance of Array.spice() ● Complete suppression of GC is impossible
  • 44. Dive into Resolution Issue ● A designer-generated image is scaled up/down 4 times at most implicitly ○ canvas.width, canvas.height ○ canvas.style.width, canvas.style.height ○ ctx.drawImage(source, destination) ○ window.devicePixelRatio ● Try not to scale canvas.width/height, canvas. style.width/height ○ how to adapt device resolution in performant way ○ no fitting/add padding is good for performance ○ sub optimal display for a user
  • 45. <canvas> Isolation ● fps swing around 30% up and down, when <canvas> is contained within a document with complex DOM tree ● Seprate <canvas> from DOM based game UI ○ not easy in the real field where designers/publisher and developers from different teams are co-working
  • 46. Case Study: Flappy Ball ● DOM/<canvas> hybrid ● Smart repaint, sprite image separation
  • 47. 2048 ● DOM/GPU only ● Keeping GPU textures as long as possible
  • 48. Space 2014 ● Radically reuse a previous frame without clearance ○ Android 2.3 ● clearRect/fillRect
  • 49. Closing Remark ● For commercialization on mobile devices, performance matters a lot ○ understading Web-engine internals is essential for developing commercial level game successfully ● open sourced ○ http://skpla.net/bPqc