diff --git a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m index f30fa374ddaa..586e824195ce 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m @@ -37,21 +37,24 @@ MTLGC_DestroyMTLGraphicsConfig(jlong pConfigInfo) { J2dTraceLn(J2D_TRACE_INFO, "MTLGC_DestroyMTLGraphicsConfig"); + JNI_COCOA_ENTER(env); + [ThreadUtilities performOnMainThreadWaiting:NO block:^() { + MTLGraphicsConfigInfo *mtlinfo = + (MTLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo); + if (mtlinfo == NULL) { + J2dRlsTraceLn(J2D_TRACE_ERROR, + "MTLGC_DestroyMTLGraphicsConfig: info is null"); + return; + } - MTLGraphicsConfigInfo *mtlinfo = - (MTLGraphicsConfigInfo *)jlong_to_ptr(pConfigInfo); - if (mtlinfo == NULL) { - J2dRlsTraceLn(J2D_TRACE_ERROR, - "MTLGC_DestroyMTLGraphicsConfig: info is null"); - return; - } - - MTLContext *mtlc = (MTLContext*)mtlinfo->context; - if (mtlc != NULL) { - [mtlinfo->context release]; - mtlinfo->context = nil; - } - free(mtlinfo); + MTLContext *mtlc = (MTLContext*)mtlinfo->context; + if (mtlc != NULL) { + [mtlinfo->context release]; + mtlinfo->context = nil; + } + free(mtlinfo); + }]; + JNI_COCOA_EXIT(env); } JNIEXPORT jboolean JNICALL @@ -114,7 +117,6 @@ Java_sun_java2d_metal_MTLGraphicsConfig_getMTLConfigInfo (JNIEnv *env, jclass mtlgc, jint displayID, jstring mtlShadersLib) { - __block MTLContext* mtlc = nil; __block MTLGraphicsConfigInfo* mtlinfo = nil; JNI_COCOA_ENTER(env); @@ -123,7 +125,7 @@ [ThreadUtilities performOnMainThreadWaiting:YES block:^() { - mtlc = [[MTLContext alloc] initWithDevice:displayID + MTLContext* mtlc = [[MTLContext alloc] initWithDevice:displayID shadersLib:path]; if (mtlc != 0L) { // create the MTLGraphicsConfigInfo record for this context