Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Question Any idea why we would be seeing an object Awake called twice on reload (2022.2.3f1)

Discussion in 'Web' started by fwalker, Feb 24, 2023.

  1. fwalker

    fwalker

    Joined:
    Feb 5, 2013
    Posts:
    255
    When we first run the application on WebGL a gameObject's Awake function gets called once as expected. (Just like it does on the Editor)
    Then if we refresh (Chrome) the game runs again and our gameObjects Awake function gets called twice!!

    We cant repo this on Unity Editor (obviously) since there is no refresh.

    And we are at a loss at figuring this one out.

    Does anyone have any ideas of what this might be about Unity 2022.2.3f1
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    7,263
    How do you determine that it runs twice? How do you perform the refresh? There's the F5 and then there's Ctrl+F5. Try both, and different browsers. And double-check (ie via timestamps) that you aren't misreading the logs or the behaviour you see ingame. It could be as simple as manually calling Awake() under some circumstances (I've seen devs do that!).

    If it reliably occurs in other browsers, it's prone to be an issue with the app itself, so be sure to test other browsers.
    But if it only happens in Chrome, it might have to do with Chrome itself or an extension. Be sure to test with a fresh install of Chrome with no additional plugins/extensions installed.