Skip to content
This repository has been archived by the owner on Oct 6, 2023. It is now read-only.

Help: Unity not responding while restoring package #42

Closed
2 tasks done
Creta5164 opened this issue Feb 27, 2020 · 13 comments
Closed
2 tasks done

Help: Unity not responding while restoring package #42

Creta5164 opened this issue Feb 27, 2020 · 13 comments
Assignees
Labels
question Need answer, not changes

Comments

@Creta5164
Copy link

Creta5164 commented Feb 27, 2020

Expected behavior

When clearing cached Library folder and reopen project, Unity's UPM will restore packages, includes Newtonsoft.Json-for-Unity.

Actual behavior

Unity is stucking in splash screen.

image


Task manager says one or more thread are wait for finishing Network I/O.

image

Steps to reproduce

  • New project
  • Import jillejr.newtonsoft.json-for-unity via UPM
  • Close project
  • Delete Library folder in project folder
  • Reopen project
  • Unity will stuck in splash screen.
  • When removes package info in manifest.json then Unity will successfully open project.

Details

OS : Windows 10 Pro RS5 (1909) 64bit
Unity : 2019.3.3f1
Package version : 12.0.301

Checklist

  • Shutdown Unity, deleted the /Library folder, opened project again in Unity, and problem still remains.
  • Checked to be using latest version of the package.
@Creta5164 Creta5164 changed the title Help: Unity not responding by restoring package Help: Unity not responding while restoring package Feb 27, 2020
@applejag
Copy link
Owner

Hey thanks for reporting this issue! It's really helpful!

This is the first time I've ever seen anything like it and sadly I can't make any educated assumptions from this. Some further questions:

  1. On first import, does UPM download the package, or has it never succeeded?

  2. Can you access npm.cloudsmith.io? Like try pinging

    ping npm.cloudsmith.io
  3. Could you also post the log file from when this occurs? The log file can be found at:

    %LOCALAPPDATA%\Unity\Editor\Editor.log
    

    Upload it here or at https://pastebin.com and paste the link here. Or if your logs contains confidential information you can email the pastebin link to me.

@applejag applejag self-assigned this Feb 28, 2020
@Creta5164
Copy link
Author

Hmm I can't reproduce this now, it's maybe this issue has fixed in Unity side host or something, I think...

Question 1 was fine if already opened project.
But adding package before open project, Unity was stucked.

And question 2 is yes, it's able to connect to package host!

When I got this situation again then I'll answer to you 3rd question!
Because it's seems issued part was discarded by Unity editor...

I'll temporary close this issue, and thanks to attention for my issue!

@Creta5164
Copy link
Author

So, I got again this situation.

Heres excluding json.net package info in manifest.json before and after Editor.log, I checked it with diff it seems AssetDatabase doesn't appears in log.

Editor.log (before excluding json.net package info in manifest)
Editor.log (after excluding json.net package info in manifest)

If you have vscode, open new two file, and paste them each side then right click files to check diff.
image
image

@Creta5164 Creta5164 reopened this Feb 29, 2020
@applejag
Copy link
Owner

applejag commented Mar 1, 2020

Big hmm. Still can't make any conclusions. As you said only when excluding the package it does a script compilation (as seen in the - Starting script compilation section)

To try track it down more, what about:

  1. Are you doing any DllImport in your project?

  2. Are both logs from launching with a deleted Library folder? Since only one log shows recompilation.

  3. What are your projects scripting backend and API compatability level?

  4. What's the content of the %LOCALAPPDATA%\Unity\Editor\upm.log file on a failed launch? (usually never find anything there of interest but I'm shooting in the dark right now)

  5. If you grab the content of the package and toss it into the Assets folder instead of having it added as an UPM package, does it still freeze at startup?

@Creta5164
Copy link
Author

Creta5164 commented Mar 3, 2020

Sorry for late reply, I was busy on my works 🙏

  1. Yes, my project uses nuget packages. (Markdig, AngleSharp, ColorCode)
    * If you meaning DllImport attribute, I doesn't uses DllImport.

  2. That's my all logs started with Library folder!

  3. Project uses .NET Framework 4.x compatability.

  4. Seems there's noting to found useful information...

[2020-03-03T05:11:25.259Z][INFO] Starting Server
[2020-03-03T05:11:25.265Z][INFO] Server started on port [50812]
[2020-03-03T05:11:25.319Z][INFO] Health Request received

  1. Yes, it's happen again! this is meaning that problem is compiler side or something?

@Creta5164
Copy link
Author

Creta5164 commented Mar 3, 2020

