Skip to content

Android backend improvements and fixup (WIP)#2727

Draft
riccardobl wants to merge 5 commits intojMonkeyEngine:masterfrom
riccardobl:androidfixup
Draft

Android backend improvements and fixup (WIP)#2727
riccardobl wants to merge 5 commits intojMonkeyEngine:masterfrom
riccardobl:androidfixup

Conversation

@riccardobl
Copy link
Copy Markdown
Member

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

@riccardobl riccardobl changed the title Android backend improvement and fixup Android backend improvements and fixup (WIP) Apr 29, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 29, 2026

🖼️ 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 didn't expect to change anything visual:
Fix your changes so the screenshot tests pass.

If you did mean to change things:
Review the replacement images in jme3-screenshot-tests/build/changed-images to make sure they really are improvements and then replace and commit the replacement images at jme3-screenshot-tests/src/test/resources.

If you are creating entirely new tests:
Find the new images in jme3-screenshot-tests/build/changed-images and commit the new images at jme3-screenshot-tests/src/test/resources.

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

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread jme3-android/src/main/java/com/jme3/app/AndroidHarnessFragment.java
Co-authored-by: Copilot <copilot@github.com>
riccardobl and others added 2 commits April 30, 2026 15:01
Co-authored-by: Copilot <copilot@github.com>
@riccardobl
Copy link
Copy Markdown
Member Author

@gemini-code-assist new review pls

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modernizes the Android backend by transitioning to OpenGL ES 3.0 and AndroidX, refactoring core components like AndroidHarnessFragment and OGLESContext. Key enhancements include a new sRGB blit conversion for gamma correction, improved EGL configuration selection, and a more robust MipMapGenerator with alpha-weighted filtering. Reviewers suggested implementing glShaderStorageBlockBinding via the GLES31 API, enabling CPU mipmap fallbacks for power-of-two resized images, and utilizing dynamic depth format selection for the linear framebuffer to improve device compatibility.

Comment thread jme3-android/src/main/java/com/jme3/renderer/android/AndroidGL.java
Comment thread jme3-core/src/main/java/com/jme3/renderer/opengl/GLRenderer.java Outdated
riccardobl and others added 2 commits April 30, 2026 17:42
Co-authored-by: Copilot <copilot@github.com>
@riccardobl
Copy link
Copy Markdown
Member Author

@gemini-code-assist new review pls

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces significant updates to the Android build configuration and rendering pipeline, including improved NDK discovery, support for OpenGL ES 3.0, and a new linear-to-sRGB blit conversion mechanism. I have reviewed the changes and provided a suggestion to improve the efficiency and readability of the NDK discovery logic in build.gradle by deduplicating SDK directory searches.

Comment thread build.gradle
Comment on lines +196 to +214
def localProperties = file('local.properties')
if (localProperties.isFile()) {
Properties properties = new Properties()
localProperties.withInputStream { properties.load(it) }
if (properties.getProperty('ndk.dir')) {
ndkCandidates << file(properties.getProperty('ndk.dir'))
}
if (properties.getProperty('sdk.dir')) {
ndkCandidates.addAll(findAndroidNdkDirs(file(properties.getProperty('sdk.dir'))))
}
}

if (System.env.ANDROID_HOME) {
ndkCandidates.addAll(findAndroidNdkDirs(file(System.env.ANDROID_HOME)))
}
if (System.env.ANDROID_SDK_ROOT) {
ndkCandidates.addAll(findAndroidNdkDirs(file(System.env.ANDROID_SDK_ROOT)))
}
ndkCandidates.addAll(findAndroidNdkDirs(file("${System.properties['user.home']}/Android/Sdk")))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The current logic for finding the NDK by searching through various SDK directories can be made more efficient and readable. It may perform redundant searches if multiple environment variables or properties point to the same SDK location.

A better approach would be to first collect all potential SDK directory paths, deduplicate them, and then iterate over the unique paths to find NDKs. This avoids unnecessary file system operations and makes the logic clearer. A similar pattern is already used in jme3-android-examples/build.gradle for locating adb.

    def sdkDirs = []
    def localProperties = file('local.properties')
    if (localProperties.isFile()) {
        Properties properties = new Properties()
        localProperties.withInputStream { properties.load(it) }
        if (properties.getProperty('ndk.dir')) {
            ndkCandidates << file(properties.getProperty('ndk.dir'))
        }
        if (properties.getProperty('sdk.dir')) {
            sdkDirs << file(properties.getProperty('sdk.dir'))
        }
    }

    if (System.env.ANDROID_HOME) {
        sdkDirs << file(System.env.ANDROID_HOME)
    }
    if (System.env.ANDROID_SDK_ROOT) {
        sdkDirs << file(System.env.ANDROID_SDK_ROOT)
    }
    sdkDirs << file("${System.properties['user.home']}/Android/Sdk")

    sdkDirs.unique { it.canonicalPath }.each { sdkDir ->
        ndkCandidates.addAll(findAndroidNdkDirs(sdkDir))
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant