googlesamples / unity-jar-resolver

Unity plugin which resolves Android & iOS dependencies and performs version management
Other
1.25k stars 343 forks source link

Remove Debug.Assert calls in production or hide them behind settings. #472

Closed JimmyDeemo closed 2 years ago

JimmyDeemo commented 2 years ago

https://github.com/googlesamples/unity-jar-resolver/blob/3dfc84aba31425c1def8a2da7027757d4b3d59fd/source/VersionHandlerImpl/src/VersionHandlerImpl.cs#L994

Debug.Assert calls are causing SecurityExceptions when invoked from other SDKs. Please can we remove them from the release or hid them behind compilation flags or settings?

SecurityException: Couldn't impersonate token.
System.Security.Principal.WindowsImpersonationContext..ctor (System.IntPtr token) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Security.Principal.WindowsIdentity.Impersonate (System.IntPtr userToken) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Configuration.ClientConfigurationHost.Impersonate () (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.BaseConfigurationRecord.Impersonate () (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.BaseConfigurationRecord.InitConfigFromFile () (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
Rethrow as ConfigurationErrorsException: An error occurred loading a configuration file: Couldn't impersonate token.
System.Configuration.ConfigurationSchemaErrors.ThrowIfErrors (System.Boolean ignoreLocal) (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.BaseConfigurationRecord.ThrowIfParseErrors (System.Configuration.ConfigurationSchemaErrors schemaErrors) (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.BaseConfigurationRecord.ThrowIfInitErrors () (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.ClientConfigurationSystem.EnsureInit (System.String configKey) (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
Rethrow as ConfigurationErrorsException: Configuration system failed to initialize
System.Configuration.ClientConfigurationSystem.EnsureInit (System.String configKey) (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.ClientConfigurationSystem.PrepareClientConfigSystem (System.String sectionName) (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String sectionName) (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.ConfigurationManager.GetSection (System.String sectionName) (at <a1ce1c69645646719db9dfa57cf6b99c>:0)
System.Configuration.PrivilegedConfigurationManager.GetSection (System.String sectionName) (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
System.Diagnostics.DiagnosticsConfiguration.GetConfigSection () (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
System.Diagnostics.DiagnosticsConfiguration.Initialize () (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
System.Diagnostics.DiagnosticsConfiguration.get_IndentSize () (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
System.Diagnostics.TraceInternal.InitializeSettings () (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
System.Diagnostics.TraceInternal.get_UseGlobalLock () (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
System.Diagnostics.TraceInternal.Fail (System.String message) (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
System.Diagnostics.TraceInternal.Assert (System.Boolean condition) (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
System.Diagnostics.Debug.Assert (System.Boolean condition) (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
Google.VersionHandlerImpl+FileMetadataByVersion.Add (Google.VersionHandlerImpl+FileMetadata metadata) (at Z:/tmp/tmp.2frsAlF4aX/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:994)
Google.VersionHandlerImpl+FileMetadataSet.Add (System.String filenameCanonical, Google.VersionHandlerImpl+FileMetadataByVersion metadataByVersion) (at Z:/tmp/tmp.2frsAlF4aX/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:1317)
Google.VersionHandlerImpl+FileMetadataSet.ConsolidateManifests () (at Z:/tmp/tmp.2frsAlF4aX/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:1508)
Google.VersionHandlerImpl+ManifestReferences.FindAndReadManifestsByPackageName (Google.VersionHandlerImpl+FileMetadataSet metadataSet) (at Z:/tmp/tmp.2frsAlF4aX/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:1906)
Google.VersionHandlerImpl+ManifestReferences.FindAndReadManifests () (at Z:/tmp/tmp.2frsAlF4aX/third_party/unity/unity_jar_resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:1953)
Firebase.Editor.Measurement.get_BaseQuery () (at Z:/tmp/tmp.J0ijfhPZ17/firebase/app/client/unity/editor/src/Measurement.cs:55)
Firebase.Editor.Measurement..cctor () (at Z:/tmp/tmp.J0ijfhPZ17/firebase/app/client/unity/editor/src/Measurement.cs:38)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.Editor.Measurement' threw an exception.
Firebase.Editor.AndroidSettingsChecker..cctor () (at Z:/tmp/tmp.J0ijfhPZ17/firebase/app/client/unity/editor/src/AndroidAPILevelChecker.cs:37)
Rethrow as TypeInitializationException: The type initializer for 'Firebase.Editor.AndroidSettingsChecker' threw an exception.
System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Activator.CreateInstance (System.Type type) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
UnityEditor.AssetPostprocessingInternal.GetTextureProcessorsHashString () (at <a259d3c004024353a2c217da97495055>:0)
UnityEditor.AssetDatabase:Refresh()

GooglePlayGames.Editor.GPGSUpgrader:.cctor() (at Assets/GooglePlayGames/Editor/GPGSUpgrader.cs:104)​
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes(Type[])
google-oss-bot commented 2 years ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

JimmyDeemo commented 2 years ago

Issue template didn't apply when I linked to a line from the source code.

chkuang-g commented 2 years ago

Yike. Sorry for replying this thread this late.

Pro tips: Use bug template if this is something really disruptive to your development.

The key issue is the use of the C# version of System.Diagnostics.Debug.Assert() instead of Unity version of Debug.Assert(), which is definitely an oversight.

I remember you reported some issue to build EDM4U locally. I'll made a release for this in the next few days.

JimmyDeemo commented 2 years ago

That's okay. Please be aware of the traction I managed to get with a repro project here; https://github.com/firebase/quickstart-unity/issues/1150.