Baritone AI pathfinder

Baritone AI pathfinder

72.7k Downloads

Stop using deprecated glPushAttrib in XZ Beacon rendering

andre4ik3 opened this issue ยท 12 comments

commented

When rendering the XZ goal as a beacon (with renderGoalXZBeacon set to true, in the function drawDankLitGoalBox), it uses the deprecated glPushAttrib. I think it should be updated to not use this, as it is not advised to use it since OpenGL 3.1+ (and in some setups, see below, it can cause a hard JVM crash without so much as a crash report).

Original Issue (click to expand)

Some information

Operating system: macOS Big Sur 11.6.5 (Apple Silicon)
Java version: openjdk 17.0.3 arm64
Minecraft version: 1.18.2 (running natively)
Baritone version: 1.8.3
Other mods (if used): None (i have some but i removed all and it still happens)

Exception, error or logs

Here, I ran it with unoptimized

[20:21:40] [Render thread/INFO]: [CHAT] [Baritone] > goto 0 0
[20:21:40] [Render thread/INFO]: [CHAT] [Baritone] Going to: GoalXZ{x=0,z=0}
FATAL ERROR in native method: Thread[Render thread,10,main]: No context is current or a function that is not available in the current context was called. The JVM will abort execution.
	at org.lwjgl.opengl.GL11.glPushAttrib(Native Method)
	at baritone.utils.PathRenderer.drawDankLitGoalBox(PathRenderer.java:258)
	at baritone.utils.PathRenderer.render(PathRenderer.java:99)
	at baritone.behavior.PathingBehavior.onRenderPass(PathingBehavior.java:565)
	at baritone.event.GameEventHandler.lambda$onRenderPass$6(GameEventHandler.java:107)
	at baritone.event.GameEventHandler$$Lambda$6588/0x0000000800e94aa8.accept(Unknown Source)
	at java.util.concurrent.CopyOnWriteArrayList.forEach([email protected]/CopyOnWriteArrayList.java:807)
	at baritone.event.GameEventHandler.onRenderPass(GameEventHandler.java:107)
	- snip (obfuscated net.minecraft.client stuff) -
	at net.minecraft.client.main.Main.main(Main.java:236)
	at java.lang.invoke.LambdaForm$DMH/0x00000008002d0000.invokeStaticInit([email protected]/LambdaForm$DMH)
	at java.lang.invoke.LambdaForm$MH/0x00000008002d0400.invokeExact_MT([email protected]/LambdaForm$MH)
	at net.fabricmc.loader.impl.game.minecraft.MinecraftGameProvider.launch(MinecraftGameProvider.java:460)
	at net.fabricmc.loader.impl.launch.knot.Knot.launch(Knot.java:74)
	at net.fabricmc.loader.impl.launch.knot.KnotClient.main(KnotClient.java:23)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0([email protected]/Native Method)
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke([email protected]/NativeMethodAccessorImpl.java:77)
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke([email protected]/DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke([email protected]/Method.java:568)
	at org.multimc.onesix.OneSixLauncher.launchWithMainClass(OneSixLauncher.java:210)
	at org.multimc.onesix.OneSixLauncher.launch(OneSixLauncher.java:245)
	at org.multimc.EntryPoint.listen(EntryPoint.java:143)
	at org.multimc.EntryPoint.main(EntryPoint.java:34)

How to reproduce

  1. have a m1 macbook
  2. have minecraft running natively (e.g. ManyMC launcher)
  3. set renderGoalXZBeacon to true
  4. in baritone, do any command that renders a vertical goal box (e.g. goto X Z, explore)
  5. observe instant minecraft hard crash

Modified settings

renderGoalXZBeacon (crashes when true)

Final checklist

  • I know how to properly use check boxes
  • I have included the version of Minecraft I'm running, baritone's version and forge mods (if used).
  • I have included logs, exceptions and / or steps to reproduce the issue.
  • I have not used any OwO's or UwU's in this issue.
commented

I'd blame it on the native part. What ManyMc does is using custom built lwjgl (and possibly others) binaries for arm64 and the exception comes from lwjgl so there's potential for a causal relationship.

commented

Here is the full log. There is no "crash report" as the JVM aborts immediately without running anything else. (ignore disabled mods, they were not loaded)

Full order of things I did:

  1. Load up Minecraft
  2. Open Singleplayer world "New World (1)"
  3. tab out for a second
  4. set renderGoalXZBeacon to true
  5. tab out again
  6. run #explore which immediately crashed the JVM and Minecraft

log.txt

commented

The issue you've got is that the many mc opengl mappings don't seem to support glPushAttrib, there isn't much we can do about this, so really you can only run minecraft non-natively.

commented

Not sure why you needed the full log as there is quite literally no other context than what I've already put lol.

Attach the full log. And use literally any other os.

M1 gets 186 fps when running natively (12 chunks + sodium) and macOS is good for development, many of the tools I have (Nova, Transmit, Xcode, Suspicious Package) simply don't exist on other OSs. But I presume you mean architecture, not OS, as I don't think running it in Windows VM would solve this.

I'd blame it on the native part. What ManyMc does is using custom built lwjgl (and possibly others) binaries for arm64 and the exception comes from lwjgl so there's potential for a causal relationship.

Yeah, I was reading the logs and saw the same thing. However, either they built release 3.2.2 (not some random commit on master) or downloaded some official build (lwjgl > 3 supports arm64), so I don't see why this would be an issue. I'm suspecting that running this under the normal launcher (that is, with Rosetta 2 emulation) would solve the issue, albeit with significantly poorer performance (like 30 fps).

Maybe there is some way to at least prevent the crash. Because here it doesn't even get to generate the crash report lol.

commented

Isn't glPushAttrib deprecated?

commented

yea, I think it might be, was actually just researching some stuff about it. At the moment on normal mc it works, so whilst it still works on normal mc this is most likely be a low priority, however if anyone want to try and change the glPushAttrib then that pr will probably be accepted.

If you rename this to "Stop using glPushAttrib as it is deprecated" then I'll rename this.

commented

Alright

commented

From what I've read and understand, glPushAttrib is basically just a wrapper that does some management stuff for you. Maybe this is a good opportunity for me to learn Java & OpenGL and make a PR :)

commented

Fixed by #4059

commented

Still not fixed on master

commented

Fully resolved by 90f2b39, although vanilla code in 1.12.2 still uses glPushAttrib and glPopAttrib.

commented

Thanks for fixing it anyways (I like cross version consistency).