Search Issue Tracker

Fixed

Fixed in 6000.0.38f1, 6000.1.0b3, 7000.0.0a20

Votes

4

Found in

6000.0.36f1

6000.1.0a9

6000.2.0a1

7000.0.0a20

Issue ID

UUM-91151

Regression

Yes

GetActiveBuildProfile can only be called from the main thread crash and error when switching from Windows to Android

-

{*}Steps to reproduce:{*}{*}{*}
# Create a new project with URP Sample > com.unity.template.urp-sample.
# Once the project opens, open Build Profile window.
# Create a new Android Profile.
# Switch to the new Profile.

*Actual results:* We get a console error and unity crash after script recompile
{code:java}
UnityException: GetActiveBuildProfile can only be called from the main thread. Constructors and field initializers will be executed from the loading thread when loading a scene.{code}
*Expected results:* Editor does not crash or throws errors after restart.

*Reproducible with versions:* 6000.1.0a9

*Not reproducible with versions:* 6000.0.26f1,  6000.0.29f1

{*}Tested on (OS):{*}{*}{*}
* macOS (Does not repro) 
* Windows 

{*}Notes:{*}{*}{*}
* Reports on discussions indicate that this issues occur on the following versions: 6000.0.28 and above. However, they do not seem consistent based on my testing on those versions. The issue is consistent on trunk.
* [https://discussions.unity.com/t/unityexception-getactivebuildprofile-can-only-be-called-from-the-main-thread/1566152]

  1. Resolution Note (fix version 6000.1.0b3):

    Tested 4 times and did not repro with 6000.1.0b3

  2. Resolution Note (fix version 6000.0.38f1):

    Verified 6000.0.38f1, switching between windows and android URP did not crash

Comments (5)

  1. muhammadadnan0075

    Feb 10, 2025 07:50

    Have been getting it constantly since all the LTS 6000 versions
    Goes away if switch from Android to Windows but switching back to android spams it back

  2. prukop

    Jan 19, 2025 22:08

    Getting this on 6000.0.33f1 on Windows after creating an Android build profile.
    Seems to happen under several conditions, but very consistent when I edit and save a ShaderGraph, I get this error and stacktrace:

    ```
    UnityException: GetActiveBuildProfile can only be called from the main thread.
    Constructors and field initializers will be executed from the loading thread when loading a scene.
    Don't use this function in the constructor or field initializers, instead move initialization code to the Awake or Start function.
    UnityEditor.EditorUserBuildSettings.GetActiveBuildProfile () (at <18226ebcc7724db583d19c0aeb6444e9>:0)
    UnityEditor.EditorUserBuildSettings.get_activeBuildProfile () (at <18226ebcc7724db583d19c0aeb6444e9>:0)
    UnityEditor.Build.Profile.BuildProfileContext.get_activeProfile () (at <18226ebcc7724db583d19c0aeb6444e9>:0)
    UnityEditor.Build.Profile.BuildProfileContext.ShouldReturnActiveProfile (UnityEditor.BuildTarget buildTarget, UnityEditor.StandaloneBuildSubtarget subtarget, System.String sharedSetting) (at <18226ebcc7724db583d19c0aeb6444e9>:0)
    UnityEditor.Build.Profile.BuildProfileContext.GetActiveOrClassicBuildProfile (UnityEditor.BuildTarget target, UnityEditor.StandaloneBuildSubtarget subTarget, System.String sharedSetting) (at <18226ebcc7724db583d19c0aeb6444e9>:0)
    ```

    Have tried removing/recreating the build profile, error still occurs.

  3. corriedotdev

    Jan 09, 2025 19:24

    Replicating same issue on 6000.0.32f1 - Initially corrupted entire project. Change made before crash was adding a new video to a render texture.

  4. jpq

    Jan 08, 2025 16:47

    error occurs on 6000.0.30f1 too

  5. LePaithon

    Dec 26, 2024 13:17

    Getting this on 6000.0.23f1. Any time i open the unity project (android), I get spammed with this error in my console.

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.