Skip to content

Conversation

codeOwlAI
Copy link
Owner

@codeOwlAI codeOwlAI commented Jun 29, 2025

PR Summary

Refactor JNI Code to Improve Logging and Remove Legacy Workarounds

Overview

This PR refactors the JNI codebase by standardizing logging mechanisms, removing legacy workarounds, and improving function signatures to use explicit parameters instead of global variables.

Change Types

Type Description
Refactor Standardize Android logging to use LOGI macro instead of direct API calls
Refactor Update function signatures to accept explicit parameters
Removal Remove legacy EMUI firmware workaround for old Huawei devices
Refactor Remove environment variable check in Vulkan loading logic

Affected Modules

Module / File Change Description
src/main/jni/ctxbridges/gl_bridge.c Replaced direct Android logging with LOGI macro
src/main/jni/ctxbridges/osm_bridge.c Switched to LOGI macro and changed log level from ERROR to INFO
src/main/jni/ctxbridges/swap_interval_no_egl.c Changed from Android native logging to custom logging implementation
src/main/jni/egl_bridge.c Removed POJAV_ZINK_PREFER_SYSTEM_DRIVER environment check
src/main/jni/input_bridge_v3.c Removed legacy EMUI firmware workaround and updated JNI environment pointer usage
src/main/jni/jvm_hooks/java_exec_hooks.c Updated hookExec() to accept JNIEnv parameter instead of using global variable
src/main/jni/jvm_hooks/lwjgl_dlopen_hook.c Changed installLwjglDlopenHook() signature to include JNIEnv parameter

artdeell and others added 15 commits January 18, 2025 21:51
…erTeam#6510)

* Fix[pojavexec]: remove central JNIEnv variables

These caused some irreliability, as pojavexec isn't guaranteed to be loaded on the same thread as the call to glfwInit

This fixes:
- 1.3-1.5.2 setting their window size to 0,0 (and thus not working correctly)
- Forge for <1.13 not resizing its window

* Fix[egl_bridge]: remove attachEnvs()

* Whoops[input_bridge]: remove unnecessary prints
Allows NIO ZipFs to function on old Android versions
void installLwjglDlopenHook() {
__android_log_print(ANDROID_LOG_INFO, "LwjglLinkerHook", "Installing LWJGL dlopen() hook");
JNIEnv* env = pojav_environ->runtimeJNIEnvPtr_JRE;
void installLwjglDlopenHook(JNIEnv *env) {
Copy link

Choose a reason for hiding this comment

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

🐛 Correctness Issue

Breaking API Change Without Dependency Updates.

The function signature change from installLwjglDlopenHook() to installLwjglDlopenHook(JNIEnv *env) will break all existing callers that don't provide the JNIEnv parameter.

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.

3 participants