Commit 95056dd1 authored by Igor Demin's avatar Igor Demin

Catch render errors on macOs.

Made behaviour similar to Windows/Linux in AWT thread (just log error, don't exit application).

We log only out errors in the render code, because SkiaRenderer will always be called from AWT thread.
parent f6f67b81
......@@ -111,7 +111,7 @@ internal class MacOsOpenGLRedrawer(
}
}
private open class AWTGLLayer(private val containerPtr: Long, setNeedsDisplayOnBoundsChange: Boolean) {
private abstract class AWTGLLayer(private val containerPtr: Long, setNeedsDisplayOnBoundsChange: Boolean) {
@Suppress("LeakingThis")
val ptr = initAWTGLLayer(containerPtr, this, setNeedsDisplayOnBoundsChange)
......@@ -131,8 +131,17 @@ private open class AWTGLLayer(private val containerPtr: Long, setNeedsDisplayOnB
// Called in AppKit Thread
protected open fun canDraw() = true
@Suppress("unused")
private fun performDraw() {
try {
draw()
} catch (e: Throwable) {
e.printStackTrace()
}
}
// Called in AppKit Thread
protected open fun draw() = Unit
protected abstract fun draw()
private external fun isAsynchronous(ptr: Long): Boolean
private external fun setAsynchronous(ptr: Long, isAsynchronous: Boolean)
......
......@@ -61,7 +61,7 @@ JavaVM *jvm = NULL;
static jclass cls = NULL;
static jmethodID method = NULL;
if (!cls) cls = (*env)->GetObjectClass(env, self.javaRef);
if (!method) method = (*env)->GetMethodID(env, cls, "draw", "()V");
if (!method) method = (*env)->GetMethodID(env, cls, "performDraw", "()V");
(*env)->CallVoidMethod(env, self.javaRef, method);
[super drawInCGLContext:ctx pixelFormat:pf forLayerTime:t displayTime:ts];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment