Project MMO

Project MMO

10M Downloads

Game lags when abilities reach over +800%

markusvisse opened this issue ยท 31 comments

commented

Describe the bug
Seems that when you reach ability exp gain over 800% an show the ability overlay in-game the game starts to lag. If you turn it off the game works fine. So it looks like there must be some massive calculations going on in the background when showing the overlay? In UV modpack it's by default under Left Alt.

Expected behavior
No lag when viewing the stats.

To Reproduce
Steps to reproduce the behavior:

  1. Put on items giving some ability boost in total over 800%
  2. Experience lag

Versions:

  • Minecraft: 1.19.2
  • Loader: Forge-43.1.47
  • PMMO: 1.19.2-0.5.3
  • Modpack: UVision 1.18
commented

I tested this with just forge and pmmo and was unable to reproduce the issue. It is possible this issue only occurs at scale, however the myriad of variables that a modpack can introduce means this requires more reports of this behavior at scale.

commented

I've checked this in the same setup as yours and having a full leather armor giving +420% give me now small frame drop. It's not as bad as anything above 800% but still noticeable.
Is there anything else I can use to boost the bonus to double check it?

commented

i used a custom configuration and just gave dirt a held bonus of 9.0.

commented

I have tested it with this as well and you can see here: https://files.fm/u/b9wamwxyf#/view/dswradu6d after toogling the stats it starts to drop.

commented

@Caltinor Managed to reproduce this:

  1. Install Minecraft 1.19.2
  2. Install Forge-43.1.47
  3. Install PMMO 1.19.2-0.5.3
  4. Create singleplayer game with cheats enabled
  5. Install vanilla datapack from https://github.com/Caltinor/PMMO-Official-Datapack/tree/main/datapacks/vanilla
  6. Give yourself 4 pieces of leather armor
  7. Put them on
  8. Lag city
commented

hmm. you shouldn't need the official datapack for any version anymore. that said, if you are getting lag spikes, then it's definitely a bug that isn't just related to hardware. I'll take a look at this.

commented

The lag only happens when you have the skill readout up. With that gone, the game runs fine. At a guess, something in the way the display calculates NBT bonuses is the culprit.

commented

It's also worth mention that the greater the bonus the greater the lag. In the video there was barely 800-900%, while having few thousands makes it really hard to do anything. Maybe try adding an item with 10k bonus, this should give at least a small lag for you hopefully.

commented

So I thought maybe the forge version may have a role. I was on 43.1.27 and updated to 43.1.47. Still unable to reproduce. I then set my bonus to 50.0 which you can see in the image below. no lag. I'm not sure what's going on here.
image

commented

If it helps, I use MultiMC and here is a download for the instance I used: https://excessive.space/download/1.19.2%20Lag.zip

commented

Same, no lag from those two items. But leather armor using the (old) tag_leather_armor.json that uses nbt_bonuses still does.

If you're using the official datapack then you're creating duplicate code for the NBT bonus and it's running twice. the NBT bonuses for leather are built into the mod so the official datapack is just duplication.

commented

Test No.2: no config aggregation. In this test i have removed the code which grabs all the configurations and provides the bonus value. You will see them render, but you won't be able to set them. This one might be harder to test. I suggest using /pmmo admin @p clear to remove all skills. agility has an 800% bonus and engineering has a 4900% bonus. if this does not solve the issue you should be able to see no lag when there is no xp in anything, some lag once you gain some agility, and massive lag if you give yourself some engineering xp.
pmmo-1.19-0.5.4-noAggregate.zip

I think you both found the issue, but I want to be certain there isn't more.

commented

I can confirm this without the datapack. Created a new world and with your nether star and cookie all works fine. With equipped leather armor + golden axe = lag.

commented

I can confirm this without the datapack. Created a new world and with your nether star and cookie all works fine. With equipped leather armor + golden axe = lag.

๐Ÿค” I may need to optimize the NBT code a bit. ๐Ÿ’ก AHA! I actually came up with a simple solution just now.

commented

Looks fine now. Even with the leather armor. No lag with both agility and engineering. Hope the solution is actually as simple as you have it in mind ๐Ÿ˜„

commented

Test No.2: no config aggregation. In this test i have removed the code which grabs all the configurations and provides the bonus value. You will see them render, but you won't be able to set them. This one might be harder to test. I suggest using /pmmo admin @p clear to remove all skills. agility has an 800% bonus and engineering has a 4900% bonus. if this does not solve the issue you should be able to see no lag when there is no xp in anything, some lag once you gain some agility, and massive lag if you give yourself some engineering xp. pmmo-1.19-0.5.4-noAggregate.zip

I think you both found the issue, but I want to be certain there isn't more.

This fixes it (for the modified nbt_bonuses leather, yes. Though interestingly I just noticed there is still lag when you mouseover the leather armor for stats.

commented

The mouseover is a different gui. the reason it doesn't lag on the skill list is because technically the NBT setting isn't being read. But the tooltip is a different gui, that i didn't modify, so it does read the NBT. So looks like we have two sources of lag. one is the NBT configurations. Independently though, the rendering of the values themselves is causing lag. So i've narrowed that down. I am going to work a bit on both of these and I will get back to each of you with a potential solution. I will also be creating a different issue specifically for the NBT bit so they don't get conflated.

commented

May it be hardware dependant after all? Or some setting in MC? But to be honest I did not change anything after installing this.

commented

I don't think it's hardware dependent. The laptop I use to code on the train is a literal toaster and that had no issues. Here is my proposed solution. I will make test jars which remove what I think is the issue. If you get no lag from that jar, then I know that is where the lag is coming from and we can narrow down from there. Would you all be willing to help in that way?

commented

No problem for me.

commented

Test No.1: no rendering. In this test i have removed the code which renders the bonuses. The bonuses are still there on the server side, but won't be visible to the player. This is to check if the rendering code is the cause. for your test, cookies have an 800% modifier, and a nether star has a 4900% modifier. both are held bonuses.
pmmo-1.19-0.5.4-noRender.zip

commented

Same, no lag from those two items. But leather armor using the (old) tag_leather_armor.json that uses nbt_bonuses still does.

commented

Looks fine for me. No visible lag.

commented

Okay, this is a first attempt at a fix for this issue. In simple terms, this caches most of the calculations related to rendering the list so that they are only performed every 10 ticks instead of every tick.
pmmo-1.19-0.5.4-cachedRender.zip

commented

Not noticing any lag from that one.

commented

woo!! i'll wait for confirmation from @markusvisse as well then i'll commit this and close the issue.

commented

Looking at the leather armor I still have the lag. I am sure I'm using the cachedRender version.

commented

Leather armor is going to still be an issue because i need to optimize the NBT bonuses. can you confirm that regular items that don't use NBT configurations no longer cause lag?

commented

Wait, should I test it with a custom item or do the prevous boost still exist? If they exist then I have no lag with them.

commented

With golden axe seems fine.

commented

you may need a custom item. try with the 9.0 and 50.0 bonuses on any random item or armor piece and see if the issue persists.