Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG/FREEZE] Skilltracker.onChat causes Client Thread to be blocked indefinetly #162

Open
gtulol opened this issue Feb 26, 2024 · 2 comments

Comments

@gtulol
Copy link

gtulol commented Feb 26, 2024

Random frequent freezes led me to profile this issue,
seems to happen from this https://github.com/bowser0000/SkyblockMod/blob/development/src/main/java/me/Danker/features/SkillTracker.java#L63
or maybe the for-each underneath?

jstack -F <PID>
-> https://pastebin.com/eXkVhqX1

important part: Client Thread Stacktrace:

Thread 1: (state = BLOCKED)

  • java.util.regex.Pattern$BmpCharProperty.match(java.util.regex.Matcher, int, java.lang.CharSequence) @bci=16, line=3797 (Compiled frame; information may be imprecise)
  • java.util.regex.Pattern$Curly.match0(java.util.regex.Matcher, int, int, java.lang.CharSequence) @bci=31, line=4250 (Compiled frame)
  • java.util.regex.Pattern$Curly.match(java.util.regex.Matcher, int, java.lang.CharSequence) @bci=54, line=4234 (Compiled frame)
  • java.util.regex.Pattern$Start.match(java.util.regex.Matcher, int, java.lang.CharSequence) @bci=44, line=3461 (Compiled frame)
  • java.util.regex.Matcher.search(int) @bci=86, line=1248 (Compiled frame)
  • java.util.regex.Matcher.find() @bci=65, line=637 (Compiled frame)
  • java.util.regex.Pattern.split(java.lang.CharSequence, int) @bci=31, line=1209 (Compiled frame)
  • java.lang.String.split(java.lang.String, int) @bci=322, line=2368 (Compiled frame)
  • java.lang.String.split(java.lang.String) @bci=3, line=2410 (Compiled frame)
  • me.Danker.features.SkillTracker.onChat(net.minecraftforge.client.event.ClientChatReceivedEvent) @bci=26, line=63 (Compiled frame)
  • net.minecraftforge.fml.common.eventhandler.ASMEventHandler_432_SkillTracker_onChat_ClientChatReceivedEvent.invoke(net.minecraftforge.fml.common.eventhandler.Event) @bci=11 (Compiled frame)
  • net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(net.minecraftforge.fml.common.eventhandler.Event) @bci=70, line=49 (Compiled frame)
  • net.minecraftforge.fml.common.eventhandler.EventBus.post(net.minecraftforge.fml.common.eventhandler.Event) @bci=40, line=140 (Compiled frame)
  • net.minecraftforge.event.ForgeEventFactory.onClientChat(byte, net.minecraft.util.IChatComponent) @bci=14, line=272 (Compiled frame)
  • net.minecraft.client.network.NetHandlerPlayClient.func_147251_a(net.minecraft.network.play.server.S02PacketChat) @bci=17, line=753 (Compiled frame)
  • net.minecraft.network.play.server.S02PacketChat.func_148833_a(net.minecraft.network.play.INetHandlerPlayClient) @bci=2, line=44 (Compiled frame)
  • net.minecraft.network.play.server.S02PacketChat.func_148833_a(net.minecraft.network.INetHandler) @bci=5, line=9 (Compiled frame)
  • net.minecraft.network.PacketThreadUtil$1.redirect$znf000$patcher$ignorePacketsFromClosedConnections(net.minecraft.network.Packet, net.minecraft.network.INetHandler) @bci=22, line=523 (Compiled frame)
  • net.minecraft.network.PacketThreadUtil$1.run() @bci=35, line=22 (Compiled frame)
  • java.util.concurrent.Executors$RunnableAdapter.call() @bci=4, line=511 (Compiled frame)
  • java.util.concurrent.FutureTask.run() @bci=42, line=266 (Compiled frame)
  • net.minecraft.util.Util.func_181617_a(java.util.concurrent.FutureTask, org.apache.logging.log4j.Logger) @bci=1, line=19 (Compiled frame)
  • net.minecraft.client.Minecraft.func_71411_J() @bci=166, line=1014 (Compiled frame)
  • net.minecraft.client.Minecraft.func_99999_d() @bci=61, line=349 (Interpreted frame)
  • net.minecraft.client.main.Main.main(java.lang.String[]) @bci=1068, line=124 (Interpreted frame)
    ...
@hashmapenjoyer
Copy link

hashmapenjoyer commented Sep 21, 2024

Edit: I am an idiot, this is 6 months old. Has this gone away on its own?

When you say freezes, do you mean frame drops or a full-on game crash? If it's just a performance issue, it's possible that precompiling the pattern outside this event handler as a class-level variable would help:

Pattern pattern = Pattern.compile(" {3,}");

And then just use this inside onChat:

String[] actionBarSections = pattern.split(event.message.getUnformattedText());

I have very little experience with modding/java, though, so this is just a guess from a random programmer.

@gtulol
Copy link
Author

gtulol commented Oct 1, 2024

hi, what i mean by freeze: the game locks up completetly and becomes unresponsive due to the main thread (Client Thread) being blocked. i'm not very familiar with precompiling the pattern etc, don't know whether this still is an issue but i would guess, just was barely playing in recent months due to moving but i noticed that i couldn't replicate this bug on JRE 8 subverion 352 as opposed to the default 51 (minecraft launcher "jre-legacy") where implementations of relevant classes changed ¯_(ツ)_/¯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants