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. Dismiss Notice

Question Game works in Editor, crashes in build instantly

Discussion in 'Editor & General Support' started by Lewsk55, Mar 22, 2022.

Thread Status:
Not open for further replies.
  1. Lewsk55

    Lewsk55

    Joined:
    May 22, 2021
    Posts:
    11
    I just upgraded to Unity 2021.2.16f1 (I previously built the game in Unity 2020.3.25). My game works great in Editor and I'm able to create the build successfully. But as soon as I run the exe (I'm on Windows 10) the build crashes instantly before the Unity splash screen appears. I found the crash log -- see below -- but I'm not 100% sure what to take away from this.

    To date I've tried rebuilding the library, but that didn't work either. I didn't experience any build crashes when I was working in Unity 2020.3.25. Help! Any ideas would be much appreciated.

     
    Last edited: Mar 23, 2022
  2. Lewsk55

    Lewsk55

    Joined:
    May 22, 2021
    Posts:
    11
    Pinging here again -- any ideas from the Unity support folks? Looks like "<RI> Initialized touch support" is the last item in the log before the crash occurs. Does that mean the input system is causing the build to crash?

    I've been working on this game for the past six months and I'm at a standstill at the moment. Any tips would be massively appreciated! thanks
     
  3. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    One approach, granted can be a bit tedious, would be divide-and-conqueror. Create a new/empty project, build and run on the device. Confirm that it works. Then add your game components one by one, repeating the process.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,505
    Could you also upload the files from the crash folder? The path is in the last line of the log you pasted.
     
  5. Lewsk55

    Lewsk55

    Joined:
    May 22, 2021
    Posts:
    11

    Attached Files:

  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,505
    Thanks for that. This is a bug that we've seen internally too, but we have yet to find a reliable reproduction project. Since you found a pretty reliable way to reproduce it, would you by any chance be able to report a bug on this and send us your project? You can do so by pressing Help -> Report a bug in the editor.

    There's the issue tracker link for this bug: https://issuetracker.unity3d.com/product/unity/issues/guid/1412776/ (I just made it public, might take a little bit to show up).

    This issue is related to loading a particular shader. To find a workaround, I'd suggest doing a binary search on objects in your initial scene to see which one is triggering it.
     
  7. Lewsk55

    Lewsk55

    Joined:
    May 22, 2021
    Posts:
    11
    @Tautvydas-Zilys oh interesting will look into the issue tracker once its live. I gave up on this and went back to Unity 2020 for now, but will report the bug and try the workaround you recommended -- performance and the visuals are improved in Unity 2021 so I'm hoping to make this work. Thanks!
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,505
    The issue tracker link unfortunately won't contain too much information, as we only saw this crashing but didn't get enough details to understand it yet.
     
  9. Lewsk55

    Lewsk55

    Joined:
    May 22, 2021
    Posts:
    11
    @Tautvydas-Zilys bug report submitted! I also included a full test build since the crash happens every time on my end (at least on my computer). Hopefully that helps you all to replicate the issue.

    Question -- could you elaborate on this: "To find a workaround, I'd suggest doing a binary search on objects in your initial scene to see which one is triggering it." Not 100% sure if I know what you mean.

    For what its worth, I deactivated every object in my test scene except the camera and skybox and exported a new build, but the same error happened.
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,505
    Do you happen to have the case number (just the 7 digits, not a full link)?

    That is very weird, I didn't expect it. I had assumed a particular object in the scene was causing the issue. Can you try creating an empty scene in your project and seeing if it happens with that?
     
  11. Lewsk55

    Lewsk55

    Joined:
    May 22, 2021
    Posts:
    11
    The case number is 1415447.

    I just created an empty scene in my project (I used the Default URP scene) and created a new build. Unfortunately, I got the same error/crash log that I included in my first post at the top of this thread. Weird...
     
  12. pool3

    pool3

    Joined:
    Mar 11, 2015
    Posts:
    8
    Hi! We're having exactly the same problem, are there any updates on this? Unity 2021.3.0 LTS
     
  13. pool3

    pool3

    Joined:
    Mar 11, 2015
    Posts:
    8
    I'd also be interested in how to do this binary search, any advice?
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,505
    1. Backup your project.
    2. Scene half of the objects from your scene. Check if the issue still reproduces.
    3. If it does, go to step 2
    4. If it doesn't, restore from backup and delete the other half of the scene.
    5. Repeat until you have the smallest scene that reproduces the issue.
     
    pool3 likes this.
  15. pool3

    pool3

    Joined:
    Mar 11, 2015
    Posts:
    8

    Allright, thanks.

    In the meantime, I can confirm that this is PC specific in our case, on some of my team's computers this happens in a build, on others it doesnt (same build used everywhere).
     
  16. Lewsk55

    Lewsk55

    Joined:
    May 22, 2021
    Posts:
    11
    @Tautvydas-Zilys thanks for explaining the binary search. Like I mentioned above though, the same build crash still occurs even when I create a build with a 100% empty scene. Any suggestions?
     
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,505
    Do you happen to have anything in "Always included shaders" setting?
     
  18. flintcheeze

    flintcheeze

    Joined:
    Sep 10, 2015
    Posts:
    80
    Mehn I am here again no solution to my problem, android build crashes immediately but when I build a new project add IAP, Unity Ads and play services it builds fine
    What the heck is happening
     
  19. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,769
    What does the
    adb logcat
    output tell you?

    You must find a way to get the information you need in order to reason about what the problem is.

    Once you understand what the problem is, you may begin to reason about a solution to the problem.

    What is often happening in these cases is one of the following:

    - the code you think is executing is not actually executing at all
    - the code is executing far EARLIER or LATER than you think
    - the code is executing far LESS OFTEN than you think
    - the code is executing far MORE OFTEN than you think
    - the code is executing on another GameObject than you think it is
    - you're getting an error or warning and you haven't noticed it in the console window

    To help gain more insight into your problem, I recommend liberally sprinkling
    Debug.Log()
    statements through your code to display information in realtime.

    Doing this should help you answer these types of questions:

    - is this code even running? which parts are running? how often does it run? what order does it run in?
    - what are the values of the variables involved? Are they initialized? Are the values reasonable?
    - are you meeting ALL the requirements to receive callbacks such as triggers / colliders (review the documentation)

    Knowing this information will help you reason about the behavior you are seeing.

    You can also supply a second argument to Debug.Log() and when you click the message, it will highlight the object in scene, such as
    Debug.Log("Problem!",this);


    If your problem would benefit from in-scene or in-game visualization, Debug.DrawRay() or Debug.DrawLine() can help you visualize things like rays (used in raycasting) or distances.

    You can also call Debug.Break() to pause the Editor when certain interesting pieces of code run, and then study the scene manually, looking for all the parts, where they are, what scripts are on them, etc.

    You can also call GameObject.CreatePrimitive() to emplace debug-marker-ish objects in the scene at runtime.

    You could also just display various important quantities in UI Text elements to watch them change as you play the game.

    If you are running a mobile device you can also view the console output. Google for how on your particular mobile target, such as this answer or iOS: https://forum.unity.com/threads/how-to-capturing-device-logs-on-ios.529920/ or this answer for Android: https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/

    Another useful approach is to temporarily strip out everything besides what is necessary to prove your issue. This can simplify and isolate compounding effects of other items in your scene or prefab.

    Here's an example of putting in a laser-focused Debug.Log() and how that can save you a TON of time wallowing around speculating what might be going wrong:

    https://forum.unity.com/threads/coroutine-missing-hint-and-error.1103197/#post-7100494

    When in doubt, print it out!(tm)

    Note: the
    print()
    function is an alias for Debug.Log() provided by the MonoBehaviour class.
     
  20. savejais

    savejais

    Joined:
    Mar 6, 2020
    Posts:
    4
    I seem to have had the same problem

    There was one button that, for whatever reason, didnt display text, once i deleted it, my game got built and ran with no problems

    This particular button was one of 4 menu buttons, and only difference between it was that it used a different image.
    2048x1024 RGB Compressed DXT1 UNorm 1.0MB, texure type sprite, and i didnt touch anything else in settings

    other buttons used image 1024x1024 RGBA Compressed DXT5 UNorm 1.0MB

    Once i changed to image to some other, everything worked fine but the text still was not showing on the button.
    I tried changing image to one of unbroken buttons to the same image i used on the broken one, and removing the broken button - my game was still working fine.

    Finally found that the text that was not showing had some material on it, not sure what, because there was a text "Type mismatch", after setting text matterial to none, text appeared and everything was working fine, even with the image that it didnt work with before.

    Hope it helps
     
  21. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,769
    This can happen when you make a script with some public variable, such as:

    Code (csharp):
    1. public Texture2D FoobarButton;
    You drag a Texture2D in there, you save your scene.

    Tomorrow you say "Oh I should use UI, that requires a Sprite, I already imported that texture as a sprite, I'll just retype the variable in code:

    Code (csharp):
    1. public Sprite FoobarButton;
    You look in the inspector. Looks great! There's my picture.

    You run. Type mismatch. The key is you need to drag the Sprite in to replace the field that had a Texture2D. Because the variable name didn't change, the old Texture2D is still saved and cannot be coerced into a Sprite.
     
  22. SJR_Team

    SJR_Team

    Joined:
    Jul 2, 2020
    Posts:
    1
    I have the same Issue.

    Still no solution?
     
  23. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,769
    Do you mean another solution than the one I posted?

    You did read ALL the responses before necro-spamming the thread, correct?

    I'll highlight the answer for you again:

     
Thread Status:
Not open for further replies.