googlesamples / unity-jar-resolver

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

[Bug] GvhProjectSettings.xml changes/resets itself #524

Closed ManuelRauber closed 2 months ago

ManuelRauber commented 2 years ago

[REQUIRED] Please fill in the following fields:

[REQUIRED] Please describe the issue here:

Sometimes, not really reproducible, the file GvhProjectSettings.xml changes/resets itself. This is super annoying, because the file pops up in the git stage:

image

As well as this dialogs pops up all the time

image

And as you can see from the diff file above, the settings get reset, e.g. I've disabled both auto-resolution on build and in editor and it will reset back to true, because that's the default.

I currently can not reproduce it exactly, when it happens. Sometimes it does not happen all day, sometimes it happens multiple times day.

ManuelRauber commented 1 year ago

Open sourced: https://github.com/RapBot-Studios/CustomDependencyManager

It's using a paid asset.

uniquecorn commented 1 year ago

I will remove OdinInspector, but it's basically just for a singleton scriptable object.

ManuelRauber commented 1 year ago

I will remove OdinInspector, but it's basically just for a singleton scriptable object.

It's still strange using a paid asset for an open source project. :)

uniquecorn commented 1 year ago

I just removed the requirement for OdinInspector.

zenith-jacob commented 1 year ago

Well, it's definitely Firebase causing this. The issue appeared in my project right after I imported Firebase

ManuelRauber commented 1 year ago

Well, it's definitely Firebase causing this. The issue appeared in my project right after I imported Firebase

No, it's not.

viktorcode commented 1 year ago

Well, it's definitely Firebase causing this. The issue appeared in my project right after I imported Firebase

The bug is caused by the dependencies resolver which is a part of Firebase distribution. The technical reason is known (abuse of static constructor in C#), all that is left is for Google to fix it.

TyelorD commented 1 year ago

I also just integrated Firebase Analytics yesterday into our Unity Project and started getting this error as well now. I did choose to use the Dependency Resolver, and we use Perforce for version control.

How is this issue still not fixed? There are some posts about it going back to 2020...

zenith-jacob commented 1 year ago

The only solution is the "Read Only" on the file mentioned a couple posts above. One of the worst hacks I've made in my life, but trust me - it's the fastest. I've spent 3 days trying to solve this, with 4 other devs. We did it, it did the trick and we forgot about it. There are errors in the console mentioning it cannot modify that file (that's intended behavior) but at least it doesn't change the resolver settings on it's own :)

FYI I'm on Mac, but it works on Windows too.

TyelorD commented 1 year ago

The only solution is the "Read Only" on the file mentioned a couple posts above. One of the worst hacks I've made in my life, but trust me - it's the fastest. I've spent 3 days trying to solve this, with 4 other devs. We did it, it did the trick and we forgot about it. There are errors in the console mentioning it cannot modify that file (that's intended behavior) but at least it doesn't change the resolver settings on it's own :)

FYI I'm on Mac, but it works on Windows too.

I'm also on Mac. This file is already set to "Read Only" because I use Perforce. It automatically marks files as "Read Only" upon submission unless told otherwise.

So I'm just supposed to ignore the extremely distracting and annoying error that it spits out multiple times each run: "Unable to write to 'ProjectSettings/GvhProjectSettings.xml' (System.UnauthorizedAccessException: Access to the path "[Unity Project]/ProjectSettings/GvhProjectSettings.xml" is denied."

That's quite... obnoxious. Google should seriously fix this...

zenith-jacob commented 1 year ago

Trust me man, I've spent the last 10 years of my life asking them to fix issues like these and they did not fix one and I've spent countless nights debugging stuff. Same with FB SDK. It just gets easier when you accept the fact they'll never do anything about it and move on with some kind of a workaround 👍

CodeMasterYi commented 1 year ago

The only solution is the "Read Only" on the file mentioned a couple posts above. One of the worst hacks I've made in my life, but trust me - it's the fastest. I've spent 3 days trying to solve this, with 4 other devs. We did it, it did the trick and we forgot about it. There are errors in the console mentioning it cannot modify that file (that's intended behavior) but at least it doesn't change the resolver settings on it's own :)

FYI I'm on Mac, but it works on Windows too.

I'm so sorry for my bad idea about this super super super old issue. Long for elegant fix.

uniquecorn commented 1 year ago

The real problem is that this entire plugin is way too complicated for what it actually does. It causes crashes because of the threading and runs way too much. It even has a bunch of assetprocessors that will slow down your whole editor when importing anything.

zenith-jacob commented 1 year ago

The only solution is the "Read Only" on the file mentioned a couple posts above. One of the worst hacks I've made in my life, but trust me - it's the fastest. I've spent 3 days trying to solve this, with 4 other devs. We did it, it did the trick and we forgot about it. There are errors in the console mentioning it cannot modify that file (that's intended behavior) but at least it doesn't change the resolver settings on it's own :) FYI I'm on Mac, but it works on Windows too.

I'm so sorry for my bad idea about this super super super old issue. Long for elegant fix.

Don't get me wrong, I'm grateful for your solution :) It's the only one that works. But you gotta admit, it's pretty damn hacky 🥇

cameronnotdoppler commented 1 year ago

Hello, its been a year since this issue was posted. Can we please get an official fix soon? Its such an annoying bug and its obviously quite large scale and affecting many different people.

Tommigun1980 commented 1 year ago

The real problem is that this entire plugin is way too complicated for what it actually does. It causes crashes because of the threading and runs way too much. It even has a bunch of assetprocessors that will slow down your whole editor when importing anything.

This. Please Google, fix the darn thing and slim it down. It's not ok to slow down our editors for no reason whatsoever. The entire thing has to be rewritten.

One would assume Google would have an incentive to make a good resolver as it drives adoption of Google libraries.

uniquecorn commented 1 year ago

The real problem is that this entire plugin is way too complicated for what it actually does. It causes crashes because of the threading and runs way too much. It even has a bunch of assetprocessors that will slow down your whole editor when importing anything.

This. Please Google, fix the darn thing and slim it down. It's not ok to slow down our editors for no reason whatsoever. The entire thing has to be rewritten.

One would assume Google would have an incentive to make a good resolver as it drives adoption of Google libraries.

You can try my custom dependency manager here: https://github.com/RapBot-Studios/CustomDependencyManager

firesightstudios commented 1 year ago

this is the worst bug of the century. using plastic scm and having to undo changes every editor refresh or branch checkout so it will even let you checkout.

Tommigun1980 commented 1 year ago

this is the worst bug of the century. using plastic scm and having to undo changes every editor refresh or branch checkout so it will even let you checkout.

Interesting, I will definitely check it out. Before I do, do you mean that libraries will be checked for and downloaded only at build time, in other words the native libraries should not be stored under the project? If so, where does it cache the libraries? I want CI builds to be as fast as possible so the libraries should be downloaded on first build only and the resolution should be fast in incremental builds. For production builds I need to be able to clear the libraries for a fresh workspace and full library resolution, so are they stored under the project's library or where? Maybe I can PM you of the use cases to verify that every scenario is supported?

uniquecorn commented 1 year ago

Interesting, I will definitely check it out. Before I do, do you mean that libraries will be checked for and downloaded only at build time, in other words the native libraries should not be stored under the project? If so, where does it cache the libraries? I want CI builds to be as fast as possible so the libraries should be downloaded on first build only and the resolution should be fast in incremental builds. For production builds I need to be able to clear the libraries for a fresh workspace and full library resolution, so are they stored under the project's library or where? Maybe I can PM you of the use cases to verify that every scenario is supported?

You are replying to me right? Sure, you can PM me. I'm not even sure how the thing works fully but what I'm guessing is that gradle downloads the libraries directly into the build at build time. I think it would be kinda easy to download the libraries to a cached directory in a library folder and copy them into the build at build time with a verification.

JVimes commented 1 year ago

On Windows GvhProjectSettings.xml is constantly rewritten with opposite line endings, even when content hasn't changed.

