Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by manny003 · Nov 06, 2014 at 02:05 PM · mobileperformancedrawcalls

Using an instantiated pooled object for the first time causes frame drop

I have a strange situation where when I show a game object on screen for the first time, like a small explosion, particle, object with attached lens flare, etc the frame rate drops for a split second causing touch control response issues.

If it were a card game, it wouldn't matter much but -- for an action, response sensitive game, it's a total kill joy cause the player loses a life for no reason and that's no fun.

Here's the kicker, it only happens the first time that object is put into play. Because after that, when that object is activated again from the pool, there is no stall at all.

These are all small, pre-instantiated, pooled object -- mostly simple particles or 2d explosions which only uses quads so it's not like I'm suddenly adding thousands is tris to the rendering engine.

My draw calls is also very low. On average it the game coasts along with 9 or 10 draw calls per frame. So when I make alive a pooled particle system or 2d explosion with attached lens flare -- I'm only adding, at most, 1 to 3 draw calls for a whopping total of ~13 draw calls. I did not think that was too much to handle.

I've double check to ensure that I am indeed using pooled objects and that the object scripts has no heavy duty code that does any major resource loading or doing any complex computations. By all measures, these are very light weight objects.

Again, it only happens the first time I use one of those pooled objects. All other subsequent uses has no issues at all.

This happens both in the Unity Editor play mode as well as in my final build running on iPad.

I tried using the Profiler on the trial license but could not find anything and now that trial has expired.

What's going on?

Manny

Comment
Add comment · Show 10
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image troien · Nov 06, 2014 at 02:17 PM 0
Share

Do you have anything going on in the Start method of any of your scripts? Because the Start method is only called the first frame the script is enabled. Therefore, if you instantiate it in a pool disabled and then enable it at a later time, the Start gets called when you enable them. If this is the case, maybe using Awake helps, since this is called even when disabled. Which means the hickup will happen at initializing the pool as intended.

avatar image _dns_ · Nov 06, 2014 at 03:36 PM 0
Share

Hi, this may be because Unity loads some resources (from disk) when you instantiate the first object. Some pooling system include a "preload" option to remove this effect.

There should be some free pooling system you can check or search for "pooling" and "preload".

avatar image manny003 · Nov 06, 2014 at 03:46 PM 0
Share

I am not using any pooling plugins. I wrote my own by simply by Instantiating a gameObject and pushing it onto a stack on level load. That is it.

There is code on my object's Start() method but I allow it to run when instantiating and at the end, I do a SetActive(false). I've confirmed, via Debug.Log, that Start() is not executing when I use a pooled object.

I'm not able to find anything about pooled object "pre-loading" -- can you reference a blog or article for me?

Thanks, $$anonymous$$anny

avatar image manny003 · Nov 06, 2014 at 03:53 PM 0
Share

A thought: When I instantiate by pooled objects, I usually but it off screen at (-1000, -1000, -1000).

The material texture used by my pooled objects, is it loaded into GPU memory upon instantiating or only when it first appears on the screen?

$$anonymous$$anny

avatar image Yokimato · Nov 06, 2014 at 03:58 PM 0
Share

That's a good thought. Unity may be doing some unwanted optimization for you since it's not visible. I don't have any documentation to point to, but it's definitely worth googling for.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by manny003 · Nov 06, 2014 at 08:45 PM

Well, well, well, what do ya know ...

http://ralphbarbagallo.com/2012/07/23/how-to-prevent-performance-spikes-in-unity3d-when-a-model-is-first-visible/

Thanks to dns for pointing me in the right direction.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

31 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity 4.6 GUI vs NGUI Performances (mobile and pc) 1 Answer

Vertices limit for iOS? 0 Answers

Efficient way of having 1 draw call but allowing for debris physics [Mobile] 1 Answer

Help with performance 1 Answer

Many draw calls w\ low verts VS little draw calls w\ lots of verts 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges