Sodium

Sodium

44M Downloads

Sodium Breaks Distant Horizons Instanced Rendering on Mac

jeseibel opened this issue ยท 4 comments

commented

Bug Description

Having Sodium installed on a Apple Silicon mac causes Distant Horizons' use of glDrawElementsInstanced to crash the game.
This issue doesn't occur with just Sodium or Distant Horizons installed.

If there's no easy fix this problem I'll just disable instanced rendering on mac when Sodium is detected (it will reduce performance, but should prevent crashing).

Crash log stack trace:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00000001ee5b9150, pid=35486, tid=259
#
# JRE version: OpenJDK Runtime Environment Microsoft-9388422 (21.0.3+9) (build 21.0.3+9-LTS)
# Java VM: OpenJDK 64-Bit Server VM Microsoft-9388422 (21.0.3+9-LTS, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# C  [GLEngine+0x11f150]  gleRunVertexSubmitImmediate+0x18cc
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

...

Stack: [0x000000016f050000,0x000000016f84c000],  sp=0x000000016f844ac0,  free space=8146k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C  [GLEngine+0x11f150]  gleRunVertexSubmitImmediate+0x18cc
C  [GLEngine+0xb8d50]  gleDrawArraysOrElements_ExecCore+0x270
C  [GLEngine+0xba170]  glDrawElementsInstanced_ACC_GL3Exec+0x1f8
C  0xa71180010deb8a88
j  org.lwjgl.opengl.GL31C.glDrawElementsInstanced(IIIJI)V+6
j  org.lwjgl.opengl.GL31.glDrawElementsInstanced(IIIJI)V+6
j  com.seibel.distanthorizons.core.render.renderer.generic.GenericObjectRenderer.renderBoxGroupInstanced(Lcom/seibel/distanthorizons/api/interfaces/override/rendering/IDhApiGenericObjectShaderProgram;Lcom/seibel/distanthorizons/api/methods/events/sharedParameterObjects/DhApiRenderParam;Lcom/seibel/distanthorizons/core/render/renderer/generic/RenderableBoxGroup;Lcom/seibel/distanthorizons/core/util/math/Vec3d;)V+209
j  com.seibel.distanthorizons.core.render.renderer.generic.GenericObjectRenderer.render(Lcom/seibel/distanthorizons/api/methods/events/sharedParameterObjects/DhApiRenderParam;Lcom/seibel/distanthorizons/core/wrapperInterfaces/minecraft/IProfilerWrapper;Z)V+294

Related links:

Distant Horizons Gitlab Issue:
https://gitlab.com/jeseibel/distant-horizons/-/issues/793

Public Distant Horizons Discord conversation about the issue:
https://www.answeroverflow.com/m/1273612018506534973

Reproduction Steps

Hardware:

  • Apple silicon mac

Install:

  • Distant Horizons 2.2.0 or newer
  • Sodium 0.5
  • Indium
  • Fabric API

Testing:

  1. Confirm DH generic rendering and clouds are enabled under DH config -> advanced -> graphics -> generic rendering
  2. load into any world.
  3. Once DH starts rendering the game should crash.

Log File

latest.log

Crash Report

hs_err_pid35486.log

commented

Just out of interest, do you know if this also happens on macs with intel iGPUs or AMD dGPUs? (There's also Macs with nvidia cards but those are largely irrelevant) The Apple Silicon drivers are observed to be generally more problematic

commented

Looking at the crash log it appears this machine was a MacBookPro18,3 which I think has a dedicated GPU ( https://support.apple.com/en-us/111902 ).

Also, one thing I just remembered: there were reports from one user that the instanced rendering didn't appear at all (didn't crash, the objects just didn't appear on screen). Unfortunately I don't know if they had any other mods installed.
Maybe instanced rendering is always broken on Mac but Sodium causes the renderer to crash when called? That would be helpful for troubleshooting if that was the case. Although that also means GLCapabilities.GL_ARB_instanced_arrays or GLCapabilities.OpenGL33 is returning the wrong value if instanced rendering aren't supported.

commented

It should be noted that the drivers for Apple Silicon vs the AMD dGPU/intel iGPUs are different enough that they can generally be considered separate in terms of what bugs and quirks they have. That's why it's relevant to know what exact computer was having the issue here.

commented

I used sodium and distant horizons on a mac with an m1 chip, which crashed. Searched for glDrawElementsInstanced in the java error report and found it mentioned. So not sure if that helps