Additional info about question 1 and 5, my project uses Unity's *.asmdef that simulates codes into different assembly or dll.

  • Editor script : *nothing
  • Asset script : referenceing TextMeshPro only
{
    "name": "ProblemSetScripts",
    "references": [
        "Unity.TextMeshPro"
    ]
}
  • Unit test script : referencing asset script and test library
{
    "name": "Problems",
    "references": [
        "UnityEngine.TestRunner",
        "UnityEditor.TestRunner",
        "ProblemSetScripts"
    ],
    "includePlatforms": [],
    "excludePlatforms": [],
    "allowUnsafeCode": false,
    "overrideReferences": true,
    "precompiledReferences": [
        "nunit.framework.dll"
    ],
    "autoReferenced": true,
    "defineConstraints": [
        "UNITY_INCLUDE_TESTS"
    ],
    "versionDefines": [],
    "noEngineReferences": false
}

@applejag
Copy link
Owner

applejag commented Mar 5, 2020

It's so weird that the compilation fails. At least we can exclude UPM from the equation.

I know you wrote in the "reproduce" that it's based off of a new project, but to confirm: Does this happen on a fresh project (No other code/asmdef in the Assets or other Unity packages)?

Sorry that this issue takes times to resolve.

@applejag
Copy link
Owner

applejag commented Mar 5, 2020

And to confirm the "works on my machine", would it be possible if you sent me a copy of your project?

@Creta5164
Copy link
Author

Creta5164 commented Mar 5, 2020

Sure, this issue is difficult to reproduce in new projects.
My project is not ready, but I considering it will be releases on GitHub with an MIT license, so I can share to my project file to you!

Here's temporary link.

Download
Project version : 2019.3.3f1

Step to reproduce

  1. Open project
  2. Select Window/UnityPSForBeginners
    image
  3. Follow instruction until reaching Space and Vector part page.
  4. When click Space and Vector part, Part 1_VectorAndDirection scene will open.
  5. If you reach Space and Vector page, close project.
  6. Reopen project then Unity will stuck in splash screen.
  7. Even reopen project before delete Library folder still stuck in splash screen.
  8. If force close Unity and remove package info in manifest.json then open project will open successfully.

@applejag
Copy link
Owner

applejag commented Mar 23, 2020

Sorry to get back to you at such a delayed time. 18 days later...

I don't really know the context here. Are you trying to get past a beginners guide or are you developing a beginners guide?

To progress this issue you're experiencing, here are my findings from my debugging session:

  • Good repro, was able to experience the issue on my local computer. Huge boost.

  • It's not stuck compiling. I was able to track it down to a call to UnityEditor.EditorSceneManager.OpenScene in SpaceAndVector.cs. That's where it's freezing when loading the Part 1_VectorAndDirection.unity scene (as we even could tell from the logs). It does not get past the OpenScene call at all.

  • What seems to be the issue is because you're loading the same scene as you already have open. Look at the struct returned from SceneManager.GetActiveScene() just before getting frozen by the OpenScene call:

    .buildIndex: -1
    .handle: -1216
    .isDirty: False
    .isLoaded: True
    .isSubScene: False
    .name: Part 1_VectorAndDirection
    .path: Assets/ProblemAssets/Main/SpaceAndVector/Part 1_VectorAndDirection.unity
    .rootCount: 5
  • To fix: Haven't tested it thoroughly, but adding something like this to the start of the SpaceAndVector.OnNavigateFrom() method would suffice:

    var activeScene = SceneManager.GetActiveScene();
    if (activeScene.path == $"{Utils.PROBLEM_ASSETS_PATH}/Main/SpaceAndVector/Part 1_VectorAndDirection.unity") {
        OnSceneOpened(activeScene, OpenSceneMode.Single);
        return;
    }

To recap: the issue seems to be that Unity freezes when calling EditorSceneManager.OpenScene on a scene that is already loaded. Certainly a bug at Unity's end, but can be easily worked around.


Why did removing the jillejr.newtonsoft.json-for-unity package help?

When you removed the Newtonsoft.Json package by removing the Packages/manifest.json file, you made the scripts UnityTutorialPS.DisplayStrings & UnityTutorialPS.ProgressData fail to compile as they now tried to reference a missing Newtonsoft.Json namespace.

They made the entire AssemblyCSharpEditor.dll assembly fail to compile and then there was no call to the EditorSceneManager.OpenScene method.


Silver lining: The Newtonsoft.Json package had no hidden bug :P

I'm closing this as I consider this resolved.

@applejag applejag added the question Need answer, not changes label Mar 23, 2020
@Creta5164
Copy link
Author

Ohh... thanks to discover my project and explain about this, even solution!
If you fine, can I put your name in this project as contributor?

@applejag
Copy link
Owner

Haha it's such a small contribution but yea sure why not :)

And you're of course allowed to do whatever you want with the code I provided in the comment.

Good luck with your project! It looked really good!

@Creta5164
Copy link
Author

Thanks, I tried it and works well!
I just put your credit in my project, thanks again!

image

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question Need answer, not changes
Projects
None yet
Development

No branches or pull requests

2 participants