Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Unity Analytics as a mandatory dependency of com.unity.ml-agents #5064

Closed
JesseTG opened this issue Mar 9, 2021 · 12 comments
Closed
Assignees
Labels
bug Issue describes a potential bug in ml-agents. request Issue contains a feature request.

Comments

@JesseTG
Copy link
Contributor

JesseTG commented Mar 9, 2021

Is your feature request related to a problem? Please describe.
I'm developing a game for a platform that Unity Analytics does not support. Since ml-agents depends on com.unity.modules.unityanalytics, this means that I can't use ml-agents on said platform.

Describe the solution you'd like
Only enable the features that use Unity Analytics if com.unity.modules.unityanalytics is installed in the project.

Describe alternatives you've considered
Manually removing the Unity Analytics DLL from the build pipeline. I don't know if this would work. It wouldn't work as this is a compiler error. The only alternative is to work on something else while this issue is resolved.

Additional context
Setting aside the issue of compatibility, I'm removing unused core Unity modules from my project to keep the file size down. For example, my game doesn't use terrain so I'm excluding the terrain module.

@JesseTG JesseTG added the request Issue contains a feature request. label Mar 9, 2021
@awjuliani awjuliani self-assigned this Mar 9, 2021
@awjuliani
Copy link
Contributor

Hi @JesseTG

Thanks for bringing this to our attention. This package should only have an impact on the Editor, and not the builds containing ML-Agents. Can you share what error you are running into, and at what point it is occuring? It is when importing the package, or when trying to build for your platform? It would also be helpful to know the specific platform which you are having issues targeting, as that will help us to reproduce the issue.

@JesseTG
Copy link
Contributor Author

JesseTG commented Mar 11, 2021

Hi @JesseTG

Thanks for bringing this to our attention. This package should only have an impact on the Editor, and not the builds containing ML-Agents. Can you share what error you are running into, and at what point it is occuring? It is when importing the package, or when trying to build for your platform? It would also be helpful to know the specific platform which you are having issues targeting, as that will help us to reproduce the issue.

The platform I'm using does not support Unity Analytics; when I set it to be the active build platform, all Unity Analytics APIs are simply unavailable, resulting in compiler errors. This occurs in the editor, so I assume it would be the same when building.

I get pretty much the same error in multiple places, all in TrainingAnalytics and InferenceAnalytics. Here's one of the errors:

[CompilerError] The type name 'AnalyticsResult' could not be found in the namespace 'UnityEngine.Analytics'. This type has been forwarded to assembly 'UnityEngine.UnityAnalyticsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' Enable the built in package 'Unity Analytics' in the Package Manager window to fix this error.
Compiler Error at Library\PackageCache\com.unity.ml-agents@1.8.0-preview\Runtime\Analytics\TrainingAnalytics.cs:67 column 17
65:               {
66:   #if UNITY_EDITOR
-->67:                   AnalyticsResult result = EditorAnalytics.RegisterEventWithLimit(eventName, k_MaxEventsPerHour, k_MaxNumberOfElements, k_VendorKey);
68:   #else
69:                   AnalyticsResult result = AnalyticsResult.UnsupportedPlatform;

The type name 'AnalyticsResult' could not be found in the namespace 'UnityEngine.Analytics'. This type has been forwarded to assembly 'UnityEngine.UnityAnalyticsModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' Enable the built in package 'Unity Analytics' in the Package Manager window to fix this error.

Unfortunately, I can't publicly say which platform I'm targeting as its details are confidential. However, there are other useful things I can say:

  • You can easily reproduce this issue for any target platform by simply disabling com.unity.modules.unityanalytics in the package manager. The effect, errors, and fix should be the same.
  • My target platform doesn't offer the UnityEngine.Analytics assemblies, even if com.unity.modules.unityanalytics is enabled.
  • I believe this issue affects multiple NDA-protected platforms and that the same fix should work for all of them. Whichever guess you make will probably be the correct one.

@surfnerd surfnerd self-assigned this Mar 11, 2021
@surfnerd
Copy link
Contributor

Is the platform you are using under NDA? Or is there a define that the analytics code uses that we aren't aware of?

@JesseTG
Copy link
Contributor Author

JesseTG commented Mar 12, 2021

Is the platform you are using under NDA? Or is there a define that the analytics code uses that we aren't aware of?

The platform itself is under NDA. Well, its development details. The platform itself is quite famous (and odds are good you have one in your living room -- or in your backpack).

No unusual #defines are in use, to my knowledge; the Analytics DLLs are just not included in the compiler's search path when my platform is active.

@surfnerd
Copy link
Contributor

Thanks for the info @JesseTG,
I'm going to create a PR that makes the analytics module an optional dependency. This should address your problem and hopefully anyone else that is using an NDA platform.

@surfnerd surfnerd added the bug Issue describes a potential bug in ml-agents. label Mar 12, 2021
@JesseTG
Copy link
Contributor Author

JesseTG commented Mar 12, 2021

Thanks for the info @JesseTG,
I'm going to create a PR that makes the analytics module an optional dependency. This should address your problem and hopefully anyone else that is using an NDA platform.

Thank you! I appreciate it.

@surfnerd
Copy link
Contributor

surfnerd commented Mar 15, 2021

@JesseTG,
which version of unity are you using, and which version of the package are you using? Optional dependencies will only work with Unity versions 2019.4 and later.

@surfnerd
Copy link
Contributor

He @JesseTG,
#5109 was merged into main. Please let us know if this fixes your issue.
Thanks,
Chris

@JesseTG
Copy link
Contributor Author

JesseTG commented Mar 16, 2021

@JesseTG,
which version of unity are you using, and which version of the package are you using? Optional dependencies will only work with Unity versions 2019.4 and later.

I'm using 2020.2.7, and I intend to upgrade to 2021.1.0 when it comes out.

He @JesseTG,
#5109 was merged into main. Please let us know if this fixes your issue.
Thanks,
Chris

With pleasure, thank you very much! When's the next release?

@surfnerd
Copy link
Contributor

There is a release coming out this week, but it will not contain these changes. The changes will make it into the April release alongside the changes to make physics and physics2d optional dependencies as well.

@JesseTG
Copy link
Contributor Author

JesseTG commented Mar 16, 2021

There is a release coming out this week, but it will not contain these changes. The changes will make it into the April release alongside the changes to make physics and physics2d optional dependencies as well.

Thank you! I'll report back if there are any problems.

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue describes a potential bug in ml-agents. request Issue contains a feature request.
Projects
None yet
Development

No branches or pull requests

3 participants