Tommigun1980 commented 1 year ago

this is the worst bug of the century. using plastic scm and having to undo changes every editor refresh or branch checkout so it will even let you checkout.

Sorry, my reply was intended for uniquecorn (regarding his custom slimmed-down resolver).

dreed-sd commented 1 year ago

Experiencing this as well. When you get so big you can't even fix the smallest bugs in your products. Considering using git update-index --assume-unchanged on it, anyone try that with success? It shouldn't change 99.999% of the time, so this seems like it'd help. You just have to use --no-assume-unchanged in the case where you actually want to change it, but then you might have a problem with others pulling the change.

harlan commented 11 months ago

+1 this problem is very annoying.

Basically every time I try to interact with version control it's complaining about this spurious file changing.

leo69n commented 10 months ago

+1 any update to fix it please ...

uniquecorn commented 10 months ago

Side note, but it's related to this error, after removing this from my project, I haven't had Unity crash in months, when it used to crash every single day from a random script reload. Seriously, it's actually fun to use Unity again.

walektine commented 10 months ago

Still happening, google is parasite everywhere...annoying

`Failed while parsing XML file ProjectSettings/GvhProjectSettings.xml System.Xml.XmlException: Data at the root level is invalid. Line 4, position 19. at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x00027] in <0590e608b5934df38d654654aeb49efd>:0 at System.Xml.XmlTextReaderImpl.Throw (System.String res, System.String arg) [0x00029] in <0590e608b5934df38d654654aeb49efd>:0 at System.Xml.XmlTextReaderImpl.Throw (System.String res) [0x00000] in <0590e608b5934df38d654654aeb49efd>:0 at System.Xml.XmlTextReaderImpl.ParseRootLevelWhitespace () [0x0012c] in <0590e608b5934df38d654654aeb49efd>:0 at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x002d4] in <0590e608b5934df38d654654aeb49efd>:0 at System.Xml.XmlTextReaderImpl.Read () [0x0008c] in <0590e608b5934df38d654654aeb49efd>:0 at System.Xml.XmlTextReader.Read () [0x00000] in <0590e608b5934df38d654654aeb49efd>:0 at Google.XmlUtilities+Reader.Read () [0x00018] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/XmlUtilities.cs:82 at Google.XmlUtilities.ParseXmlTextFileElements (System.String filename, Google.Logger logger, Google.XmlUtilities+ParseElement parseElement) [0x00132] in /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/XmlUtilities.cs:145

UnityEngine.Debug:LogError (object) Google.Logger:Log (string,Google.LogLevel) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/Logger.cs:136) Google.XmlUtilities:ParseXmlTextFileElements (string,Google.Logger,Google.XmlUtilities/ParseElement) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/XmlUtilities.cs:149) Google.ProjectSettings:Load () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs:777) Google.ProjectSettings:LoadIfEmpty () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs:558) Google.ProjectSettings:GetBool (string,bool,Google.SettingsLocation) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs:606) Google.ProjectSettings:GetBool (string,bool) (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/VersionHandlerImpl/src/ProjectSettings.cs:619) Google.IOSResolver:get_VerboseLoggingEnabled () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/IOSResolver/src/IOSResolver.cs:1039) Google.IOSResolver:.cctor () (at /Users/chkuang/Workspace/git/unity-jar-resolver/source/IOSResolver/src/IOSResolver.cs:727) UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorAssemblies.cs:126) `

AliAlbarrak commented 10 months ago

Solved this by changing source code of ProjectSettings.cs, specifically in Save method https://github.com/googlesamples/unity-jar-resolver/blob/c28949627e61a8de2c98605a244e6c1a99f8b090/source/VersionHandlerImpl/src/ProjectSettings.cs#L821-L829

This way of using XmlWriter is in Append file mode which has a possibility of corrupting the xml file, especially in heavy a domain reload environment like Unity. I surrounded the the existing XmlWriter with a FileStream in FileMode.Create.

