gamejolt / issue-tracker

Issue tracker for Game Jolt
26 stars 6 forks source link

Making a game login through the API takes forever #438

Closed Tricky1975 closed 8 years ago

Tricky1975 commented 8 years ago

My own games freeze all the time when using the API on the login, and I've seen this on a few other games as well. I've seen other people complain about it as well, so I'm pretty sure something is wrong on the server side.

Tricky1975 commented 8 years ago

(Reference above is from my own repository in issue Tricky1975/Star-Story#309, so I can see rather quickly how this issue does).

CyberKiller40 commented 8 years ago

I noticed this too in numerous other games. GJ seems quite overloaded ever since the client was released.

hworld commented 8 years ago

Is it any faster now? I did a bunch of optimizations in the past few days to try to get the site more stable. Would be nice to know if it helped at all in regards to this issue?

Tricky1975 commented 8 years ago

My time does not allow me to test this one now, but I will test this as soon as I can. Hang on. ;)

Tricky1975 commented 8 years ago

Okay, I had a little bit of time to try this out, and unfortunately still no good.

Tricky1975 commented 8 years ago

I hope it helps (as I still cannot log in through my games), but here I posted the repository in which the source code can be found which tries to contact GameJolt. Hopefully this leads to some leads. This code has always worked until december 2015 when it refused to work in any possible way, simply freezing the game not logging in. I never clocked if it makes its way through eventually, but if it does, it takes far too long.

The code can be used as well threaded as unthreaded, but I have to use unthreaded because the game crashes when I make a threaded build (with our without the API, so whatever the issue to that one is, is at least not the GJ API).

CyberKiller40 commented 8 years ago

I tried to login in a game about 1h ago and it failed (tried a long time & said that the username or token were wrong, when they were in fact ok), so the issue is still not fixed.

Tricky1975 commented 8 years ago

Note: original link I posted in my last post prior to this one had a wrong link. I fixed that ;)

Tricky1975 commented 8 years ago

The last time I tried it did not take forever but it says indeed that the login failed. Typos in the username and token are impossible since they were read from an (unmodified) file, which used to work before my trouble began.

Tricky1975 commented 8 years ago

Once again, it takes forever and forever. Well @YLivay asked for the API code in #505, well here it is. The code comes from Polan, all I did was adept it for more proper usage in the BlitzMax language (like the BlitzMax community actually expects).

YLivay commented 8 years ago

Seems like some end cases aren't being handled at all, like authentication failure for example where nothing flows back to the caller. Can you pull a tcpdump while youre trying to connect? Ill see what the exact requests and responses are - that'll give us the clearest picture.

YLivay commented 8 years ago

I actually went ahead and downloaded Blitzmax, now to get your example compiling haha.. Are there any additional steps I need to do?

Tricky1975 commented 8 years ago

That example wasn't mine, but Polan's.... Let me take a look at it....

-- EDIT: Well before you can compile any program using third party modules you should perform a "Build Modules" in order to have all 3rd party modules compiled. After that "Build and Run" should do the trick. There are a few OS specific things though.

-- Windows In Windows you will need MinGW in order to get modules compiled. YOu can best do that from the cmd prompt in the C:\BlitzMax\bin directory (assuming you installed BMax in C:\BlitzMax) and run the bmk utility. I wrote this batch file for it:

@ECHO OFF
SET PATH=%PATH%;I:\WinApp\MinGW\bin\
SET MinGW=I:\WinApp\MinGW
bmk.exe makemods %1

Once all modules are properly installed, MINGW is no longer needed and you can just "Build & Run" from MaxIDE ;)

-- Mac All compiler actions require XCode to be installed

-- Linux Linux is a very awful beast as far as BlitzMax is concerned. A big list of dependencies is required to get the compiler or the linker on the run. The "Linux Discussions" forum on the BlitzMax website may provide more information

YLivay commented 8 years ago

Did I mention Blitzmax is a huge mess on Fedora? I must've installed 20 different dependencies and now I actually have to symlink lib names because it doesnt know how to find them and I cant even recompile the source it uses to compile other modules.

