consulo / UnityEditorConsuloPlugin

Consulo plugin for UnityEditor
Apache License 2.0
18 stars 2 forks source link

Unity Editor Plugin and big data request. #17

Closed parmaia closed 3 years ago

parmaia commented 4 years ago

Hello again!

I'm having an issue with the Unity Editor Plugin dll.

I need to do a UnityWebRequest get to retrieve a large json file (aprox 1mb). If the Consulo Unity Editor Plugin dll is present in the project, Unity will freeze forever. If I delete the Consulo Plugin folder, all works again.

To reproduce it is very simple, I'm using this code in a script attached to the camera (or any GameObject in the scene):

    using System.Collections;
    using UnityEngine;
    using UnityEngine.Networking;

    public class Test: MonoBehaviour {
        IEnumerator Start() {
            Debug.Log("Getting Data");
            /// I don't know how long this fake json will be online. But I tested writing the content to StreamingAssets 
            /// and the problem is still present.
            //UnityWebRequest www = UnityWebRequest.Get("http://next.json-generator.com/api/json/get/V16pG8l
            UnityWebRequest www = UnityWebRequest.Get(Application.streamingAssetsPath + "/big_json.json");

            yield return www.SendWebRequest();
            if(www.isHttpError || www.isNetworkError){
                Debug.Log("Error " + www.error + " " + www.downloadHandler.text);
            }else{
                Debug.Log("Response " + www.downloadHandler.text);
            }
        }
    }

No matter if the json is on a url, or in StreamingAssets, the result is the same.

I also tried using BestHTTP instead of UnityWebRequest, and the problem still persists.

Tested on Unity 2019.2 and 2019.3

Here you can find an example project: https://www.dropbox.com/s/hco1oz46kpad1nc/Request.zip?dl=0

If you run it as is, Unity will crash. Then, delete the Editor folder from Assets, and it will run as intended.

VISTALL commented 4 years ago

Hello. Big thanks for example project. I will test it in my free time.

Thanks

VISTALL commented 4 years ago

Hello. I found issue. Consulo plugin handle Unity console and resend it to Consulo.

In your test it's send too big file (here https://github.com/consulo/UnityEditorConsuloPlugin/blob/master/Sources/WebApiServer.cs#L57)

For temp fix you can use sources from Assets directory from this branch https://github.com/consulo/UnityEditorConsuloPlugin/tree/unityAssetStore), and remove binary consulo library.

In near future, i will replace binary plugin by source versions.

Thanks

parmaia commented 4 years ago

Thanks for having the time to check it out.

I tested your fix, and it is working perfectly now.

VISTALL commented 4 years ago

Good. This issue will auto-closed after PR merge.

parmaia commented 4 years ago

When you replace binary plugin by source, it will be nice if the code can be placed in any directory inside the Unity Assets folder and consulo know its location for update purposes. For the initial installation use a predefined location (like Scripts/Editor...), but allow this to be moved elsewhere. In my case I put the code in Assets/ThirdParty/ConsuloPlugin.

This is just a suggestion for you to consider. Actually, I'm not sure if consulo looks for the predefined location of the plugin or ask the plugin for its location.

VISTALL commented 4 years ago

There a problem of Unity - plugin must be in project sources.

In new versions of unity - it's can be moved to packages, but - package can be added only by Unity in their repository. I can't do anything with that ;(

VISTALL commented 4 years ago

Binary distribution have major problem binary compatibility (that why need different versions for almost each major versions.).