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

WebGL always gets stuck building player - building native binary with IL2CPP

Discussion in 'WebGL' started by unklebooey1, Apr 13, 2017.

  1. CrandellWS

    CrandellWS

    Joined:
    Oct 31, 2015
    Posts:
    177
    @JoshPeterson not sure what happened but using 2019.4.22f1 seems to be fast building Android apps both apk and Google Play Store bundles when i am build basically just a blank scene...

    In my actual project it is still very slow in both apk and aab builds

    update:
    I was able to get a fast build consistently in my project by remove 3 shaders labeled
    1. Hidden/CubeBlur
    2. Hidden/CubeCopy
    3. Hidden/CubeBlend
    If i reset the `project settings -> Graphics` those remain and / or If i remove them manually everything builds fast... I am not sure why these shaders are added after resetting the graphics options nor why manually removing them sped things up but so did a reset...

    but hey if this keeps up I am good to go

    also the subsequent development build is slow I will see if follow builds after the first development build is also slow once this one finishes...

    so after an hour the development build has finished and the followup with no changes to the project seems to be on the path to be just as slow

    i will kill it and try to manually remove those shaders again...

    So the follow development build finished in 15 minutes with those shaders removed

    and now once again one final try with no changes except disabling the development build option ... will report back
    ok that was 12 minutes and now doing a no change rebuild and checking for time again...
    and that follow up was just over 2 minutes...

    kinda all over the place in the results wish i had a more definitive response but it is what it is
     
    Last edited: Mar 14, 2021
  2. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    @CrandellWS

    Thanks for all of the details.

    As a first question, is the bundle build (which is faster) using the Mono scripting backend instead? Since it is a JIT, it does much less work ahead of time than IL2CPP.

    Second, when the slower builds complete, can you check for a profile.json file in with the generated IL2CPP output (which I believe in the Temp directory for Android builds). This file should indicate what IL2CPP was doing, and how long each step of the process takes. I can analyze it if you send it to me (or you can by using chrome://tracing in Google Chrome).

    Finally, when those clang++ processes seem to be hung, can you check the command line options for them? It would be great to know which generated C++ file they are compiling, and then take a look at the contents of that file to hopefully understand why it takes so long to compile.
     
  3. CrandellWS

    CrandellWS

    Joined:
    Oct 31, 2015
    Posts:
    177
    @JoshPeterson
    So I switched to IL2CPP and therefore no mono is not set to be used as the scripting backend and as far as i know it should not be what is used but either way I do find a `mono` process is invoked when building even when the backend scripting is set to IL2CPP

    I checked the project directory and could not find a file labeled `profile.json` is there some way I need to trigger it's creation during a build?

    how do i check the command line options for the `clang++` processes?

    I will do my best to provide accurate feedback but a little guidance might help thanks.
     
  4. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Yes, sorry, in 2019.4 the profile.json file is not generated by default. You need to run the Unity Editor with an environment variable set: IL2CPP_ADDITIONAL_ARGS="--enable-stats". Then after a successful build, but before the Unity Editor is closed, the profile.json file should be in the Temp/StagingArea/Il2Cpp/il2cppOutput directory.

    If you are on Windows, you can use Process Explorer to do this. On macOS, you can use htop. You may need do install both utilities.
     
  5. CrandellWS

    CrandellWS

    Joined:
    Oct 31, 2015
    Posts:
    177
    @JoshPeterson so I use Ubuntu Linux for all my desktop needs...

    I set an environmental variable in my `.bashrc` file in my home directory and it is definitely set

    upload_2021-3-16_12-37-26.png

    searching the project directory after a build does not find a file named profile.json
    upload_2021-3-16_12-40-47.png

    and in the mentioned folder it is not there: (alphabetically order shows it goes from m to s with no files starting with p )
    upload_2021-3-16_12-41-42.png

    I do have an app called htop but how to get command line options from it is not something i know how to do...
     
  6. CrandellWS

    CrandellWS

    Joined:
    Oct 31, 2015
    Posts:
    177
    Also yet again more inconstancy I got a fast build using the development options... so really at this point I have no clue why it is fast sometimes and not others
     
  7. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    And I'm unsure why the profile.json is not there on your machine. I tired it on macOS with the same version of Unity you are using, and it exists. Maybe there is some Linux-specific issue preventing this from working.

    Regarding htop - at least on macOS it can show a tree of processes with command line arguments for each. You could do the same with ps though, I guess.

    That is probably your best option now - when it is slow, do do ps | grep clang and see what files are taking a long time to compile.
     
  8. CrandellWS

    CrandellWS

    Joined:
    Oct 31, 2015
    Posts:
    177

    well not sure what to do for the profile.json file...

    and I tried to build again with a different scene but it went pretty fast but I will try to remember to capture info using `ps -ax | grep clang` the next time it is slow
     
  9. CrandellWS

    CrandellWS

    Joined:
    Oct 31, 2015
    Posts:
    177
    @JoshPeterson `ps -ax | grep clang` results

    you might need to hit the reply button for this post to see the results...

    Code (csharp):
    1.  
     
  10. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Thanks for the details. I see a number of clang++ processes running there. Usually when a build hangs we see one (or maybe two) long-running processes taking up the time.

    Was this ps pretty early in the build? Or was this after it had hung for a while? And does this build eventually finish?
     
  11. CrandellWS

    CrandellWS

    Joined:
    Oct 31, 2015
    Posts:
    177
    the build did in fact complete successfully

    the only consistent thing at this point seems like when in development mode it is very slow and generally it is faster otherwise

    I suppose if needed I could try again but use a basic blank scene...

    that project has several assets attached to it... I actually ran the `ps -ax | grep clang` command several times through the waiting period and copied it for you to see.... it all mostly looked the same to me so i just copied and pasted it after changing the user and computer name...

    I guess now that i look at it I should have also run the `date` command to show how long it was between the times i entered the command...
     
  12. leegod

    leegod

    Joined:
    May 5, 2010
    Posts:
    2,339
    using 2021.1.1f1, still have this problem, waiting over 1hour 30 mins, does not proceed after Building Player pop up window Building native binary with IL2CPP...
     
  13. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    There could be a number of different issues involved here. Can you follow the step above to try to isolate what specifically is taking a long time? Also, there should be a profile.json file in the generated C++ code folder in the Unity project after the build completes. That file should give us more information about what is happening.
     
  14. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    I am getting this as well - 4 hours build time so far - cannot see any profile json - probably cause its still on building native binary with IL2CPP
     
  15. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    I have a feeling its a shader or the LRP or a combination of shaders and the LRP or something along those lines - just recreating my library folder first then will look at illumination stuff for LRP first and move on from there.
     
  16. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    tried changing some of the shaders but no luck - gonna see if it even finishes building its at 7 hours + right now
     
  17. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    11+ hours and i gave up and was still going - any suggestions to try?
     
  18. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    o snap i removed all the shaders except for 1 from the video shaders portion and that seems to have moved on after only 13 minutes - gonna add 1 by 1 back in
     
  19. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    hmmm everything is pink when the site finishes loading (after the unity logo loading portion)
     
  20. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    annddd its slow again - even removing all the shaders again - yeesh 9 hours and still stuck building native binary
     
  21. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    "C:\Program Files\2020.3.15f2\Editor\Data\il2cpp/build/deploy/netcoreapp3.1/il2cpp.exe" @"artifacts\rsp\9597218057848841659.rsp" seems to be getting stuck on that
     
  22. duartedd

    duartedd

    Joined:
    Aug 1, 2017
    Posts:
    148
    yeesh exclude the dang il2cpp in the AV hasnt been an issue since now
     
  23. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    @duartedd

    So were you able to correct this by excluding IL2CPP from anti-virus?
     
  24. DiscoWarlock

    DiscoWarlock

    Joined:
    May 23, 2020
    Posts:
    7
    Hey @JoshPeterson I'm having the same issue as @duartedd and others. For some reason my builds will sit stuck at IL2CPP, I left one build for over 15 hours and it still didn't budge. I've tried allowing exceptions in my AV but still nothing (I'm using BitDefender).

    When I run windows process explorer this is the line that it appears to be held up on: D:\Unity\2020.3.12f1\Editor\Data\il2cpp/build/deploy/netcoreapp3.1/il2cpp.exe @"artifacts\rsp\9262852920640934459.rsp"

    This has been the only project that hasn't been able to build as a WebGL for me and I'm unable to recreate the issue in other projects, so I'm not sure what's left to try, could it be a custom shader?
     
  25. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    I doubt that it is a custom shader, since IL2CPP does not touch any shader code.

    Can you temporarily disable BitDefender completely? That might help indicate whether or not that is the problem.
     
  26. DiscoWarlock

    DiscoWarlock

    Joined:
    May 23, 2020
    Posts:
    7
    Yeah those were some of my first steps (Disabling BitDefender for one build, then adding exceptions for another, trying deleting Highlight Plus) and each time I would leave a build overnight, so they would run for about 10-11 hours. For some odd reason it builds just fine when I do a cloud build so all is not lost, but just sucks that I can't build it on my own desktop. Any other ideas?
     
  27. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Ok, thanks for confirming that. When the build takes that long, does it actually complete? If so, is there a profile.json file in the Temp/ directory of the project? That might indicate where the time is going.
     
  28. DiscoWarlock

    DiscoWarlock

    Joined:
    May 23, 2020
    Posts:
    7
    No problem. Unfortunately I usually cancel it out since there is usually 0 cpu usage and no matter how long I leave it (longest has been 16 hours). When I check what process is running, it always says it's on this process "D:\Unity\2020.3.12f1\Editor\Data\il2cpp/build/deploy/netcoreapp3.1/il2cpp.exe @"artifacts\rsp\9262852920640934459.rsp"

    But if I take a blank project or one of my earlier games, it compiles and builds for WebGL no problem.
     
  29. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
  30. DiscoWarlock

    DiscoWarlock

    Joined:
    May 23, 2020
    Posts:
    7
    It's usually all on it's own as the only child process from the Bee.exe tree. I can send screenshots of it when I get a chance
     
    JoshPeterson likes this.
  31. DiscoWarlock

    DiscoWarlock

    Joined:
    May 23, 2020
    Posts:
    7
    upload_2021-8-23_11-37-45.png
    Here's a screenshot showing the process tree, as you see, IL2CPP is the only one running with no children
     
  32. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    Thanks for that information. This does look exactly like what we saw with BitDefender running. To confirm though - does this happen with BitDefender completely disabled?

    I mean, can you turn off BitDefender at the system level, not just exclude il2cpp.exe?
     
  33. DiscoWarlock

    DiscoWarlock

    Joined:
    May 23, 2020
    Posts:
    7
    I ran the compiler with BitDefender off and got the same results. I also noticed that every time I play a cloud build of my game it crashes at random parts and throws these errors in the console. Do you think these could somehow be related? upload_2021-8-24_7-5-55.png
     
  34. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    I don't think these errors at run time are related to the compile time hang, but without knowing what causes either, I cannot be sure.

    Can you submit a bug report and include this project? I'm curious to know if this is something we can reproduce on our end. Since it works during cloud build, that may not be the case. But I'm not of other ideas to try now.
     
  35. DiscoWarlock

    DiscoWarlock

    Joined:
    May 23, 2020
    Posts:
    7
    For sure! and yeah I do find it weird that it builds a cloud build but will almost always crash after loading into the first or 2nd level, as I've never faced issues like this in my other WebGL builds.
     
  36. FloAtm

    FloAtm

    Joined:
    Dec 3, 2018
    Posts:
    4
    Hey there! I’m guessing this conversation moved to the ticket. Any chance you found a solution?
     
  37. donotprikel2

    donotprikel2

    Joined:
    Feb 20, 2022
    Posts:
    4
    Same i am on unity 2017,1,2f1 and the first time ive biuld the game on WebGL it glicthes and i cant do any thing. tell me any thing that will help.
     
  38. JoshPeterson

    JoshPeterson

    Unity Technologies

    Joined:
    Jul 21, 2014
    Posts:
    6,773
    If could be caused by a number of different issues. I would recommend that you try a newer version of Unity, 2017 is pretty old - there have been many changes since then.
     
  39. donotprikel2

    donotprikel2

    Joined:
    Feb 20, 2022
    Posts:
    4
    I know the resion i use unity 2017 is becus it loads faster that 2021 that takes 11 minutes to load to the scene from the hub. then it take 1 minute to load the scene witch 2017 loads in 1 minute to almost 30 seconds compared to the 2021 kind. There for thanks for telling me. Æ.Jessie