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 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 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
· Make in-app payments done in native code to make it secure from decompiling.