stride
stride copied to clipboard
OpenGL ES 2 support dropped without official notice
Release Type: Official Release
Version: 4.1.0.1838 and onwards
Platform(s): Android
Describe the bug As of this commit in Oct 8, 2019, [Graphics] Bye OpenGL ES 2.0! ES 2 was dropped, but the engine technically did not notice this properly and you just get random/cryptic graphics errors.
Expected behavior Either the engine needs to not allow ES 2 (which seems to be planned already), or at least documentation should be updated to say not use this since it's been dropped for a while yet the option has persisted for so long.
Additional context When Stride has a graphics profile at ES3 and above, it will check your hardware's support level, then drop it's profile to the hardware's level. eg. If your Android device only supports ES2 yet your Game Settings was ES3, it will set to ES2 - however note that ES2 does not work in Stride so you just get a random app crash.
This is especially noticeable on Android emulators, which default to only ES2 level for API level less than 33 (if you make an Android emulator with 33 or higher, it should (theoretically) use ES3 or higher, assuming your hardware supports it).
If you use an API less than 33, manually enable it:
Current workaround to detect and prevent app from continuing on Android (not battle tested, use at your own risk), in your GAMENAMEActivity.cs
file:
using Android.App;
using Android.Content.PM;
using Android.OS;
using Silk.NET.Windowing;
using Stride.Engine;
using Stride.Starter;
using System;
namespace AnMyGame_4_2_0_2122
{
[Activity(MainLauncher = true,
Icon = "@mipmap/gameicon",
ScreenOrientation = ScreenOrientation.Portrait,
Theme = "@android:style/Theme.NoTitleBar",
ConfigurationChanges = ConfigChanges.UiMode | ConfigChanges.Orientation | ConfigChanges.KeyboardHidden | ConfigChanges.ScreenSize)]
public class AnMyGame_4_2_0_2122Activity : StrideActivity
{
private bool esVersionFailed;
protected Game Game;
protected override void OnRun()
{
if (esVersionFailed)
{
// Create a dummy view to bypass Stride, but at least run the error dialog we created in OnCreate
var options = default(ViewOptions);
options.API = GraphicsAPI.None;
var view = Silk.NET.Windowing.Window.GetView(options);
view.Run();
view.Dispose();
return;
}
base.OnRun();
Game = new Game();
Game.Run(GameContext);
}
protected override void OnDestroy()
{
Game?.Dispose();
base.OnDestroy();
}
protected override void OnPause()
{
try { base.OnPause(); }
catch (Exception) { } // Crashes when esVersionFailed is true, so just suppress it
}
protected override void OnResume()
{
try { base.OnResume(); }
catch (Exception) { } // Crashes when esVersionFailed is true, so just suppress it
}
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
var activityMananger = (ActivityManager)GetSystemService(ActivityService);
var configInfo = activityMananger.DeviceConfigurationInfo;
const int MinimumOpenGlEsVersion = 0x30000; // Requires at least OpenGL EL 3.0 (note it's in hexadecimal)
esVersionFailed = configInfo.ReqGlEsVersion < MinimumOpenGlEsVersion;
if (esVersionFailed)
{
using var builder = new AlertDialog.Builder(this);
string errorMessage = "Application requires OpenGL ES 3.0 or higher to run.";
#if DEBUG
errorMessage += "\r\nIf running on an emulator, remember to set the renderer to API level to 3.0 or higher in the advanced setting.";
#endif
var dialog = builder
.SetTitle("Unsupported Hardware Error")
.SetMessage(errorMessage)
.SetNeutralButton("OK", (dialog, id) =>
{
// Close the app
FinishAffinity();
})
.Create();
dialog.Show();
}
}
}
}
This will just pop up an error message and you cannot continue further if it does not detect ES3 or higher. Also note the above does not incorporate the Bluetooth permissions solution discussed here which you should also include.
As per https://developer.android.com/develop/ui/views/graphics/opengl/about-opengl#manifest You should also edit the AndroidManifest.xml file and set the ES3 requirement (I believe this will stop apps on the Google Play store from allowing it, but haven't checked it myself).