Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

My game keeps crashing. Why?

Discussion in 'Editor & General Support' started by JuhJuhButt, Apr 13, 2021.

  1. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    I've tried rebuilding (a billion times), building for x86, rebooting my computer (twice), and excluding unfinished scenes from build. The game appears to still be running when I rebuild, and I have to end the UnityCrashHandler task from task manager. What else could be a possible solution?

    P.S. I just tested: an older build doesn't work (but I'm pretty sure it's because I can't connect to Discord right now, and it checks my rights to run the game via Discord GameSDK) and running it in play mode in the editor crashes Unity entirely, forcing me to reopen the project via Unity Hub. It's likely some other program blocking it, but I couldn't imagine what.
     
  2. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    Alright, I did a little more digging. Playing Settings.unity from the editor works fine, it's only MainMenu.unity (index 0 in build settings) that's acting up. I'll look further into what's going on.
     
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,920
    Always start with the logs. They may contain crucial information.
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'm unclear about what your problem is. Is the problem while building, or while running the build? If it is crashing, then it should have something in the logs. If it is still running, that doesn't sound like a crash though. Are you sure you didn't mean it is freezing? A freeze is usually caused by an infinite loop somewhere in your code.
     
  5. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    I have debugged this scene to the moon and back. I have removed *every single GameObject* and it still crashes the game or editor. At that point, I figured maybe there was something wrong with the scene itself, not its hierarchy, and so I deleted the scene, made a new one, copied over the main parent GameObject, and played it, and the editor crashed.


    That's one of the first things I found in my initial Google search; the player logs don't show anything useful, just some tech specs and XInput initializing. I checked editor logs too, but those didn't contain much substance besides some packages not loading then being loaded later as well as Android and OSXStandalone modules not being found, but I'm not worried about that as I'm currently building for Windows Standalone.


    I apologize for not being clearer; the issues occur when running the built game or entering play mode from the editor. The consequences, respectively, are the game exiting upon initialization or the editor completely closing (When I reopen the project, Unity Hub doesn't say that the editor is already running). It's possible that there may be an infinite loop, but off the top of my mind the only loop in my code is `Update()` from MonoBehaviour, I don't even use coroutines or anything yet. Aside from checking my code (which I intend to do), is there any other way of debugging it and finding the cause of the problems?

    Thank you all for your help.
     
    Last edited: Apr 14, 2021
  6. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    Joe-Censored, I have checked my scripts as per your suggestion that it could be an infinite loop in my code. As far as I can tell, there's nothing that should be endlessly running in without a player exploiting something, meaning there isn't anything that could quit the game upon opening it.

    Now that I think of it, I do recall recently adding a plugin for serialization. It's open-source at https://github.com/neuecc/MessagePack-CSharp, but it doesn't seem that anyone else is having the same issue on Windows.
     
  7. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Does this happen in a new project?
     
    Joe-Censored likes this.
  8. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    No; the described behaviour is not present in a fresh project with the same scene and assets relevant to it.
     
    Last edited: Apr 14, 2021
  9. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I'm still not clear if you're referring to a freeze, where the application stops responding but stays up, or a crash, where the application unexpectedly exits.
     
  10. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    Standalone build: game exits (but UnityCrashHandler keeps running until its task is ended)
    Unity editor play button: Unity exits
     
  11. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    What are the last lines in the Editor log immediately after this happens?
     
  12. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    funny story. When I deleted the test project to achieve that conclusion, somehow I deleted my actual project too. After restoring it from recycle bin (thank god for that thing) and resolving a few GUID conflicts from previously deleted/renamed files, the scene works perfectly fine.

    Thanks again for all your help; I apologize to anyone coming here in the future and not being able to find a solution aside from deleting and restoring your project.
     
    Last edited: Apr 15, 2021
  13. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    not sure if this is the latest or if its what was wrong before but here it is:

    [Package Manager] Server::Kill -- Server was shutdown
    ##utp:{"type":"MemoryLeaks","version":2,"phase":"Immediate","time":1618471472903,"processId":9284,"allocatedMemory":501187,"memoryLabels":[{"Default":-3084},{"NewDelete":122082},{"Thread":167},{"Manager":2584},{"Texture":152},{"GfxDevice":210584},{"Physics":1},{"Serialization":40},{"File":16912},{"WebCam":72},{"String":44844},{"DynamicArray":28466},{"HashMap":23248},{"UTF16String":42},{"Utility":400},{"Curl":-1728},{"PoolAlloc":176},{"Sprites":8},{"GI":336},{"VR":1888},{"Secure":2024},{"Subsystems":96},{"EditorGui":2056},{"EditorUtility":3200},{"AssetDatabase":5498},{"AssetImporter":32},{"RestService":144},{"License":10656},{"UnityConnect":26368},{"Collab":779},{"Licensing":3144}]}
     
  14. Madgvox

    Madgvox

    Joined:
    Apr 13, 2014
    Posts:
    1,315
    Should look into using some kind of source control.
     
    Kurt-Dekker and Vryken like this.
  15. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,779
    Seriously, it is 2021. Use source control. If it's worth doing, it's worth backing up.

    Personally I use git because it is free and there are tons of tutorials out there to help you set it up.

    Here's how I use git in one of my games, Jetpack Kurt:

    https://forum.unity.com/threads/2-steps-backwards.965048/#post-6282497

    Using fine-grained source control as you work to refine your engineering:

    https://forum.unity.com/threads/whe...grammer-example-in-text.1048739/#post-6783740

    Share/Sharing source code between projects:

    https://forum.unity.com/threads/your-techniques-to-share-code-between-projects.575959/#post-3835837

    Setting up the right .gitignore file:

    https://forum.unity.com/threads/removing-il2cpp_cache-from-project.1084607/#post-6997067
     
  16. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    I am; I just hadn't committed/pushed the latest changes.
     
    Madgvox likes this.
  17. JuhJuhButt

    JuhJuhButt

    Joined:
    Sep 18, 2020
    Posts:
    10
    Thanks, I'm already using GitHub (you can check out my personal profile JuhJuhButts, I'm a big open-source advocate ). Nonetheless, I'll take a look at these resources.
     
  18. DearUnityPleaseAddSerializableDictionaries

    DearUnityPleaseAddSerializableDictionaries

    Joined:
    Sep 12, 2014
    Posts:
    135
    Did you find out what was the cause of your crash? Was it because of Discord Game SDK?