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

Crash on IL2CPP due to a attempt to instantiate DriveInfo class #2

Open
IronWarrior opened this issue Aug 5, 2023 · 0 comments
Open

Comments

@IronWarrior
Copy link

IronWarrior commented Aug 5, 2023

Tested using Version v2023.7.1 from the Unity Asset Store (latest as of this post). In SystemIODataService.IsThereEnoughDiskSpaceFor we currently have

        public async Task<bool> IsThereEnoughDiskSpaceFor(long bytes)
        {
            try
            {
#if UNITY_ANDROID
                //DriveInfo is not supported on iLcpp
                AndroidJNI.AttachCurrentThread();
                var statFs = new AndroidJavaObject("android.os.StatFs", persistentDataPath);
                var freeBytes = statFs.Call<long>("getFreeBytes");
                return bytes < freeBytes;
#else
                FileInfo f = new FileInfo(PersistentDataRootDirectory);
                string drive = Path.GetPathRoot(f.FullName);
                var d = new DriveInfo(drive);
                return bytes < d.AvailableFreeSpace;
#endif
            }
            catch(Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }

which correctly notes that DriveInfo is not supported in IL2CPP, as recorded here.

However, it will be used on any platform other than Android which would cause the crash (I have only been testing this on Standalone). Previous modio versions had

        public async Task<bool> IsThereEnoughDiskSpaceFor(long bytes)
        {
            // Not implemented for this platform
            return true;
        }

Not sure if there is any solution here for IL2CPP beyond just allowing the installation attempt to proceed (and fail) and then catch the IOException?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant