Android backend improvements and fixup (WIP)#2727
Android backend improvements and fixup (WIP)#2727riccardobl wants to merge 2 commits intojMonkeyEngine:masterfrom
Conversation
Co-authored-by: Copilot <copilot@github.com>
|
🖼️ Screenshot tests have failed. The purpose of these tests is to ensure that changes introduced in this PR don't break visual features. They are visual unit tests. 📄 Where to find the report:
✅ If you did mean to change things: ✨ If you are creating entirely new tests: Note; it is very important that the committed reference images are created on the build pipeline, locally created images are not reliable. Similarly tests will fail locally but you can look at the report to check they are "visually similar". See https://github.com/jMonkeyEngine/jmonkeyengine/blob/master/jme3-screenshot-tests/README.md for more information Contact @richardTingle (aka richtea) for guidance if required |
There was a problem hiding this comment.
Code Review
This pull request updates the Android implementation to support OpenGL ES 3.0, migrates to AndroidX, and improves the Android harness fragment. It also refactors texture format handling and mipmap generation to be more robust across different hardware. I have identified two issues: the error dialog in AndroidHarnessFragment lacks a dismiss action, and the EGL extension check in OGLESContext is susceptible to false positives.
| requireActivity().runOnUiThread(new Runnable() { | ||
| @Override | ||
| public void run() { | ||
| AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); | ||
| builder.setTitle(finalTitle); | ||
| builder.setPositiveButton("Kill", AndroidHarnessFragment.this); | ||
| builder.setMessage(finalMsg); | ||
|
|
||
| AlertDialog dialog = builder.create(); | ||
| AlertDialog dialog = new AlertDialog.Builder(requireActivity()) | ||
| .setTitle(finalTitle) | ||
| .setMessage(finalMessage) | ||
| .create(); | ||
| dialog.show(); | ||
| } | ||
| }); |
There was a problem hiding this comment.
The error dialog created in handleError does not provide any action for the user to dismiss it or close the application. This is a regression from the previous implementation which had a Kill button. Without a way to close the app, the user is forced to kill the process through the OS, which is a poor user experience.
requireActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
AlertDialog dialog = new AlertDialog.Builder(requireActivity())
.setTitle(finalTitle)
.setMessage(finalMessage)
.setPositiveButton(android.R.string.ok, (d, w) -> {
if (app != null) {
app.stop(true);
}
requireActivity().finish();
})
.create();
dialog.show();
}
});| private static boolean hasExtension(EGL10 egl, EGLDisplay display, String extension) { | ||
| String extensions = egl.eglQueryString(display, EGL10.EGL_EXTENSIONS); | ||
| return extensions != null && extensions.contains(extension); | ||
| } |
There was a problem hiding this comment.
The hasExtension method uses String.contains() to check for the presence of an EGL extension. This can lead to false positives if an extension name is a substring of another (e.g., checking for EGL_IMG_context_priority could incorrectly match EGL_IMG_context_priority_foo). A more robust check is needed to ensure only exact matches are considered.
private static boolean hasExtension(EGL10 egl, EGLDisplay display, String extension) {
String extensions = egl.eglQueryString(display, EGL10.EGL_EXTENSIONS);
if (extensions == null) {
return false;
}
// Check for a full word match.
return (" " + extensions + " ").contains(" " + extension + " ");
}
This brings the android backend up to par with the desktop ~GL3 backend.
After this PR the android renderer will use GLES3+ only, and support android 11+.
WIP