game-ci / unity-orb

Build and test Unity projects for several platforms using CircleCI.
https://circleci.com/developer/orbs/orb/game-ci/unity
MIT License
7 stars 12 forks source link

Building Unity Project Times Out #30

Closed Renanse closed 1 year ago

Renanse commented 1 year ago

Orb version:

1.1.0

What happened:

I am building an Android project with Unity 2021.3.6f1 at CircleCI. The framework terminates the job due to no output after 10 minutes.

Starting: /opt/unity/Editor/Data/Tools/netcorerun/netcorerun "/opt/unity/Editor/Data/PlaybackEngines/AndroidPlayer/AndroidPlayerBuildProgram.exe" "/opt/unity/Editor/Data/PlaybackEngines/AndroidPlayer/Bee:/opt/unity/Editor/Data/Tools/BuildPipeline" "Library/Bee/Player01afee0d.dag.json" "Library/Bee/Player01afee0d-inputdata.json" "Library/Bee/buildprogram2.traceevents"
WorkingDir: /root/project/android/unity_build
ExitCode: 0 Duration: 1s499ms
Starting: /opt/unity/Editor/Data/bee_backend --profile="Library/Bee/backend_profiler3.traceevents" --stdin-canary --dagfile="Library/Bee/Player01afee0d.dag" --continue-on-failure --dagfilejson="Library/Bee/Player01afee0d.dag.json" Player
WorkingDir: /root/project/android/unity_build
++++ trap_build_script_exit
++++ exit_status=0
++++ set +x
Compressing build artifacts...

Too long with no output (exceeded 10m0s): context deadline exceeded

It appears CircleCI supports customizing this timeout, but it must be passed through by the orb. See also: https://discuss.circleci.com/t/how-to-handle-no-output-timeout-in-orb-command/44934/2

Expected behavior:

Should build, or provide a way around the timeout.

EricRibeiro commented 1 year ago

Hi, @Renanse 👋

Thank you for opening this issue.

Per your output, Unity's build command finishes its execution. If the following is the last message you see, what is hanging is the compression step:

Compressing build artifacts...

Can you try running the job with compress: false? Also, what Executor are you using?

Renanse commented 1 year ago

Thank you for the follow-up! Great spot on the compress. That actually does not show up until the process finally times out. In the circleci interface it shows this up until canceling:

Starting: /opt/unity/Editor/Data/bee_backend --profile="Library/Bee/backend_profiler3.traceevents" --stdin-canary --dagfile="Library/Bee/Player01afee0d.dag" --continue-on-failure --dagfilejson="Library/Bee/Player01afee0d.dag.json" Player
WorkingDir: /root/project/android/unity_build

But perhaps that is the result of some output buffering or something like that? I will give disabling compression a shot.

Here's a snippet of my config, with executor and such:

jobs:
  build-unity-android:
    working_directory: "~/project/android/unity_build"
    executor: 
      editor_version: 2021.3.6f1
      name: unity/ubuntu
      resource_class: large
      target_platform: android
    steps:
      - sync-submodules
      - unity/prepare-env:
          unity-password-var-name: UNITY_PASSWORD
          unity-serial-var-name: UNITY_SERIAL
          unity-username-var-name: UNITY_USERNAME
      - unity/build:
          step-name: Building KSTV in Unity for Android
          build-target: Android
          project-path: .
      - persist_to_workspace: 
          root: "./Builds/android/"
          paths:
            - UnityBuild/
Renanse commented 1 year ago

Turning off compression did not fix the issue. Note how there is no ExitCode immediately before the trap_build_script_exit? I believe that run of bee_backend is exceeding the 10minute timeout, perhaps indicating something else is wrong in general with my build because outside of running it here, these commands all take a handful of seconds tops. (e.g. on Unity Cloud Build, etc.)

Starting: /opt/unity/Editor/Data/Tools/netcorerun/netcorerun "/opt/unity/Editor/Data/PlaybackEngines/AndroidPlayer/AndroidPlayerBuildProgram.exe" "/opt/unity/Editor/Data/PlaybackEngines/AndroidPlayer/Bee:/opt/unity/Editor/Data/Tools/BuildPipeline" "Library/Bee/Player01afee0d.dag.json" "Library/Bee/Player01afee0d-inputdata.json" "Library/Bee/buildprogram2.traceevents"
WorkingDir: /root/project/android/unity_build
ExitCode: 0 Duration: 1s335ms
Starting: /opt/unity/Editor/Data/bee_backend --profile="Library/Bee/backend_profiler3.traceevents" --stdin-canary --dagfile="Library/Bee/Player01afee0d.dag" --continue-on-failure --dagfilejson="Library/Bee/Player01afee0d.dag.json" Player
WorkingDir: /root/project/android/unity_build
++++ trap_build_script_exit
++++ exit_status=0
++++ set +x

Too long with no output (exceeded 10m0s): context deadline exceeded
EricRibeiro commented 1 year ago

Got it. Thanks for trying and sharing your config! Any chance you can share the full output in Pastebin or somewhere like that? If you can, remember to redact your license.

I'll publish a developer version of the orb with the no_output_timeout parameter and share it here for you to try and check if it fixes the issue. I'm not super hopeful because of this:

these commands all take a handful of seconds tops

But we might as well try it.

EricRibeiro commented 1 year ago

Made the change here: https://github.com/game-ci/unity-orb/tree/feat_no_output_timeout_param.

You can try the no_output_timeout parameter by replacing your game-ci/unity@1.x.x slug with game-ci/unity@dev:5adf234fc35540145f112e63eeb7cb9c406473dc

Renanse commented 1 year ago

Thanks, Eric. I will give that a shot later today. This whole thing took a little wind out of my sail and wondering if I should go with GHA instead :/

Renanse commented 1 year ago

Hi Eric, happy to report that increasing the timeout helped my build pass. Thank you for your help!

EricRibeiro commented 1 year ago

Hi Eric, happy to report that increasing the timeout helped my build pass. Thank you for your help!

Thanks for trying it out @Renanse! I have a PR open to officially include the new parameter in the orb on #32.

Thanks, Eric. I will give that a shot later today. This whole thing took a little wind out of my sail and wondering if I should go with GHA instead :/

That's fair. GameCI's Builder Action has been around for three years now, which means It's battle-tested and has had more time to evolve. Nevertheless, I'm glad you took the time to test the orb and provide us with your feedback.