fix: Update renderer autoselect

New behavior is as follows.
If below 1.17, use the GL4ES based renderer.
If below 1.17 and modded, use the Mesa renderer (Zink in this case).
If above 1.17 and/or modded, use MobileGlues.
This commit is contained in:
alexytomi
2025-12-29 02:55:28 +08:00
parent e9728b87df
commit c3b671c417

View File

@@ -414,40 +414,28 @@ public class MainActivity extends BaseActivity implements ControlButtonMenuListe
assetVersion = version.assets;
}
} catch (RuntimeException ignored){
runOnUiThread(() -> Toast.makeText(this, R.string.autorendererselectfailed, Toast.LENGTH_LONG).show());
assetVersion = "legacy";
} // If this fails.. oh well.
// Autoselect renderer
if (Tools.LOCAL_RENDERER == null) {
// 25w09a is when HolyGL4ES starts showing a black screen upon world load.
// There is no way to consistently check for that without breaking mod loaders
// for old versions like legacy fabric so we start from 25w07a instead
// 25w07a assets and assetIndex.id is set to 23, 25w08a and 25w09a is 24.
// 1.19.3 snapshots and all future versions restarted assets and assetsIndex.id
// to 1 and started counting up from there
// Previous versions had "1.19" and "1.18" and such, with April Fools versions
// being even more inconsistent like "3D Shareware v1.34" for the 2019 April Fools
// or 1.RV-Pre1 for 2016, thankfully now they don't seem to do that anymore and just
// use the incrementing system they now have
// I could probably read the manifest itself then check which position the `id` field is
// and count from there since its ordered latest to oldest but that uses way more code
// for basically 3 peoples benefit
try {
int assetID = Integer.parseInt(assetVersion);
// Check if below 25w08a
Tools.LOCAL_RENDERER = (assetID <= 23) ? "opengles2" : "opengles_mobileglues";
// Then assume 1.19.2 and below
} catch (NumberFormatException e) { Tools.LOCAL_RENDERER = "opengles2"; }
// Preferably we could detect when it is modded and swap to zink however that would also
// cover optifine and vanilla+ configurations which are relatively common, degrading their
// experience for no reason. We will compromise with just having users do it themselves.
Tools.LOCAL_RENDERER = "opengles2";
// MobileGlues becomes available post 1.17. It has superior compatibility with mods
// while having fairly similar performance performance compared to GL4ES-based forks.
if(assetVersion.matches("\\d+") || // Should match all digits, which is the modern assetVersioning
"1.17".equals(assetVersion) ||
"1.18".equals(assetVersion) ||
"1.19".equals(assetVersion)) Tools.LOCAL_RENDERER = "opengles_mobileglues";
}
if(!Tools.checkRendererCompatible(this, Tools.LOCAL_RENDERER)) {
Tools.RenderersList renderersList = Tools.getCompatibleRenderers(this);
String firstCompatibleRenderer = renderersList.rendererIds.get(0);
Log.w("runCraft","Incompatible renderer "+Tools.LOCAL_RENDERER+ " will be replaced with "+firstCompatibleRenderer);
Tools.LOCAL_RENDERER = firstCompatibleRenderer;
runOnUiThread(() -> Toast.makeText(this, R.string.autorendererselectfailed, Toast.LENGTH_LONG).show());
Tools.releaseRenderersCache();
}