VeriorPies / ParrelSync

(Unity3D) Test multiplayer without building
MIT License
4.51k stars 318 forks source link

[BUG] Unity crash on symlink since 2021.2.0b14+ and 2022.1.0a9+ #61

Closed ghost closed 2 months ago

ghost commented 2 years ago

Describe the bug ParrelSync doesn't work with Unity 2021.2.0b14+ and 2022.1.0a9+ due to a bug in Unity.

To Reproduce Steps to reproduce the behavior:

  1. Create project with Unity 2021.2.0b14+
  2. Clone
  3. Open cloned project
  4. Crash in 0x00007ff762cbfee1 (Unity) OnDemandScheduler::SetStandbyWorkerCount

https://issuetracker.unity3d.com/issues/crash-on-ondemandscheduler-setstandbyworkercount-when-opening-a-project-with-a-symbolic-link-in-it It seems Unity has problem with symbolic links in latest versions. I am not sure if it's easy to workaround on ParrelSync side (probably not) so please upvote this link so that this gets Unity attention!

Hadoukanen commented 2 years ago

I got stopped in my tracks due to this as well.

jmguillemette commented 2 years ago

just tripped on this as well

Hadoukanen commented 2 years ago

I manage to get mine working by disabling Directory Monitoring under Asset Pipeline in the prefs. Symlinks does not work with it.. Capture .

ghost commented 2 years ago

It's now part of "Known Issues in 2021.2.0f1":

Asset Import Pipeline: There is a crash in OnDemandScheduler::SetStandbyWorkerCount when opening a project with a symbolic link in it. (1370389)

brogan89 commented 2 years ago

I made some editor methods that just copy the project to a clone. Its not ideal as it takes much longer, but its working fine for now. Its not that bad when just syncing the scripts only and stuff. It will do for the time being anyway.

        [MenuItem("Sync/All", true)]
        [MenuItem("Sync/Scripts", true)]
        [MenuItem("Sync/Prefabs", true)]
        [MenuItem("Sync/Scenes", true)]
        private static bool IsTheClone() => !Directory.GetCurrentDirectory().Contains("_clone");
        [MenuItem("Sync/All")] private static void SyncProject() => SyncPath("Assets", "Packages", "ProjectSettings");
        [MenuItem("Sync/Scripts")] private static void SyncScriptsFolder() => SyncPath("Assets/Scripts");
        [MenuItem("Sync/Prefabs")] private static void SyncPrefabsFolder() => SyncPath("Assets/Prefabs");
        [MenuItem("Sync/Scenes")] private static void SyncScenesFolder() => SyncPath("Assets/Scenes");

        private static void SyncPath(params string[] paths)
        {
            foreach (var path in paths)
            {
                var oldRoot = Directory.GetCurrentDirectory();
                var oldFolder = $"{oldRoot}/{path}";

                var newRoot = $"{oldRoot}_clone";
                var newFolder = $"{newRoot}/{path}";

                // create root
                Directory.CreateDirectory(newRoot);
                SyncDir(oldFolder, newFolder);
            }
        }

        private static void SyncDir(string sourcePath, string targetPath)
        {
            if (!Directory.Exists(targetPath))
                Directory.CreateDirectory(targetPath);

            // CopyFilesRecursively
            //Now Create all of the directories
            foreach (string dirPath in Directory.GetDirectories(sourcePath, "*", SearchOption.AllDirectories))
                Directory.CreateDirectory(dirPath.Replace(sourcePath, targetPath));

            //Copy all the files & Replaces any files with the same name
            foreach (string newPath in Directory.GetFiles(sourcePath, "*.*",SearchOption.AllDirectories))
                File.Copy(newPath, newPath.Replace(sourcePath, targetPath), true);

            Debug.Log($"Synced: <b>{sourcePath}</b> to <b>{targetPath}</b>");
        }
brogan89 commented 2 years ago

I manage to get mine working by disabling Directory Monitoring under Asset Pipeline in the prefs. Symlinks does not work with it.. Capture .

This also works too. Thanks for the tip :)

ghost commented 2 years ago

image Source: https://issuetracker.unity3d.com/issues/crash-on-ondemandscheduler-setstandbyworkercount-when-opening-a-project-with-a-symbolic-link-in-it