CCBlueX / LiquidLauncher

The official Minecraft launcher for LiquidBounce
GNU General Public License v3.0
141 stars 24 forks source link

[BUG] Scripts are very slow #241

Open fineless71 opened 7 months ago

fineless71 commented 7 months ago

LiquidBounce Branch

Nextgen

LiquidBounce Build/Version

4a5efac

Operating System

Linux

Minecraft Version

1.20.4

Describe the bug

Accessing some Java stuff from scripts (most notably player) kills my FPS, and is unbearably slow. I see a log about Execution only in interpreted mode will strongly impact the guest application performance. from GraalVM (but the page it tells me to go to shows "Page not found", of course not LB's fault). Not everything seems to have this issue, some things like client.displayChatMessage is fine.

Steps to reproduce

Try this simple script, it brings me from 60 fps to 1-2 when moving around:

module.on("playerTick", () => {
    if (!mc.player.onGround && mc.player.velocity.y < 0)
        mc.player.velocity.y = 0;
});

Client Log

[engine] WARNING: The polyglot context is using an implementation that does not support runtime compilation.
The guest application code will therefore be executed in interpreted mode only.
Execution only in interpreted mode will strongly impact the guest application performance.
For more information on using GraalVM see https://www.graalvm.org/java/quickstart/.
To disable this warning the '--engine.WarnInterpreterOnly=false' option or use the '-Dpolyglot.engine.WarnInterpreterOnly=false' system property.

Screenshots

No response

1zun4 commented 7 months ago

I think the only thing we can do is to use GraalVM in the LiquidLauncher.

fineless71 commented 7 months ago

I hope this can be fixed another way. The following performs fine for example:

module.on("playerTick", () => {
    client.displayChatMessage("Speed: " + movementUtil.speed());
    client.displayChatMessage("Speed: " + movementUtil.speed());
    client.displayChatMessage("Speed: " + movementUtil.speed());
});

What I originally thought was going on is that when mc.player is used, it first needs to convert the entire mc object to js, which is huge and probably takes a while (and maybe even everything it holds), and then player as well. But onGround seems to perform ok-ish, while velocity is very bad. So I have no idea. But I feel even in interpreted mode it still shouldn't bring me to 1 fps..

Although I agree that LiquidLauncher should use GraalVM as it could only help