Skip to content

Commit

Permalink
Search objc pool functions more agressively
Browse files Browse the repository at this point in the history
  • Loading branch information
olonho committed Jul 30, 2021
1 parent b991173 commit 371455b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions skiko/src/jvmMain/objectiveC/macos/MetalRedrawer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#import <jawt.h>
#import <jawt_md.h>


#include <dlfcn.h>

#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import <Metal/Metal.h>
Expand Down Expand Up @@ -110,18 +113,26 @@ JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_makeMeta
return (jlong) renderTarget;
}

extern "C" void* objc_autoreleasePoolPush(void);
extern "C" void objc_autoreleasePoolPop(void*);
typedef void* (*objc_autoreleasePoolPush_t)(void);
typedef void (*objc_autoreleasePoolPop_t)(void*);

JNIEXPORT jlong JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_startRendering(
JNIEnv * env, jobject redrawer)
{
static objc_autoreleasePoolPush_t objc_autoreleasePoolPush = NULL;
if (objc_autoreleasePoolPush == NULL) {
objc_autoreleasePoolPush = (objc_autoreleasePoolPush_t)dlsym(RTLD_DEFAULT, "objc_autoreleasePoolPush");
}
return (jlong)objc_autoreleasePoolPush();
}

JNIEXPORT void JNICALL Java_org_jetbrains_skiko_redrawer_MetalRedrawer_endRendering(
JNIEnv * env, jobject redrawer, jlong handle)
{
static objc_autoreleasePoolPop_t objc_autoreleasePoolPop = NULL;
if (objc_autoreleasePoolPop == NULL) {
objc_autoreleasePoolPop = (objc_autoreleasePoolPop_t)dlsym(RTLD_DEFAULT, "objc_autoreleasePoolPop");
}
objc_autoreleasePoolPop((void*)handle);
}

Expand Down

0 comments on commit 371455b

Please sign in to comment.