outernauts from aaa console to aaa flash
play

Outernauts: From AAA Console to AAA Flash Joe Valenzuela Insomniac - PowerPoint PPT Presentation

Outernauts: From AAA Console to AAA Flash Joe Valenzuela Insomniac Games Friday, April 19, 13 Outernauts: From AAA Console to AAA Flash Joe Valenzuela Insomniac Games Friday, April 19, 13 Insomniac Games Friday, April 19, 13 Friday,


  1. Outernauts: From AAA Console to AAA Flash Joe Valenzuela Insomniac Games Friday, April 19, 13

  2. Outernauts: From AAA Console to AAA Flash Joe Valenzuela Insomniac Games Friday, April 19, 13

  3. Insomniac Games Friday, April 19, 13

  4. Friday, April 19, 13

  5. Friday, April 19, 13

  6. Friday, April 19, 13

  7. Basic Info ● Flash/AS3 game client ● LAMP on Amazon (AWS) app servers ● nginx load balancing ● REST based app server ● dbShards with mysql interface Friday, April 19, 13

  8. Terminology Friday, April 19, 13

  9. Tile Friday, April 19, 13

  10. Moby Friday, April 19, 13

  11. flash.display.* DisplayObject Shape Sprite Bitmap MovieClip Friday, April 19, 13

  12. DisplayList Shape MovieClip Bitmap MovieClip Shape Friday, April 19, 13

  13. Outernauts metrics ● 52 production levels ● 5968 assets ● 786 audio files ● 1599 avatar/890 monster animations ● 1240 tiles ● ~150000 LOC (ActionScript3) ● ~20 man-years Friday, April 19, 13

  14. Lessons ● Flash ● Vector DisplayObjects: use judiciously ● Keep DisplayList short & simple ● Idioms reflect scale ● Retain your best practices ● Memory rigor ● Separate simulation vs rendering Friday, April 19, 13

  15. Is-a renderable Sprite GameObj Tile Moby Avatar Monster Pet Friday, April 19, 13

  16. Is-a renderable Sprite GameObj Tile Moby Avatar Monster Pet Friday, April 19, 13

  17. Is-a renderable Sprite GameObj Tile Moby Avatar Monster Pet Friday, April 19, 13

  18. CPU: hotspots ● GC costs ● Stringy ● Flash Anti-Patterns Friday, April 19, 13

  19. Event Mania Playfield ? ? ? GameObj GameObj GameObj Friday, April 19, 13

  20. Event Mania GameObj private function set x(value:Number):void { super.x = value; dispatch(CustomEvent(GameObj.CHANGE_POSITION)); } private function set y(value:Number):void { super.y = value; dispatch(CustomEvent(GameObj.CHANGE_POSITION)); } Friday, April 19, 13

  21. Compulsive Listening Playfield GameObj { GameObj for each (var obj:GameObj in getAllObjects()) obj.addEventListener(GameObj.CHANGE_POSITION, doStuff); } GameObj static public function doStuff(e:Event):void { var gameObj:GameObj = e.target as GameObj; GameObj if (gameObj.isSpecial()) doSomething(gameObj); } GameObj Friday, April 19, 13

  22. Hash addiction Object IsoVec x: -14 “-12,9,-1” 1 y: 10 z: 0 “-13,2,-1” 1 1 “-14,10,0” IsoVec x: -14 y: 10 z: 0 Friday, April 19, 13

  23. Abstractogeddon IoTrackedClass Player IoTrackedField id: 200015 name: Joe Valenzuela name: “xp” value: “576” pets: [ ... ] IoTrackedField xp: 576 level: 5 name: “level” value: “5” IoTrackedField name: “pets” value:[ ... ] Friday, April 19, 13

  24. Abstractogeddon IoTrackedClass Player IoTrackedField id: 200015 name: Joe Valenzuela name: “xp” value: “576” pets: [ ... ] IoTrackedField xp: 576 level: 5 name: “level” value: “5” if (foo["xp"] != oldVal["xp"]) IoTrackedField { oldVal["xp"] = foo["xp"]; name: “pets” value:[ ... ] serialize(foo["xp"]); } Friday, April 19, 13

  25. Memory breakdown 9.4 35.2 ● 300-600MB. Peaks to 1GB. ● Bitmap data ● Flash Runtime data 203.1 175.8 ● Volatility Other (Flash Runtime) Global (XML) Bitmap Exe 16.5 Dynamic Data Friday, April 19, 13

  26. Reducing Memory Volatility ● Object pooling ● Single-threaded scratch space aliasing ● MovieClips (esp offscreen) ● Activation Objects Friday, April 19, 13

  27. Activation Objects ● Capture environment (closures) ● Generated implicitly (try/catch, nested functions) ● Affects code generation Friday, April 19, 13

  28. Activation Objects public function add0(a:int, b:int):int function add0(:int, :int)::int { getlocal0 � return a+b; pushscope � } getlocal1 � getlocal2 � public function add1(a:int, b:int):int add � { returnvalue � function dummy():void { } return a+b; } Friday, April 19, 13

  29. function add1(:int, :int)::int Activation Objects getlocal0 � pushscope � newactivation � dup � setlocal3 � public function add0(a:int, b:int):int pushscope � { getscopeobject � 1 return a+b; getlocal1 � } setslot � 1 getscopeobject � 1 getlocal2 � public function add1(a:int, b:int):int setslot � 2 { getscopeobject � 1 function dummy():void newfunction � no name { coerce � :Function } setslot � 3 getscopeobject � 1 return a+b; getslot � 1 } getscopeobject � 1 getslot � 2 add � returnvalue Friday, April 19, 13

  30. Rendering ● Vector slow/Bitmap fast ● Runtime bitmap conversion ● Better data sharing ● DisplayList too long ● Bitmap background Friday, April 19, 13

  31. Runtime Bitmap Conversion Traditional approach: SpriteSheets Friday, April 19, 13

  32. Runtime Bitmap Conversion Traditional approach: SpriteSheets Friday, April 19, 13

  33. Runtime Bitmap Conversion Hybrid approach: BitmapData Array Friday, April 19, 13

  34. Runtime Bitmap Conversion Hybrid approach: BitmapData Array Friday, April 19, 13

  35. Vector Bitmap CustomizedVector 166ms ● 12 133ms 100ms 66ms 33ms 0 players 32 players 64 players 96 players 128 players Friday, April 19, 13

  36. Bitmap Background Friday, April 19, 13

  37. Bitmap Background ● Aqualos region 0: 2371 tiles Friday, April 19, 13

  38. Bitmap Background ● Aqualos region 0: 434 tiles (82%) Friday, April 19, 13

  39. Bitmap Background ● Required separate simulation state from rendering Friday, April 19, 13

  40. Hybrid Static Vector 30fps 15fps 0fps Bitmapped Background No Bitmapped Background Friday, April 19, 13

  41. Hybrid Static Vector 700mb 350mb 0mb Bitmapped Background No Bitmapped Background Friday, April 19, 13

  42. Hybrid Static Vector 30fps 15fps 0fps Bitmapped Background No Bitmapped Background Friday, April 19, 13

  43. Hybrid Static Vector 600mb 300mb 0mb Bitmapped Background No Bitmapped Background Friday, April 19, 13

  44. Loading ● ~15MB data download ● 3MB client, 1MB global data ● level data, assets ● browser caching ● Content Delivery Network (CDN) ● Aggregated asset loading Friday, April 19, 13

  45. Internet Loading Friday, April 19, 13

  46. Internet Loading { timings: { blocked: 72, dns: -1, connect: -1, send: 0, wait: 37, receive: 1, ssl: -1 } } Friday, April 19, 13

  47. RegionCache: aggregated assets at1_bldg1 aqualos region 0 cache at1_bldg1 at_bubbles at_bubbles at1_deco_27 at1_deco_27 at_bubbles home_deco_41 home_deco_41 Friday, April 19, 13

  48. Aggregated SWF: mxmlc toolchain public class aqualos_regioncache_0 extends Sprite { public const version:int = REGION_CACHE_VERSION; public const num:int = 1; public var swfs:Dictionary = new Dictionary(true); [Embed('home_deco_41.swf', mimeType='application/octet-stream')] private var aqualos_regioncache_0_0:Class; public function aqualos_regioncache_0():void { var class0:Class = new aqualos_regioncache_0_0(); swfs["assets/tiles/home_deco_41.swf"] = ByteArrayAsset(new class0); } } Friday, April 19, 13

  49. Caching Injection loose file home_deco_41 Client Asset Cache Friday, April 19, 13

  50. Caching Injection loose file home_deco_41 Client Asset Cache Asset request Friday, April 19, 13

  51. Caching Injection loose file home_deco_41 Client Asset Cache Asset request loadBytes(loader.bytes) Friday, April 19, 13

  52. Caching Injection aqualos region 0 cache loose file home_deco_41 Client Asset Cache Asset request loadBytes(loader.bytes) Friday, April 19, 13

  53. Loading results 400s 300s 200s 100s 0s Default Cache Alias Cache/Alias Dirty Friday, April 19, 13

  54. Wrap up: Old School still rocks ● Separate simulation/rendering ● Amortized memory allocation ● Eschew strings ● Off-line data processing Friday, April 19, 13

  55. ● mailto: joe@insomniacgames.com ● twitter: @jvalenzu Friday, April 19, 13

  56. Bonus Material! Friday, April 19, 13

  57. Defs Editor Friday, April 19, 13

  58. Tools: WorldBuilder Friday, April 19, 13

  59. Attack of the Clones Instance Override Class id: 688 id: 688 id: 688 name: Zombie Chomp name: Zombie Chomp name: Zombie Chomp type: Phantom type: Phantom type: flying level: 8 level: 8 level: 8 power: 270 power: 440 power: 440 ... ... ... energy: 10 energy: 10 energy: 10 Friday, April 19, 13

  60. Attack of the Clones “Solution” private function getNumberKey(key:String):Number { if (overrides.hasOwnProperty(key)) return overrides[key]; return abilityTagClass[key]; } private function setNumberKey(key:String, value:Number):void { overrides[key] = abilityTagClass[key]; � } public function set accuracy(value:Number):void { setNumberKey("accuracy", MathUtils.clamp(value, 0, 1)); } Friday, April 19, 13

  61. Don’t Panic! ● flash.sampler API ● Interactive/offline tool ● HTML/WebSocket with daemon ● JSON output Friday, April 19, 13

  62. Stats ● MonetDB ● 300e6 rows ● abstract schema: 16 ints ● Stat browsing Friday, April 19, 13

  63. Friday, April 19, 13

Recommend


More recommend