NavidK0 / SimpleGraphQL-For-Unity

A simple graphQL client that allows one to use .graphql files (or code) for queries, mutations, and subscriptions with Unity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slower Calls After Update

RPloutarchou opened this issue · comments

Hi, I have been using SimpleGraphQL package for one of the games I am developing and recently when I update to the latest version I noticed a bit of a lag when making requests. Not sure where the problem is but the lag is noticeable. The package version I was using before is 1.1.3 and I have updated to version 1.2.0.

Hi, I have been using SimpleGraphQL package for one of the games I am developing and recently when I update to the latest version I noticed a bit of a lag when making requests. Not sure where the problem is but the lag is noticeable. The package version I was using before is 1.1.3 and I have updated to version 1.2.0.

Is it possible for you to provide a test project or some test code? This type of problem is really hard to debug without additional information because it could really be anything causing it.

Hi again I have attached two files one showing the older version and one showing the newer version. I use this code to get data from the server with the SimpleGraphQL package and then deserialize the data with Newtosoft.JSON and add them to an instantiated object on me scene usually on a scroll view. The delay occurs when unity is processing/is waiting on the query and while on the older version the object instantiation was almost instant on the newer version their is a noticeable lag on this part. I am not sure whether this is a problem with this particular package or with the newer version of unity but I would appreciate it If you take a look at it. The scripts I have attached are abstract versions of the scripts I am using In most of my app. Thanks again for the reply.
OldVersion.txt
NewVersion.txt

Hi again I have attached two files one showing the older version and one showing the newer version. I use this code to get data from the server with the SimpleGraphQL package and then deserialize the data with Newtosoft.JSON and add them to an instantiated object on me scene usually on a scroll view. The delay occurs when unity is processing/is waiting on the query and while on the older version the object instantiation was almost instant on the newer version their is a noticeable lag on this part. I am not sure whether this is a problem with this particular package or with the newer version of unity but I would appreciate it If you take a look at it. The scripts I have attached are abstract versions of the scripts I am using In most of my app. Thanks again for the reply.
OldVersion.txt
NewVersion.txt

So I reduced your test cases to just testing the queries with a stopwatch and I was unable to find any significant difference between the package versions. The only difference is the ".ToRequest()" extension method in query.ToRequest(). I've attached my files in case you want to try them out:

SimpleGraphQLTest.zip

If you do try it out and find significant differences in the actual query calling, it may be a platform issue or another deeply ingrained problem.

Please note that the first connection will always be slower than the others because of the WebSocket initialization handshake process. Subsequent calls will reuse the same WebSocket so they are much faster. (All GraphQLClient instances use the same WebSocket too.)

As for your issue, I believe that you are noticing lag possibly because of NewtonsoftJSON's deserialization. It's just an educated guess, but you can try using JSONUtility instead and seeing if that helps. I believe your data structure is simple enough to work. Do let me know how it works out. It may just be a problem with either the deserialization or the gameObject instantiation itself, rather than the actual networking.

I used Unity 2021.1.16f1 and got on average ~12 ms stopwatch time on both versions (located on the East Coast of the US).
Test server is https://countries.trevorblades.com/, the zip file contains the Configuration already setup.

Thanks for the quick response, I will try using switching from Newtonsoft to JSONUtility to check if there is any difference and let you know.

Closing for inactivity.