Tuesday, August 27, 2013

Casual Connect 2013: Technical Challenges of HTML5 Development

by Chris Shankland, Lead Developer, Big Viking Games
·         Tools to use
o    Chrome Developer Tools (turn on the experimental tools). Use the profilers – the data profiler, the heat profiler to track memory leaks, and the canvas inspection tool to look at draw calls.
o    jsperf.com for Javascript performance benchmarking.
o    Crankshaft for optimization profiling.
o    Safari Remote Debugger for mobile devices.
o    Webkit Bugzilla for webkit debugging.
·         Performance techniques
o    Don’t use .eval() since it kills optimization.
o    Try-catch blocks cannot be auto-optimized with Crankshaft.
o    Function calls are expensive especially on iOS, so use inline functions.
o    Branching is expensive.
o    Always use the profile.
·         Memory management
o    Javascript is a garbage collected environment and everything creates garbage ([], {}, new, Object.keys, strings, etc.). Mobile makes memory situation exponentially worse.
o    iOS kills your app if it uses too much memory, but how much memory is arbitrary. It will kill the app anywhere between 200mb to 400mb.
o    ECMAScript specifically disallows you from knowing how much memory you’re using.
o    Solutions – create pools, adopt an “our parameter” convention, use Emscripten-style pre-allocation
·         Asm.js is a subset of Javascript that enforces types by casting and allows for ahead-of-time compiling. It’s currently available in Firefox and is spearheaded by Mozilla.
·         The biggest pro of HTML5 is that it allows developers to patch game without submitting to Apple. It’s cross-platform and enables you to keep game in-sync across platforms. Also, since it’s just Javascript, QA can send stack traces and console dumps to developers easily.
·         Make in-app payments done in native code to make it secure from decompiling.

No comments: