Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
1
Question by RobAnthem · Jun 05, 2019 at 07:47 PM · awakereflections

Are the Awake functions not run on the main thread?

I ask this because I had an issue where I was getting a massive 2000-20000ms spike a few seconds AFTER the game would start, in fact I could even move around a bit first. Now after some profiling I realized this was caused by the Realtime Reflection Probes and their Update mode being OnAwake. Now I was always under the impression that Awake functions ran consecutively on the main thread, as it enabled each active object. So why then, does the reflection probe Awake update happen seconds after I am already able to move around? I would think it would happen when everything else initializes and that this spike would occur during the initial loading process. What am I missing here?

Comment
Add comment
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

1 Reply

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

Answer by Bunny83 · Jun 05, 2019 at 08:16 PM

Awake is called on the main thread, otherwise you wouldn't be able to use any Unity API in that callback. Awake is usually called immediately after an object is created. However since the reflection probe are built in native components they are not bound to the managed scripting rules. "OnAwake" could mean anything since the component is actually handled on the native C++ side. Though such a long delay would be unusual. I haven't used the reflection probes yet so i can't say anything about them. Did you do a deep profile?


According to this the refresh mode OnAwake will update the probes at "start". Since they explicitly mention that this is useful for dynamically setup environments, the actual update can not be done during the managed Awake callback since you wouldn't have any time to setup anything dynamically. Awake is actually called before anything ever get rendered. However the reflection probes actually need to render the scene. So it most likely will do the update shortly after Start.


You could use the refresh mode "Via Scripting" and develop your own update procedure for the probes and see if it helps.

Comment
Add comment · Show 1 · 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
avatar image RobAnthem · Jun 05, 2019 at 08:55 PM 0
Share

That makes a lot of sense, not sure why I didn't think about the fact the scene needs rendered BEFORE it can create reflection probe data. Also I guess the reason for the spike, and this is with profiling I discovered it, is that when reflection probe data is being constructed, it has to render all the effect objects at once, and I had a VERY complex scene with a lot of reflection probes. According to the profiler, it was basically rendering more than my computer was capable of handing, locking it up until it was able to complete the process. What bothered my was that it happened AFTER my play could move around, but I realize that Baked probes was more adequate for what I wanted, and they seem to have very little overhead and no runtime setup cost.

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

107 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 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 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 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

instatiation order of events 1 Answer

Adding a function to update 1 Answer

Do I have to check for null value before assigning a variable in Awake()? 1 Answer

How to init disabled canvas properly 1 Answer

GetComponentInChildren returns null during Awake() 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