YLivay commented 8 years ago

Haha thanks man, yeah Im in the linux hell atm, I already did all the recompilations and building modules and whatnot and im trying to get it to link now. It seems like its trying to find libs by name and doesnt know how to look em up if they have versioned names so I need to create aliases. Now the problem is that they dont bother running in verbose so I cant really tell what it actually looks for. Im trying to recreate the commands it runs on g++ manually now.

In the meantime, try getting that tcpdump - if it illuminates anything on the problem its preferable that getting this uhh... thing.. working.

Tricky1975 commented 8 years ago

Well, all I could get dumped was a quick dump of what GJ reports: The final stuff it reports is this:

GJ>id:"?????"
GJ>title:"We are the Heroes of our Time"
GJ>description:"Complete the entire game"
GJ>difficulty:"Platinum"
GJ>image_url:"http://m.gjcdn.net/trophy-thumbnail/100/?????-ktaacnhu.jpg"
GJ>achieved:"false"

(I removed the ID numbers). This achievement is the final one in the list of my current game project, after that everything freezes.

The routine that appears to do all GameJolt calls is this:

    Function Call:Object(data:Object)
        Local c:gjCall = gjCall(data)
            'Print c.url
            c.stream = OpenStream("http::"+Right(c.url,Len(c.url)-7))
            If(c.stream)
                Local r:gjResult = New gjResult
                Local str$,first:Byte=True
                While(Not Eof(c.stream))
                    str = ReadLine(c.Stream)
                    If gjdebug Then Print "GJ>"+str
                    ListAddLast(r.atr,str)
                    If(str = "success:~qtrue~q") Then r.success = True
                Wend
                CloseStream(c.stream)
                If(c.onFinish)
                    c.onFinish(r,c.onFinishData)
                EndIf
            EndIf
        ?Threaded   
        DetachThread(c.thread)
        ?
    End Function

At least I see nothing odd in the call itself, which appears to be done in accordance of BlitzMax rules. I'm adding a few more things that can be helpful, standby...

YLivay commented 8 years ago

Just get a tcpdump, so we'd know if its networking or if its just mishandled responses. https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/tcpdump.1.html

Tricky1975 commented 8 years ago

The tcpdump is being created, but in the meantime I think I found the source of all evil here. The API takes a rather long time to get all trophy pictures imported into the system (which are actually not used by the game itself, so I can fix the issue on my own hand by making building in a routine that skips that part)

(It didn't take that long for that in the past though).

Tricky1975 commented 8 years ago

And here I pasted the results of a tcpdump while I was running my last test that lead me to the conclusion I posted above.

(Supplement. I enhanced the API and made it skip loading all trophy images and now it logs in very very quickly. And the trophies awarding works as quickly as it should. Not to mention that I never knew Polan's API wasted so much memory in the process).

I shall soon push a new commit of this API.

YLivay commented 8 years ago

Yo, sorry for not mentioning, tcpdump by default truncates packets so I cant inspect it properly. Can you try again? Run with tcpdump -i <interface> -s 65535 -w <some-file>. Make sure to run blitzmax during the capture so we'd see the networking between you and gj. Ah, and I need the file, not the lines in the terminal :P

Tricky1975 commented 8 years ago

https://www.dropbox.com/s/mwcejrfzps20h7j/tcpdump?dl=0

I have to note, this dump was done while the fix I mentioned in the commit of the API you can see above in this commit was already in place, and now logging in works very fast, so I think the BlitzMax code was to blame after all. I can make a temp build in which it has to load all trophy pics as the evil was clearly there. It needed a lot of time per image, and the game has quite a lot of trophies, and try to create a dump of that.

YLivay commented 8 years ago

Yup, most likely has to do with something else, the actual authentication is snappy :) Going to close this, if there are things we can and should optimize open a separate issue.

P.S. Game API is not currently a priority so we'll probably only focus on showstopping level issues.