SlideShare uma empresa Scribd logo
1 de 39
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
PRACTICAL GUIDE TO
OPTIMIZATION ON MOBILES
Valentin Simonov
Field Engineer @ Unity Technologies
E-mail: val@unity3d.com
Skype: simonov.valentin
Comment: additional comments were added to slides.
Content shown in live demos is obviously missing.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
Valentin Simonov
Field Engineer @ Unity Technologies
• Work with Unity customers to get
maximum performance from their
games
• Teach Unity
• Translated a book about Unity
• Maintain a few open source projects:
• https://github.com/TouchScript/TouchScript
E-mail: val@unity3d.com
Skype: simonov.valentin
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
OPTIMIZATION
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
while (true)
{
var stuff = FindStuffToOptimize();
if (stuff == null) break;
Optimize(stuff);
}
Comment: in theory optimization loop is that simple. In practice we have such annoying concepts like TIME and MONEY,
so FindStuffToOptimize() function must also consider impact and business value of issues it returns.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
Stuff FindStuffToOptimize()
{
var stuff = …; // ???
return stuff;
}
Comment: so, how should the FindStuffToOptimize function work?
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
Every developer knows where
issues in his code are.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
Every developer knows where
issues in his code are.
Comment: LOL! Of course not. Developers usually know where the code they’d LIKE to optimize is,
but without actual profiling it is impossible to say if this makes sense.
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
SET THE TARGET DEVICE
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
“How do I
optimize my game
on iOS?”
Random Unity Developer
Comment: All phones are very different. The first step must be figuring out what your target device is.
The question “How do I optimize my game on iOS” doesn’t make sense, instead you should ask “How do I make my game run 30 fps
on iPhone 4s?”.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
TEST SCENE
Chinese pool simulator
Comment: next you need a reference scene to base your tests on. This scene must contain 1.5-2x all assets that is possible
to create in your game. For example if you are making a pool simulator game, this is how your test scene should look.
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
TEST AND MEASURE
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
DON’T WASTE TIME!
You must:
1. Know how to use tools to get data from the target device,
2. Have enough knowledge to interpret this data.
Comment: this must be the most important slide. If you are not following this procedure you most likely just wasting time.
This is probably one of the fundamental differences between senior and junior developers. When junior developers encounter an issue
they run around in panic, while senior developers seem to know what they are doing.
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
1. Set the target device
2. Test and measure
3. Know your platform
4. Know your tools
5. Profile on device
6. CPU
7. GPU
8. Memory
9. Project structure
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
KNOW YOUR PLATFORM
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
“Nothing is black and white…”
* Except black and white.
Comment: nothing is ever black and white. You should not blindly do (or not do) things because you were told that they were bad.
Usually it depends…
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
“The trouble with quotes
on the Internet is that
you can never know if
they are genuine.”
Abraham Lincoln
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
DRAW CALLS ARE NOT THE WORST
Comment: static batching in Unity is implemented with several draw calls with no state changes which are fast.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
OVERDRAW IS YOUR ENEMY
Comment: all mobile devices have a maximum number of pixels they can draw a second. Divided by 60 fps and retina resolution
you’ll get a relatively low number. This means that you should really try to avoid drawing fully transparent pixels which get alpha blended.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
Comment: to avoid overdraw you can use more complex
geometry effectively cutting empty space.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
Comment: when you import sprites Unity automatically does this for you. But it doesn’t do it very smart. There are plugins on Asset Store
which do much better job.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
DON’T USE CUTOUT SHADERS
Comment: cutout shaders are bad on mobile GPUs. Here’s a test where I was rendering a fullscreen transparent checkerboard.
Left: transparent shader, right: cutout shader.
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
DON’T MOVE 2D COLLIDERS
• Box2D can’t change colliders, it has to recreate them
• Don’t move 2d colliders
• Only move transforms with Rigidbody2D
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
KNOW WHERE ASSETS LIVE
• There’s native (c++) and managed (c#) memory
• Assets live in native memory
• Managed memory has light wrappers for assets
• myTexture = null; — wrapper is GCd, texture data is stuck
• Destroy(myTexture); — wrapper is stuck, texture data is freed
• Resources.UnloadUnusedAssets(); — destroys stuck assets
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
EXAMPLE: WWW
• WWW www = new WWW(…)
-> allocate buffers
• www.Dispose()
-> release buffers
• GC(?)-> www.~WWW()
-> release buffers
WWW wrapper
WWW data
Managed
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
READ THIS:
• Unity iOS and Android - cross-platform challenges and solutions
http://www.realtimerendering.com/downloads/MobileCrossPlatformChallenges_siggraph.pdf
• Tuning your OpenGL ES app
https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_Programming
Guide/Performance/Performance.html
• Squeezing performance out of your unity gear vr game
https://developer.oculus.com/blog/squeezing-performance-out-of-your-unity-gear-vr-game/
https://developer.oculus.com/blog/squeezing-performance-out-of-your-unity-gear-vr-game-continued/
• Mobile performance tuning: poor man's tips and tricks
http://www.slideshare.net/valentinsimonov/mobile-performance-tuning-48786822
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
KNOW YOUR TOOLS
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
KNOW YOUR TOOLS
• Unity Profiler
• Unity Frame Debugger
• Xcode
• Xcode Frame Debugger
• Instruments
Comment: here a sample game is shown and different tools are used to get relevant data while it’s running on an iPhone.
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
PROFILE ON DEVICE
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
PROFILE ON DEVICE
• Hardware is very different
• Editor uses a different player
• Editor keeps more stuff in memory
• It’s possible to do a lot of unnecessary work
(GetComponent<T>() allocates???!)
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
CPU
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
CPU
• Loading time:
• Resources overhead
• Parsing/loading JSON/XML
• Building cached data
• Downloading bundles
• Instantiating stuff
• Useless calculations:
• Invisible objects
• Empty cameras
• Physics
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
GPU
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
GPU
• Overdraw
• Sprite geometry
• Particle systems (super bad on iPhone4)
• WTF geometry (wrong or totally useless)
• Broken batching
• Shader complexity
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
MEMORY
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
MEMORY
• Garbage in managed memory -> GC lag spikes
• instantiation
• foreach allocates* 40 bytes
• … all the other stuff
• Resources in native memory
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
PROJECT
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
PROJECT
• Multiple JSON/XML parsers
• Multiple tween engines
• Multiple loggers
• Example code
• All this stuff goes into generated IL2CPP code
• Example: 72Mb vs. 64Mb generated code size on test game
COPYRIGHT 2014 @ UNITY TECHNOLOGIES
STUFF WE FOUND
• Loading time:
• 2 seconds to parse JSON
• 3 seconds to generate the list of images from the bundle
• 2 seconds to fill pool of bots
• WWW is not disposed
• Resources overhead
• Empty fullscreen quad
• Broken batching, a lot of overdraw on sprites
• 2D colliders are constantly rebuilt due to animation
• Shaders are too complex
• Text is constantly updated
• Game Over window is very heavy
• foreach loops allocate 40 bytes each
• A lot of unnecessary code
• …
COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES
1. Have you RTFM?
2. Do you know your target device?
3. Are you profiling on device?
4. Are you using the right tools?
5. Are you fixing the right issues?
QUESTIONS?

Mais conteúdo relacionado

Mais procurados

Look Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus MobileLook Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus MobileUnity Technologies
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and PerformanceDevGAMM Conference
 
Best practices: Async vs. coroutines - Unite Copenhagen 2019
Best practices: Async vs. coroutines - Unite Copenhagen 2019Best practices: Async vs. coroutines - Unite Copenhagen 2019
Best practices: Async vs. coroutines - Unite Copenhagen 2019Unity Technologies
 
Tales from the Optimization Trenches - Unite Copenhagen 2019
Tales from the Optimization Trenches - Unite Copenhagen 2019Tales from the Optimization Trenches - Unite Copenhagen 2019
Tales from the Optimization Trenches - Unite Copenhagen 2019Unity Technologies
 
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Unity Technologies
 
Creating A Character in Uncharted: Drake's Fortune
Creating A Character in Uncharted: Drake's FortuneCreating A Character in Uncharted: Drake's Fortune
Creating A Character in Uncharted: Drake's FortuneNaughty Dog
 
Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019
Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019
Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019Unity Technologies
 
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化Unity Technologies Japan K.K.
 
[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in Unity[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in UnityWilliam Hugo Yang
 
2022 COMP4010 Lecture5: AR Prototyping
2022 COMP4010 Lecture5: AR Prototyping2022 COMP4010 Lecture5: AR Prototyping
2022 COMP4010 Lecture5: AR PrototypingMark Billinghurst
 
Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Gerke Max Preussner
 
The Guerrilla Guide to Game Code
The Guerrilla Guide to Game CodeThe Guerrilla Guide to Game Code
The Guerrilla Guide to Game CodeGuerrilla
 
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...Unity Technologies
 
[IGC2018] 청강대 이득우 - 언리얼에디터확장을위해알아야할것들
[IGC2018] 청강대 이득우 - 언리얼에디터확장을위해알아야할것들[IGC2018] 청강대 이득우 - 언리얼에디터확장을위해알아야할것들
[IGC2018] 청강대 이득우 - 언리얼에디터확장을위해알아야할것들강 민우
 
The Next Generation of PhyreEngine
The Next Generation of PhyreEngineThe Next Generation of PhyreEngine
The Next Generation of PhyreEngineSlide_N
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesUnity Technologies
 
NDC 2018 디지털 신원 확인 101
NDC 2018 디지털 신원 확인 101NDC 2018 디지털 신원 확인 101
NDC 2018 디지털 신원 확인 101tcaesvk
 
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationGuerrilla
 
PRESENTATION ON Game Engine
PRESENTATION ON Game EnginePRESENTATION ON Game Engine
PRESENTATION ON Game EngineDiksha Bhargava
 

Mais procurados (20)

Look Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus MobileLook Ma, No Jutter! Optimizing Performance Across Oculus Mobile
Look Ma, No Jutter! Optimizing Performance Across Oculus Mobile
 
Unity Internals: Memory and Performance
Unity Internals: Memory and PerformanceUnity Internals: Memory and Performance
Unity Internals: Memory and Performance
 
Best practices: Async vs. coroutines - Unite Copenhagen 2019
Best practices: Async vs. coroutines - Unite Copenhagen 2019Best practices: Async vs. coroutines - Unite Copenhagen 2019
Best practices: Async vs. coroutines - Unite Copenhagen 2019
 
Tales from the Optimization Trenches - Unite Copenhagen 2019
Tales from the Optimization Trenches - Unite Copenhagen 2019Tales from the Optimization Trenches - Unite Copenhagen 2019
Tales from the Optimization Trenches - Unite Copenhagen 2019
 
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
Developing and optimizing a procedural game: The Elder Scrolls Blades- Unite ...
 
Creating A Character in Uncharted: Drake's Fortune
Creating A Character in Uncharted: Drake's FortuneCreating A Character in Uncharted: Drake's Fortune
Creating A Character in Uncharted: Drake's Fortune
 
Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019
Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019
Refresh what you know about AssetDatabase.Refresh()- Unite Copenhagen 2019
 
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
【Unite Tokyo 2018】実践的なパフォーマンス分析と最適化
 
[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in Unity[UniteKorea2013] Memory profiling in Unity
[UniteKorea2013] Memory profiling in Unity
 
2022 COMP4010 Lecture5: AR Prototyping
2022 COMP4010 Lecture5: AR Prototyping2022 COMP4010 Lecture5: AR Prototyping
2022 COMP4010 Lecture5: AR Prototyping
 
Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4Plug-ins & Third-Party SDKs in UE4
Plug-ins & Third-Party SDKs in UE4
 
Level Design
Level DesignLevel Design
Level Design
 
The Guerrilla Guide to Game Code
The Guerrilla Guide to Game CodeThe Guerrilla Guide to Game Code
The Guerrilla Guide to Game Code
 
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
Unite Berlin 2018 - Book of the Dead Optimizing Performance for High End Cons...
 
[IGC2018] 청강대 이득우 - 언리얼에디터확장을위해알아야할것들
[IGC2018] 청강대 이득우 - 언리얼에디터확장을위해알아야할것들[IGC2018] 청강대 이득우 - 언리얼에디터확장을위해알아야할것들
[IGC2018] 청강대 이득우 - 언리얼에디터확장을위해알아야할것들
 
The Next Generation of PhyreEngine
The Next Generation of PhyreEngineThe Next Generation of PhyreEngine
The Next Generation of PhyreEngine
 
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle GamesWe Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
We Love Performance! How Tic Toc Games Uses ECS in Mobile Puzzle Games
 
NDC 2018 디지털 신원 확인 101
NDC 2018 디지털 신원 확인 101NDC 2018 디지털 신원 확인 101
NDC 2018 디지털 신원 확인 101
 
Taking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next GenerationTaking Killzone Shadow Fall Image Quality Into The Next Generation
Taking Killzone Shadow Fall Image Quality Into The Next Generation
 
PRESENTATION ON Game Engine
PRESENTATION ON Game EnginePRESENTATION ON Game Engine
PRESENTATION ON Game Engine
 

Semelhante a Practical Guide for Optimizing Unity on Mobiles

So You Want to Build a Snowman…But it is Summer
So You Want to Build a Snowman…But it is SummerSo You Want to Build a Snowman…But it is Summer
So You Want to Build a Snowman…But it is SummerIntel® Software
 
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in ActionBill Scott
 
Lean Engineering: How to make Engineering a full Lean UX partner
Lean Engineering: How to make Engineering a full Lean UX partnerLean Engineering: How to make Engineering a full Lean UX partner
Lean Engineering: How to make Engineering a full Lean UX partnerBill Scott
 
Steganography: a tool for community driven development in TerraTech
Steganography: a tool for community driven development in TerraTechSteganography: a tool for community driven development in TerraTech
Steganography: a tool for community driven development in TerraTechRuss Clarke
 
SEARIS 2014 Keynote - MiddleVR - Philosophy and architecture
SEARIS 2014 Keynote - MiddleVR - Philosophy and architectureSEARIS 2014 Keynote - MiddleVR - Philosophy and architecture
SEARIS 2014 Keynote - MiddleVR - Philosophy and architectureSebastien Kuntz
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium IntroNicholas Jansma
 
ITCamp 2011 - Catalin Zima - Common pitfalls in Windows Phone 7 game development
ITCamp 2011 - Catalin Zima - Common pitfalls in Windows Phone 7 game developmentITCamp 2011 - Catalin Zima - Common pitfalls in Windows Phone 7 game development
ITCamp 2011 - Catalin Zima - Common pitfalls in Windows Phone 7 game developmentITCamp
 
Wds leanengineering-141103233017-conversion-gate02
Wds leanengineering-141103233017-conversion-gate02Wds leanengineering-141103233017-conversion-gate02
Wds leanengineering-141103233017-conversion-gate02Shivam Prajapati
 
Unity: What does it take to port a browser title to mobiles
Unity: What does it take to port a browser title to mobilesUnity: What does it take to port a browser title to mobiles
Unity: What does it take to port a browser title to mobilesDevGAMM Conference
 
Appium Native Application Crawler
Appium Native Application CrawlerAppium Native Application Crawler
Appium Native Application CrawlerJustin Ison
 
Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015Dominique Boutin
 
DWX 2013 Nuremberg
DWX 2013 NurembergDWX 2013 Nuremberg
DWX 2013 NurembergMarcel Bruch
 
Programming the Real World: Javascript for Makers
Programming the Real World: Javascript for MakersProgramming the Real World: Javascript for Makers
Programming the Real World: Javascript for Makerspchristensen
 
What new in Android n and Tensor Flow - Updates from Google #IO16
What new in Android n and Tensor Flow - Updates from Google #IO16What new in Android n and Tensor Flow - Updates from Google #IO16
What new in Android n and Tensor Flow - Updates from Google #IO16GBG Mumbai
 
RAD Studio XE5 in Action Tech Preview
RAD Studio XE5 in Action Tech PreviewRAD Studio XE5 in Action Tech Preview
RAD Studio XE5 in Action Tech PreviewSoftline
 
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7Rapid7
 
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023Pedro Vicente
 
How HTML5 missed its graduation - #TrondheimDC
How HTML5 missed its graduation - #TrondheimDCHow HTML5 missed its graduation - #TrondheimDC
How HTML5 missed its graduation - #TrondheimDCChristian Heilmann
 

Semelhante a Practical Guide for Optimizing Unity on Mobiles (20)

So You Want to Build a Snowman…But it is Summer
So You Want to Build a Snowman…But it is SummerSo You Want to Build a Snowman…But it is Summer
So You Want to Build a Snowman…But it is Summer
 
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
6 Principles for Enabling Build/Measure/Learn: Lean Engineering in Action
 
Enabling Lean at Enterprise Scale: Lean Engineering in Action
Enabling Lean at Enterprise Scale: Lean Engineering in ActionEnabling Lean at Enterprise Scale: Lean Engineering in Action
Enabling Lean at Enterprise Scale: Lean Engineering in Action
 
Lean Engineering: How to make Engineering a full Lean UX partner
Lean Engineering: How to make Engineering a full Lean UX partnerLean Engineering: How to make Engineering a full Lean UX partner
Lean Engineering: How to make Engineering a full Lean UX partner
 
Steganography: a tool for community driven development in TerraTech
Steganography: a tool for community driven development in TerraTechSteganography: a tool for community driven development in TerraTech
Steganography: a tool for community driven development in TerraTech
 
SEARIS 2014 Keynote - MiddleVR - Philosophy and architecture
SEARIS 2014 Keynote - MiddleVR - Philosophy and architectureSEARIS 2014 Keynote - MiddleVR - Philosophy and architecture
SEARIS 2014 Keynote - MiddleVR - Philosophy and architecture
 
Appcelerator Titanium Intro
Appcelerator Titanium IntroAppcelerator Titanium Intro
Appcelerator Titanium Intro
 
ITCamp 2011 - Catalin Zima - Common pitfalls in Windows Phone 7 game development
ITCamp 2011 - Catalin Zima - Common pitfalls in Windows Phone 7 game developmentITCamp 2011 - Catalin Zima - Common pitfalls in Windows Phone 7 game development
ITCamp 2011 - Catalin Zima - Common pitfalls in Windows Phone 7 game development
 
Wds leanengineering-141103233017-conversion-gate02
Wds leanengineering-141103233017-conversion-gate02Wds leanengineering-141103233017-conversion-gate02
Wds leanengineering-141103233017-conversion-gate02
 
Is Python still production ready ? Ludovic Gasc
Is Python still production ready ? Ludovic GascIs Python still production ready ? Ludovic Gasc
Is Python still production ready ? Ludovic Gasc
 
Unity: What does it take to port a browser title to mobiles
Unity: What does it take to port a browser title to mobilesUnity: What does it take to port a browser title to mobiles
Unity: What does it take to port a browser title to mobiles
 
Appium Native Application Crawler
Appium Native Application CrawlerAppium Native Application Crawler
Appium Native Application Crawler
 
Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015Dublin Unity User Group Meetup Sept 2015
Dublin Unity User Group Meetup Sept 2015
 
DWX 2013 Nuremberg
DWX 2013 NurembergDWX 2013 Nuremberg
DWX 2013 Nuremberg
 
Programming the Real World: Javascript for Makers
Programming the Real World: Javascript for MakersProgramming the Real World: Javascript for Makers
Programming the Real World: Javascript for Makers
 
What new in Android n and Tensor Flow - Updates from Google #IO16
What new in Android n and Tensor Flow - Updates from Google #IO16What new in Android n and Tensor Flow - Updates from Google #IO16
What new in Android n and Tensor Flow - Updates from Google #IO16
 
RAD Studio XE5 in Action Tech Preview
RAD Studio XE5 in Action Tech PreviewRAD Studio XE5 in Action Tech Preview
RAD Studio XE5 in Action Tech Preview
 
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
The Internet of Fails - Mark Stanislav, Senior Security Consultant, Rapid7
 
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
A Multiplatform, Multi-Tenant Challenge - Droidcon Lisbon 2023
 
How HTML5 missed its graduation - #TrondheimDC
How HTML5 missed its graduation - #TrondheimDCHow HTML5 missed its graduation - #TrondheimDC
How HTML5 missed its graduation - #TrondheimDC
 

Último

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...masabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 

Último (20)

Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 

Practical Guide for Optimizing Unity on Mobiles

  • 1. COPYRIGHT 2014 @ UNITY TECHNOLOGIES PRACTICAL GUIDE TO OPTIMIZATION ON MOBILES Valentin Simonov Field Engineer @ Unity Technologies E-mail: val@unity3d.com Skype: simonov.valentin Comment: additional comments were added to slides. Content shown in live demos is obviously missing.
  • 2. COPYRIGHT 2014 @ UNITY TECHNOLOGIES Valentin Simonov Field Engineer @ Unity Technologies • Work with Unity customers to get maximum performance from their games • Teach Unity • Translated a book about Unity • Maintain a few open source projects: • https://github.com/TouchScript/TouchScript E-mail: val@unity3d.com Skype: simonov.valentin
  • 3. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES OPTIMIZATION
  • 4. COPYRIGHT 2014 @ UNITY TECHNOLOGIES while (true) { var stuff = FindStuffToOptimize(); if (stuff == null) break; Optimize(stuff); } Comment: in theory optimization loop is that simple. In practice we have such annoying concepts like TIME and MONEY, so FindStuffToOptimize() function must also consider impact and business value of issues it returns.
  • 5. COPYRIGHT 2014 @ UNITY TECHNOLOGIES Stuff FindStuffToOptimize() { var stuff = …; // ??? return stuff; } Comment: so, how should the FindStuffToOptimize function work?
  • 6. COPYRIGHT 2014 @ UNITY TECHNOLOGIES Every developer knows where issues in his code are.
  • 7. COPYRIGHT 2014 @ UNITY TECHNOLOGIES Every developer knows where issues in his code are. Comment: LOL! Of course not. Developers usually know where the code they’d LIKE to optimize is, but without actual profiling it is impossible to say if this makes sense.
  • 8. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES SET THE TARGET DEVICE
  • 9. COPYRIGHT 2014 @ UNITY TECHNOLOGIES “How do I optimize my game on iOS?” Random Unity Developer Comment: All phones are very different. The first step must be figuring out what your target device is. The question “How do I optimize my game on iOS” doesn’t make sense, instead you should ask “How do I make my game run 30 fps on iPhone 4s?”.
  • 10. COPYRIGHT 2014 @ UNITY TECHNOLOGIES TEST SCENE Chinese pool simulator Comment: next you need a reference scene to base your tests on. This scene must contain 1.5-2x all assets that is possible to create in your game. For example if you are making a pool simulator game, this is how your test scene should look.
  • 11. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES TEST AND MEASURE
  • 12. COPYRIGHT 2014 @ UNITY TECHNOLOGIES DON’T WASTE TIME! You must: 1. Know how to use tools to get data from the target device, 2. Have enough knowledge to interpret this data. Comment: this must be the most important slide. If you are not following this procedure you most likely just wasting time. This is probably one of the fundamental differences between senior and junior developers. When junior developers encounter an issue they run around in panic, while senior developers seem to know what they are doing.
  • 13. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES 1. Set the target device 2. Test and measure 3. Know your platform 4. Know your tools 5. Profile on device 6. CPU 7. GPU 8. Memory 9. Project structure
  • 14. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES KNOW YOUR PLATFORM
  • 15. COPYRIGHT 2014 @ UNITY TECHNOLOGIES “Nothing is black and white…” * Except black and white. Comment: nothing is ever black and white. You should not blindly do (or not do) things because you were told that they were bad. Usually it depends…
  • 16. COPYRIGHT 2014 @ UNITY TECHNOLOGIES “The trouble with quotes on the Internet is that you can never know if they are genuine.” Abraham Lincoln
  • 17. COPYRIGHT 2014 @ UNITY TECHNOLOGIES DRAW CALLS ARE NOT THE WORST Comment: static batching in Unity is implemented with several draw calls with no state changes which are fast.
  • 18. COPYRIGHT 2014 @ UNITY TECHNOLOGIES OVERDRAW IS YOUR ENEMY Comment: all mobile devices have a maximum number of pixels they can draw a second. Divided by 60 fps and retina resolution you’ll get a relatively low number. This means that you should really try to avoid drawing fully transparent pixels which get alpha blended.
  • 19. COPYRIGHT 2014 @ UNITY TECHNOLOGIES Comment: to avoid overdraw you can use more complex geometry effectively cutting empty space.
  • 20. COPYRIGHT 2014 @ UNITY TECHNOLOGIES Comment: when you import sprites Unity automatically does this for you. But it doesn’t do it very smart. There are plugins on Asset Store which do much better job.
  • 21. COPYRIGHT 2014 @ UNITY TECHNOLOGIES DON’T USE CUTOUT SHADERS Comment: cutout shaders are bad on mobile GPUs. Here’s a test where I was rendering a fullscreen transparent checkerboard. Left: transparent shader, right: cutout shader.
  • 22. COPYRIGHT 2014 @ UNITY TECHNOLOGIES DON’T MOVE 2D COLLIDERS • Box2D can’t change colliders, it has to recreate them • Don’t move 2d colliders • Only move transforms with Rigidbody2D
  • 23. COPYRIGHT 2014 @ UNITY TECHNOLOGIES KNOW WHERE ASSETS LIVE • There’s native (c++) and managed (c#) memory • Assets live in native memory • Managed memory has light wrappers for assets • myTexture = null; — wrapper is GCd, texture data is stuck • Destroy(myTexture); — wrapper is stuck, texture data is freed • Resources.UnloadUnusedAssets(); — destroys stuck assets
  • 24. COPYRIGHT 2014 @ UNITY TECHNOLOGIES EXAMPLE: WWW • WWW www = new WWW(…) -> allocate buffers • www.Dispose() -> release buffers • GC(?)-> www.~WWW() -> release buffers WWW wrapper WWW data Managed
  • 25. COPYRIGHT 2014 @ UNITY TECHNOLOGIES READ THIS: • Unity iOS and Android - cross-platform challenges and solutions http://www.realtimerendering.com/downloads/MobileCrossPlatformChallenges_siggraph.pdf • Tuning your OpenGL ES app https://developer.apple.com/library/ios/documentation/3DDrawing/Conceptual/OpenGLES_Programming Guide/Performance/Performance.html • Squeezing performance out of your unity gear vr game https://developer.oculus.com/blog/squeezing-performance-out-of-your-unity-gear-vr-game/ https://developer.oculus.com/blog/squeezing-performance-out-of-your-unity-gear-vr-game-continued/ • Mobile performance tuning: poor man's tips and tricks http://www.slideshare.net/valentinsimonov/mobile-performance-tuning-48786822
  • 26. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES KNOW YOUR TOOLS
  • 27. COPYRIGHT 2014 @ UNITY TECHNOLOGIES KNOW YOUR TOOLS • Unity Profiler • Unity Frame Debugger • Xcode • Xcode Frame Debugger • Instruments Comment: here a sample game is shown and different tools are used to get relevant data while it’s running on an iPhone.
  • 28. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES PROFILE ON DEVICE
  • 29. COPYRIGHT 2014 @ UNITY TECHNOLOGIES PROFILE ON DEVICE • Hardware is very different • Editor uses a different player • Editor keeps more stuff in memory • It’s possible to do a lot of unnecessary work (GetComponent<T>() allocates???!)
  • 30. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES CPU
  • 31. COPYRIGHT 2014 @ UNITY TECHNOLOGIES CPU • Loading time: • Resources overhead • Parsing/loading JSON/XML • Building cached data • Downloading bundles • Instantiating stuff • Useless calculations: • Invisible objects • Empty cameras • Physics
  • 32. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES GPU
  • 33. COPYRIGHT 2014 @ UNITY TECHNOLOGIES GPU • Overdraw • Sprite geometry • Particle systems (super bad on iPhone4) • WTF geometry (wrong or totally useless) • Broken batching • Shader complexity
  • 34. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES MEMORY
  • 35. COPYRIGHT 2014 @ UNITY TECHNOLOGIES MEMORY • Garbage in managed memory -> GC lag spikes • instantiation • foreach allocates* 40 bytes • … all the other stuff • Resources in native memory
  • 36. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES PROJECT
  • 37. COPYRIGHT 2014 @ UNITY TECHNOLOGIES PROJECT • Multiple JSON/XML parsers • Multiple tween engines • Multiple loggers • Example code • All this stuff goes into generated IL2CPP code • Example: 72Mb vs. 64Mb generated code size on test game
  • 38. COPYRIGHT 2014 @ UNITY TECHNOLOGIES STUFF WE FOUND • Loading time: • 2 seconds to parse JSON • 3 seconds to generate the list of images from the bundle • 2 seconds to fill pool of bots • WWW is not disposed • Resources overhead • Empty fullscreen quad • Broken batching, a lot of overdraw on sprites • 2D colliders are constantly rebuilt due to animation • Shaders are too complex • Text is constantly updated • Game Over window is very heavy • foreach loops allocate 40 bytes each • A lot of unnecessary code • …
  • 39. COPYRIGHT 2014 @ UNITY TECHNOLOGIESCOPYRIGHT 2014 @ UNITY TECHNOLOGIES 1. Have you RTFM? 2. Do you know your target device? 3. Are you profiling on device? 4. Are you using the right tools? 5. Are you fixing the right issues? QUESTIONS?

Notas do Editor

  1. Bla