AbrarSyed / SecretRoomsMod-forge

The official SecretRoomsMod repo
GNU Lesser General Public License v3.0
40 stars 35 forks source link

[1.12.2 5.2.1] Massive lag when changing dimensions; Partially even timeouts / disconnects #216

Closed Lordmau5 closed 6 years ago

Lordmau5 commented 6 years ago

Optifine: Yes, 1.12.2 HD U C8 Does this affect the issue?: No

So TL;DR we had this mod in our pack and when changing dimensions, e.g. to or from the Nether, it took at least 20 seconds. This caused deaths due to long load times and even timeouts.

After trying to figure out which mod was causing it, I went ahead and used VisualVM to try and figure out what is taking so long to load.

Turns out it's this mod's FakeChunkRenderFactory. I don't know what it's doing, but it definitely doesn't behave well.

I haven't tried to reproduce this issue on the client, only on a dedicated server.

Wyn-Price commented 6 years ago

Ok I think I know what's causing this. I'll get onto it now

Wyn-Price commented 6 years ago

What happens is when the player changes dimensions, the server sends a NBT tag containing all the positions the Energized Camoflage Paste is in. It used to have to be like this, as the whole Energized Camoflage Paste system was diffrent. You were kinda right with the FakeChunkRenderFactory. If you look at that class, it calls FakeRenderChunk, which then calls FakeChunkCache, which then, calls EnergizedPasteHandler.java at Line 333.

At EnergizedPasteHandler.java, line 333, you can see that when an entity joins the world (EntityJoinWorldEvent), it sends all the data to the player that joined. To fix this I just need to do it so its when the player joins the server, not when they change worlds.

Wyn-Price commented 6 years ago

Also are you using the Energized Paste? Theres no point in using 5.2.x if youre not. If you dont know what it is, look here

Wyn-Price commented 6 years ago

Could you test out this build? It should work better

Lordmau5 commented 6 years ago

Alright, it doesn't hang up anymore when changing dimensions.

But when I join the server, then leave, and repeat this process like 3 times, I can't connect anymore. Could it be related to some caching that's going on?

Wyn-Price commented 6 years ago

What happens when you try and connect? Does what error message does it say. Is there any errors that occur in the server or client logs

Lordmau5 commented 6 years ago

No error. Just super long load times that cause disconnects / timeouts

Wyn-Price commented 6 years ago

That'll be because when you join a Server, it sends all the information on where the energized paste is. If the list is long, then it'll take a while to send . I'll try a different technique of sending the data

Lordmau5 commented 6 years ago

The list was empty because I didn't place any of those blocks / paste down. I should've probably mentioned that lol

Wyn-Price commented 6 years ago

Hey I'm trying to sort things out, and I'll need you to test something. I'm having major internet issues at the moment and am unable to work on it. I should have it fixed for today or tommorow

Wyn-Price commented 6 years ago

Ok so ive changed some of the code. Does this fix loading times. Ive removed some code, just for testing, so the Energized Paste wont be synced up from server to client.

Lordmau5 commented 6 years ago

Once again, the first 3 times it worked pretty okay, but then increased the load times more and more, up until I get to disconnects every time I try to join from the 4th attempt onwards.

I've spun up VisualVM again, once again it looks like the FakeChunkRenderFactory is eating pretty much most of the Client Thread: image

Wyn-Price commented 6 years ago

Ok that's interesting. I removed the packet being sent, so it's not that which is causing the issue. I'll look more into it now

Wyn-Price commented 6 years ago

What version of java and forge are you using. I cant think of anything that would cause this apart from version diffrences

Wyn-Price commented 6 years ago

Also could you send me the following files, from the server, and the client.

Errors from the NettyIO threads often get pushed to other logs, not the main one.

Lordmau5 commented 6 years ago

https://lordmau5.com/mc/client_logs.zip https://lordmau5.com/mc/server_logs.zip

Java 1.8 Update 144 Forge 14.23.1.2599

Wyn-Price commented 6 years ago

If you look at the fml-junk-earlystartup, server side, at line 212725, you can see theres an error being thrown due to the client leaving. The error means that the client left, as the server was reading a data packet. Try this version to see if theres no connecting issue. Again, the data from the Energized Paste wont sync up.

Wyn-Price commented 6 years ago

Are you sure its SecretRoomsMod doing this. Could you try it on its owm just to make sure

Lordmau5 commented 6 years ago

Yup, same issue happens with just SecretRoomsMod. fml-junk-earlystartup.log latest.log

As I said, it seems to only happen on a dedicated server. See if you yourself can reproduce it with that - just a local dedicated server. Then try to connect and disconnect a few times, together with going back and forth from the Nether

Wyn-Price commented 6 years ago

Ok try this. If this still slows down then ill have to do more investigating

Lordmau5 commented 6 years ago

Still happening :/ fml-junk-earlystartup.log latest.log

Wyn-Price commented 6 years ago

Ok thats intresting. Its nothing to do with the packet handling as i removed all of that in the version I sent you.

As for replicating it, ive set up a dedicated server, and left and rejoined multiple times ,going back and forth from the nether. I cant seem to replicate it

Wyn-Price commented 6 years ago

OK ive removed the IChunkRenderFactory from being loaded. See if this makes any diffrence

Lordmau5 commented 6 years ago

Suddenly I can join in less than 2 seconds, that's... something I'm not used to because every mod just messes with the loading haha

Anyway, yea, it doesn't seem to happen anymore now.

Wyn-Price commented 6 years ago

Ok so its somthing to do with the custom rendering system. Ill slowly add more and more of the code untill it breaks, so then I know what part is working. How does this build work. Also, while going through my code, I noticed an error that could be causes with vbo not being eneabled, whether off in the settings or not supported by the system. If the build i sent works, could you try this build

Lordmau5 commented 6 years ago

First build worked fine; No issues.

With the 2nd build however it took me 18 seconds to switch dimensions. I have the feeling the packet is not optimized very well, is it?

//EDIT: Oh right, I'm currently testing the connect / disconnect stuff. Give me a minute //EDIT2: That was quick. On the 2nd attempt of connecting it already took too long and threw me off the server.

Wyn-Price commented 6 years ago

The packet is somthing I finished writing at around 2am. However, in one of the builds I sent you, the packet was removed and still it causes issues. If the first worked, and the second didnt, I think i have some idea of where the issue may be. Does this build solve anything

Lordmau5 commented 6 years ago

Takes at least 10 seconds to switch dimensions again. 2nd attempt at trying to connect, once again, took too long and threw me off.

I checked VisualVM again and it seems that FakeChunkRenderFactory.func_178158_a / VboChunkFactory.func_178158_a (whatever that method is) is taking up a crapload of time whenever I join or switch dimensions.

Dimension switching: image

Joining: image


Checking the file... Why are you iterating over all methods in the old render class, setting them to accessible, invoking them, and then setting them inaccessible again? Is this necessary?

Wyn-Price commented 6 years ago

Ok thats intresting. This build might fix issues. If it does then ill still need to do more testing

Lordmau5 commented 6 years ago

I'll make sure to test it once I'm back home in like an hour.

Also, do you perhaps have Discord? Would make communication a lot easier than this.

If so, feel free to send me a friend request: Lordmau5#7184

Wyn-Price commented 6 years ago

Ok i sent you a request.