32
Best Practices: Hybrid Mobile Apps Charles Ying Developer @ Flipboard #NativeWeb © 2012

Best Practices: Hybrid Mobile Native + Web Apps

Embed Size (px)

DESCRIPTION

Learn different ways to integrate HTML5 into native apps, what tools you can use, and when to build your own. We'll cover achieving high graphics frame rates, touch responsiveness while conserving battery life. Learn the benefits and tradeoffs of mobile graphics hardware acceleration in animation and emulating native UI in mobile web browsers. We'll also touch on Flipboard's use of HTML5.We'll cover these specific technology areas: WebKit and JavaScriptCore; native view system architecture, animated scene graphs; and hardware accelerated graphics drawing and compositing.

Citation preview

Page 1: Best Practices: Hybrid Mobile Native + Web Apps

Best Practices: Hybrid Mobile Apps

Charles YingDeveloper @ Flipboard

#NativeWeb

© 2012

Page 2: Best Practices: Hybrid Mobile Native + Web Apps
Page 3: Best Practices: Hybrid Mobile Native + Web Apps
Page 4: Best Practices: Hybrid Mobile Native + Web Apps
Page 5: Best Practices: Hybrid Mobile Native + Web Apps
Page 6: Best Practices: Hybrid Mobile Native + Web Apps

Flipboard is a Hybrid App

Page 7: Best Practices: Hybrid Mobile Native + Web Apps

Web App Native AppHybrid App

Simple WrapperWeb UI with

Native API accessJavaScript logic with Native UI

Page 8: Best Practices: Hybrid Mobile Native + Web Apps

Web App Native App

High performance

Native user experience

Rapid development

Instant update

Page 9: Best Practices: Hybrid Mobile Native + Web Apps

Use the best qualities of each technology

Page 10: Best Practices: Hybrid Mobile Native + Web Apps

Don’t emulate native UI

Page 11: Best Practices: Hybrid Mobile Native + Web Apps

Document-oriented content and UI

Varying presentation and layout

Rapidly updated parts

Cross platform parts

Web

Page 12: Best Practices: Hybrid Mobile Native + Web Apps

Native UI

Performance critical parts

Hardware intensive operations

Effects and Animation

Native

Page 13: Best Practices: Hybrid Mobile Native + Web Apps

Bridging Web and Native

Page 14: Best Practices: Hybrid Mobile Native + Web Apps

iOS UIWebView

Native Code JavaScript

URL encoded data

JSON data

• Request queue

• Storing string data in JavaScript global

• Suf!cient for most applications

Page 15: Best Practices: Hybrid Mobile Native + Web Apps

iOS Custom JavaScriptCore

Direct JavaScript Calls

• High performance

• Direct JavaScript object access and bindings

• Ideal for games

Native Code JavaScript

Page 16: Best Practices: Hybrid Mobile Native + Web Apps

Keep integration points simple, loosely coupled

Detect and version features in your native API - degrade gracefully

Avoid making calls in performance hotspots

Bridging Tips

Page 17: Best Practices: Hybrid Mobile Native + Web Apps

Profile before optimizing

Page 18: Best Practices: Hybrid Mobile Native + Web Apps

Always respond to user input

Page 19: Best Practices: Hybrid Mobile Native + Web Apps

Save power: Do fewer, simpler things

Page 20: Best Practices: Hybrid Mobile Native + Web Apps

Build a HTML simulated environment for debugging

Move hotspot areas into native code

See what your JavaScript libraries are doing

Consider what the browser has to draw and composite

Browser bugs

Working with Web Code

Page 21: Best Practices: Hybrid Mobile Native + Web Apps

Aim for 60 FPS

GPU acceleration is key to fast animations and UI

Use CSS3 Animation + Transitions

Watch graphics memory use

Shadows and gradients typically slower CPU operations

Consider compositing and overdraw

Mobile Graphics

Page 22: Best Practices: Hybrid Mobile Native + Web Apps

Existing Frameworks

Page 23: Best Practices: Hybrid Mobile Native + Web Apps

UIWebView bridge PhoneGap, trigger.io

Custom JavaScriptCore Appcelerator

Gaming Spaceport, ImpactJS, CocoonJS

Page 24: Best Practices: Hybrid Mobile Native + Web Apps

Examples

Page 25: Best Practices: Hybrid Mobile Native + Web Apps
Page 26: Best Practices: Hybrid Mobile Native + Web Apps
Page 27: Best Practices: Hybrid Mobile Native + Web Apps
Page 28: Best Practices: Hybrid Mobile Native + Web Apps

CSS3 Cover!ow at 60 FPShttp://www.satine.org/archives/2008/11/06/cover!ow-for-safari-on-iphone/

Sony Video Unlimited for PlayStation 3http://www.satine.org/archives/2011/09/27/playstation-web-app/

Flipboard for iPad and iPhonehttp://!ipboard.com

References to Example Videos

Page 29: Best Practices: Hybrid Mobile Native + Web Apps

Use the best qualities of each technology

Bridge Web and Native code with simple, loosely coupled APIs

Pro"le "rst, be responsive, save power

Consider what your code, libraries, and platform are doing

Use hardware acceleration where possible

Summary

Page 30: Best Practices: Hybrid Mobile Native + Web Apps

“Is it a web app or a native app?”

Page 31: Best Practices: Hybrid Mobile Native + Web Apps

It’s a great user experience