aboutsummaryrefslogtreecommitdiffstats
path: root/src/newt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2019-12-05 07:38:48 +0100
committerSven Gothel <[email protected]>2019-12-05 07:38:48 +0100
commit033ee4cad3493038480b06f6caf3de015a3e8de7 (patch)
tree205b78ada030137bb4002236bc071b241f4d9999 /src/newt
parent84a2e5a250148d600d48a0dd58e07286a375f616 (diff)
Bug 1405, Bug 1406, Bug 1408: Resolution: Call ReleasePrimitiveArrayCritical(..) in GetPrimitiveArrayCritical(..) code path!egl-gbm
Now that was quite a miss, causing the bugs in the first place! The freeze was caused in the JVM, as this open GetPrimitiveArrayCritical(..) disabled the GC. This was reported via '-Xcheck:jni'. Depending on the system/jvm, the freeze may happen early or only after a while. This code path was not executed with new property 'newt.disable.PointerIcon' set, but from there to finding the missing critical release - a journey: - jstack showed "main" #1 prio=5 os_prio=0 cpu=275.71ms elapsed=51.93s allocated=9710K defined_classes=472 tid=0x00007f7084015000 nid=0x1a39 waiting on condition [0x00007f70897c2000] java.lang.Thread.State: RUNNABLE at jogamp.opengl.es3.GLES3Impl.dispatch_glUniformMatrix4fv1(Native Method) at jogamp.opengl.es3.GLES3Impl.glUniformMatrix4fv(GLES3Impl.java:2585) at jogamp.opengl.es3.GLES3Impl.glUniform(GLES3Impl.java:10713) -- said that this thread was no more running, waiting on condition .. -- glUniformMatrix4fv1 was given an array! - '-Xcheck:jni' gave: Warning: Calling other JNI functions in the scope of Get/ReleasePrimitiveArrayCritical or Get/ReleaseStringCritical -- Now it is clear that the lack of releasing the critical array, returning to Java and then calling other JNI methods caused the Warning - and eventually the freeze.
Diffstat (limited to 'src/newt')
-rw-r--r--src/newt/native/drm_gbm.c35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/newt/native/drm_gbm.c b/src/newt/native/drm_gbm.c
index 637693bff..7fb6ad2c8 100644
--- a/src/newt/native/drm_gbm.c
+++ b/src/newt/native/drm_gbm.c
@@ -53,6 +53,7 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_CreatePoin
(JNIEnv *env, jclass clazz, jlong jgbmDevice, jobject jpixels, jint pixels_byte_offset, jboolean pixels_is_direct,
jint width, jint height, jint hotX, jint hotY)
{
+ void *pixels0 = NULL;
const uint32_t *pixels = NULL;
struct gbm_device * gbmDevice = (struct gbm_device *) (intptr_t) jgbmDevice;
struct gbm_bo *bo = NULL;
@@ -71,10 +72,10 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_CreatePoin
return 0;
}
{
- const char * c1 = (const char *) ( JNI_TRUE == pixels_is_direct ?
- (*env)->GetDirectBufferAddress(env, jpixels) :
- (*env)->GetPrimitiveArrayCritical(env, jpixels, NULL) );
- pixels = (uint32_t *) ( c1 + pixels_byte_offset );
+ pixels0 = ( JNI_TRUE == pixels_is_direct ?
+ (*env)->GetDirectBufferAddress(env, jpixels) :
+ (*env)->GetPrimitiveArrayCritical(env, jpixels, NULL) );
+ pixels = (uint32_t *) ( ((char *) pixels0) + pixels_byte_offset );
}
bo = gbm_bo_create(gbmDevice, 64, 64,
@@ -83,18 +84,20 @@ JNIEXPORT jlong JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_CreatePoin
GBM_BO_USE_CURSOR_64X64 | GBM_BO_USE_WRITE);
if( NULL == bo ) {
ERR_PRINT("cursor.cstr gbm_bo_create failed\n");
- return 0;
- }
-
- // align user data width x height -> 64 x 64
- memset(buf, 0, sizeof(buf)); // cleanup
- for(int i=0; i<height; i++) {
- memcpy(buf + i * 64, pixels + i * width, width * 4);
+ } else {
+ // align user data width x height -> 64 x 64
+ memset(buf, 0, sizeof(buf)); // cleanup
+ for(int i=0; i<height; i++) {
+ memcpy(buf + i * 64, pixels + i * width, width * 4);
+ }
+ if ( gbm_bo_write(bo, buf, sizeof(buf)) < 0 ) {
+ ERR_PRINT("cursor.cstr gbm_bo_write failed\n");
+ gbm_bo_destroy(bo);
+ bo = NULL;
+ }
}
- if ( gbm_bo_write(bo, buf, sizeof(buf)) < 0 ) {
- ERR_PRINT("cursor.cstr gbm_bo_write failed\n");
- gbm_bo_destroy(bo);
- return 0;
+ if ( JNI_FALSE == pixels_is_direct && NULL != jpixels ) {
+ (*env)->ReleasePrimitiveArrayCritical(env, jpixels, pixels0, JNI_ABORT);
}
return (jlong) (intptr_t) bo;
}
@@ -120,8 +123,6 @@ JNIEXPORT jboolean JNICALL Java_jogamp_newt_driver_egl_gbm_DisplayDriver_SetPoin
int ret;
DBG_PRINT( "EGL_GBM.Screen SetPointerIcon0.0: bo %p, enable %d, hot %d/%d, pos %d/%d\n", bo, enable, hotX, hotY, x, y);
- // int drmModeSetCursor(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height);
- // int drmModeSetCursor2(int fd, uint32_t crtcId, uint32_t bo_handle, uint32_t width, uint32_t height, int32_t hot_x, int32_t hot_y);
if( enable ) {
ret = drmModeSetCursor2(drmFd, crtc_id, bo_handle, 64, 64, hotX, hotY);
if( ret ) {