[Mod installer] Try to attach JNI thread anyways

This commit is contained in:
khanhduytran0 2020-11-05 18:03:39 +07:00
parent 189793020c
commit 58bb44f89a
3 changed files with 8 additions and 2 deletions

View File

@ -91,7 +91,7 @@ public class AWTCanvasView extends TextureView implements TextureView.SurfaceTex
if (attached) {
drawing = JREUtils.renderAWTScreenFrame(canvas, mWidth, mHeight);
}
canvas.drawText("FPS: " + fps() + ", attached=" + attached + ", drawing=" + drawing, 50, 50, fpsPaint);
canvas.drawText("FPS: " + (Math.round(fps() * 10) / 10) + ", attached=" + attached + ", drawing=" + drawing, 50, 50, fpsPaint);
mSurface.unlockCanvasAndPost(canvas);
} catch (Throwable th) {

View File

@ -8,7 +8,10 @@
// TODO: check for memory leaks
int printed = 0;
JNIEXPORT jboolean JNICALL Java_net_kdt_pojavlaunch_JREUtils_renderAWTScreenFrame(JNIEnv* env, jclass clazz, jobject canvas, jint width, jint height) {
if (runtimeJNIEnvPtr_ANDROID == NULL) return JNI_FALSE;
if (runtimeJNIEnvPtr_ANDROID == NULL) {
if (runtimeJavaVMPtr == NULL) return JNI_FALSE;
(*runtimeJavaVMPtr)->AttachCurrentThread(runtimeJavaVMPtr, &runtimeJNIEnvPtr_ANDROID, NULL);
}
int *rgbArray;
jintArray jreRgbArray, androidRgbArray;

View File

@ -55,6 +55,9 @@ void JNI_OnUnload(JavaVM* vm, void* reserved) {
DetachCurrentThread(vm);
*/
androidJNIEnvPtr_JRE = NULL;
runtimeJNIEnvPtr_ANDROID = NULL;
}
#define ADD_CALLBACK_WWIN(NAME) \