using (FileStream fileStream = new FileStream(PROJECT_SETTINGS_FILE, FileMode.Create))
{
    using (var writer =
        XmlWriter.Create(fileStream, ...)) {
        ...
    }
}

I'm no longer facing the issue, at least on Mac. I haven't tested this on Windows yet. Once I'm done with testing I'll make a pull request.

AliAlbarrak commented 10 months ago

Edit: builds linked here are broken, please use the builds in the following comment instead

I wasted a couple of hours yesterday try to build from Windows before realizing it is broken #448.

That aside, this issue is so random and inconsistent that I cannot say for sure that my attempt fixes it. It is almost impossible to reliably reproduce even without my changes.

To confirm that my fix works, not just "issue happened to stop after my change", I'd like for more people to test it before I create a pull request. If you are interested please download and test build from my fork

If this doesn't fixes it please report to me.

harlan commented 10 months ago

@AliAlbarrak you're the man

harlan commented 10 months ago

@chkuang-g what's the process to get @AliAlbarrak 's diff merged in?

toxikman commented 10 months ago

Awesome, thank you @AliAlbarrak for looking into this! I've been testing the UPM Package Archive 1.2.178-preview with Unity 2021.3.31f1, and it's throwing these exceptions that it obviously wasn't doing with Google's 1.2.177 version of the UPM package:

System.TypeInitializationException: The type initializer for 'Google.VersionHandlerVersionNumber' threw an exception. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.Parse (System.String input) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version..ctor (System.String version) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at Google.VersionHandlerVersionNumber..cctor () [0x00000] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionNumber.cs:35 
   --- End of inner exception stack trace ---
  at Google.VersionHandlerImpl..cctor () [0x00052] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:2279 
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorAssemblies.cs:134)

System.TypeInitializationException: The type initializer for 'Google.VersionHandlerImpl' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Google.VersionHandlerVersionNumber' threw an exception. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.Parse (System.String input) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version..ctor (System.String version) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at Google.VersionHandlerVersionNumber..cctor () [0x00000] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionNumber.cs:35 
   --- End of inner exception stack trace ---
  at Google.VersionHandlerImpl..cctor () [0x00052] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:2279 
   --- End of inner exception stack trace ---
  at Google.VersionHandlerImpl+DotNetVersionUpdater..cctor () [0x00015] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:3056 
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorAssemblies.cs:134)

System.TypeInitializationException: The type initializer for 'Google.PackageManagerResolver' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Google.PackageManagerResolverVersionNumber' threw an exception. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.Parse (System.String input) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version..ctor (System.String version) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at Google.PackageManagerResolverVersionNumber..cctor () [0x00000] in /Users/barrak/Projects/unity-jar-resolver/source/PackageManagerResolver/src/VersionNumber.cs:35 
   --- End of inner exception stack trace ---
  at Google.PackageManagerResolver..cctor () [0x00044] in /Users/barrak/Projects/unity-jar-resolver/source/PackageManagerResolver/src/PackageManagerResolver.cs:595 
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
  at Google.PackageMigrator..cctor () [0x00000] in /Users/barrak/Projects/unity-jar-resolver/source/PackageManagerResolver/src/PackageMigrator.cs:598 
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorAssemblies.cs:134)

System.TypeInitializationException: The type initializer for 'Google.PackageManagerResolverVersionNumber' threw an exception. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.Parse (System.String input) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version..ctor (System.String version) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at Google.PackageManagerResolverVersionNumber..cctor () [0x00000] in /Users/barrak/Projects/unity-jar-resolver/source/PackageManagerResolver/src/VersionNumber.cs:35 
   --- End of inner exception stack trace ---
  at Google.PackageManagerResolver..cctor () [0x00044] in /Users/barrak/Projects/unity-jar-resolver/source/PackageManagerResolver/src/PackageManagerResolver.cs:595 
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorAssemblies.cs:134)

System.TypeInitializationException: The type initializer for 'Google.AndroidResolverVersionNumber' threw an exception. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.Parse (System.String input) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version..ctor (System.String version) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at Google.AndroidResolverVersionNumber..cctor () [0x00000] in /Users/barrak/Projects/unity-jar-resolver/source/AndroidResolver/src/VersionNumber.cs:35 
   --- End of inner exception stack trace ---
  at GooglePlayServices.PlayServicesResolver..cctor () [0x0009d] in /Users/barrak/Projects/unity-jar-resolver/source/AndroidResolver/src/PlayServicesResolver.cs:819 
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorAssemblies.cs:134)

System.TypeInitializationException: The type initializer for 'Google.IOSResolverVersionNumber' threw an exception. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.Parse (System.String input) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version..ctor (System.String version) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at Google.IOSResolverVersionNumber..cctor () [0x00000] in /Users/barrak/Projects/unity-jar-resolver/source/IOSResolver/src/VersionNumber.cs:35 
   --- End of inner exception stack trace ---
  at Google.IOSResolver..cctor () [0x0018d] in /Users/barrak/Projects/unity-jar-resolver/source/IOSResolver/src/IOSResolver.cs:1223 
UnityEditor.EditorAssemblies:ProcessInitializeOnLoadAttributes (System.Type[]) (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorAssemblies.cs:134)

Job failed with exception: System.TypeInitializationException: The type initializer for 'Google.VersionHandlerImpl' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Google.VersionHandlerVersionNumber' threw an exception. ---> System.FormatException: Input string was not in a correct format.
  at System.Number.ThrowOverflowOrFormatException (System.Boolean overflow, System.String overflowResourceKey) [0x0001a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Number.ParseInt32 (System.ReadOnlySpan`1[T] value, System.Globalization.NumberStyles styles, System.Globalization.NumberFormatInfo info) [0x00016] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Int32.Parse (System.ReadOnlySpan`1[T] s, System.Globalization.NumberStyles style, System.IFormatProvider provider) [0x0000e] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.TryParseComponent (System.ReadOnlySpan`1[T] component, System.String componentName, System.Boolean throwOnFailure, System.Int32& parsedComponent) [0x0000b] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.ParseVersion (System.ReadOnlySpan`1[T] input, System.Boolean throwOnFailure) [0x0011a] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version.Parse (System.String input) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at System.Version..ctor (System.String version) [0x00014] in <fb900569f62341f196b7b5fe48154a92>:0 
  at Google.VersionHandlerVersionNumber..cctor () [0x00000] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionNumber.cs:35 
   --- End of inner exception stack trace ---
  at Google.VersionHandlerImpl..cctor () [0x00052] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:2279 
   --- End of inner exception stack trace ---
  at Google.VersionHandlerImpl+BuildTargetChecker.HandleBuildTargetChanged (UnityEditor.BuildTarget newBuildTarget) [0x00001] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:3119 
  at Google.VersionHandlerImpl+BuildTargetChecker.CheckBuildTarget () [0x00041] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:3102 
  at Google.VersionHandlerImpl+BuildTargetChecker.HandleSettingsChanged () [0x00001] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/VersionHandlerImpl.cs:3096 
  at Google.RunOnMainThread.ExecuteNext () [0x00047] in /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:486 
UnityEngine.Debug:LogError (object)
Google.RunOnMainThread:ExecuteNext () (at /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:488)
Google.RunOnMainThread/<>c:<ExecuteAllUnnested>b__28_0 () (at /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:536)
Google.RunOnMainThread:RunAction (System.Action) (at /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:343)
Google.RunOnMainThread:ExecuteAllUnnested (bool) (at /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:530)
Google.RunOnMainThread:ExecuteAll () (at /Users/barrak/Projects/unity-jar-resolver/source/VersionHandlerImpl/src/RunOnMainThread.cs:512)
UnityEditor.EditorApplication:Internal_CallUpdateFunctions () (at /Users/bokken/build/output/unity/unity/Editor/Mono/EditorApplication.cs:356)
AliAlbarrak commented 10 months ago

Thanks @toxikman for your feedback.

I think adding -preview to the version number straight up broke EDM4U. The initial build was versioned 1.2.178 but then I wanted to indicate that my package is not official so I added the preview suffix last minute. Seems like that wasn't the right call.

I don't have to a Mac right now. Will make a new package tomorrow.

toxikman commented 10 months ago

OK, great, thanks. I wondered about that -preview as well when I saw the version errors. I'm not sure how Unity achieves that in their Package Manager listings.

AliAlbarrak commented 10 months ago

Edit: build linked here is reportedly not working, please use the builds in the following comment instead

Here is the new, hopefully ~working~, release

Again, your feedback is appreciated

MigrantP commented 10 months ago

Here is the new, hopefully working, release

@AliAlbarrak Thanks, I tried this out (Unity 2022.2.11 on MacOS). It seemed to help at first, but unfortunately I'm still getting phantom changes to GvhProjectSettings.xml with Unity on Standalone platform.

AliAlbarrak commented 10 months ago

Thanks for your feedback.

Here is my understanding of the issue, and I could be wrong. Reading and writing of the settings file is protected by a lock. It is possible that due to domain reload, 2 separate running processes are trying to access the file at the same time so the lock is not aware of the other process.

I'm not sure if this is even solvable but I can try different approach.

AliAlbarrak commented 10 months ago

Edit: even though builds linked here are working for us, some reported that there might be an edge case where the fix fails. Please use the builds in the following comment instead

Here is new attempt. This time I'm trying to avoid file corruption by using tmp files

Again, your feedback is appreciated

harlan commented 10 months ago

@AliAlbarrak i appreciate the work you're putting into this.

toxikman commented 10 months ago

Here is the new, hopefully working, release

@AliAlbarrak Thanks, I tried this out (Unity 2022.2.11 on MacOS). It seemed to help at first, but unfortunately I'm still getting phantom changes to GvhProjectSettings.xml with Unity on Standalone platform.

@AliAlbarrak I also got the problem again with your previous release. I'm going to try the latest one you posted most recently that creates tmp files.

MigrantP commented 10 months ago

Since the most recent update from @AliAlbarrak we haven't seen the problem again!

AliAlbarrak commented 9 months ago

Your feedback is much appreciated.

Due to the nature of this bug, it is difficult to prove a fix, or claim that a change fixes it.

I'll wait few days before making the pull request to allow for more testing

toxikman commented 9 months ago

I can report that we've been using this new version for a few days and so far no issues with the XML getting reset! The temporary file solution seems to solve the issue. Note that we have not tested changing any of the settings, so you should rely on others to verify that the XML file is being written correctly when it needs to be.

MigrantP commented 9 months ago

An update after a few weeks - the issue has occurred again. However it happens way less often for sure, so at least it's quite an improvement!

AliAlbarrak commented 9 months ago

@MigrantP thanks for your feedback I'll close the pull request since it is not a definite fix. I'll look for better solutions but I'm busy now. I might get back to this early December

Tommigun1980 commented 9 months ago

@paulinon Hi. When will this be fixed? This might be one of the most time consuming and annoying bugs ever. It is unfathomable that it's not been fixed yet.

Can we pool a monetary bounty to Google to get it fixed?

v17alya commented 9 months ago

It's horrible. When will this be fixed? 🥲😭

Tommigun1980 commented 8 months ago

Hi @paulinon. Any progress on this one? It's so incredibly risky to have the file auto reset it all the time by accidental commits, not to mention how infuriating it is to close the resolver dialog 50 times a day.

This will drive people away from Firebase and other services Google is providing that are dependent on the resolver.

toxikman commented 8 months ago

@Tommigun1980 The "temporary file solution" that @AliAlbarrak posted on Oct 25 does work for us, have you tried it?

AliAlbarrak commented 8 months ago

Sorry for long delay since last update. Here is new attempt. This time I'm avoiding overriding the file when settings didn't change. Previously, even when settings are the same, the file gets written 3 times with every domain reload. I added an extra check to skip file write if settings didn't change since last read.

I'm opening the pull request again as well.

Again, your feedback is appreciated.