Skip to content
Permalink
Browse files
8263788: JavaFX application freezes completely after some time when u…
…sing the WebView

Reviewed-by: kcr, ghb
  • Loading branch information
arun-Joseph committed Apr 20, 2021
1 parent 67828ae commit 49d2126e26a32ac7f83525ba3340a4b069b346a2
@@ -36,9 +36,5 @@ private static void fwkScheduleDispatchFunctions() {
});
}

private static boolean fwkIsMainThread() {
return Invoker.getInvoker().isEventThread();
}

private static native void twkScheduleDispatchFunctions();
}
@@ -30,11 +30,20 @@
#include <wtf/MainThread.h>
#include <wtf/RunLoop.h>

#if OS(UNIX)
#include <pthread.h>
#endif

namespace WTF {
static JGClass jMainThreadCls;
static jmethodID fwkIsMainThread;
static jmethodID fwkScheduleDispatchFunctions;

#if OS(UNIX)
static pthread_t mainThread;
#elif OS(WINDOWS)
static ThreadIdentifier mainThread { 0 };
#endif

void scheduleDispatchFunctionsOnMainThread()
{
AttachThreadAsNonDaemonToJavaEnv autoAttach;
@@ -70,38 +79,32 @@ void initializeMainThreadPlatform()
static JGClass jMainThreadRef(env->FindClass("com/sun/webkit/MainThread"));
jMainThreadCls = jMainThreadRef;

fwkIsMainThread = env->GetStaticMethodID(
jMainThreadCls,
"fwkIsMainThread",
"()Z");

ASSERT(fwkIsMainThread);

fwkScheduleDispatchFunctions = env->GetStaticMethodID(
jMainThreadCls,
"fwkScheduleDispatchFunctions",
"()V");

ASSERT(fwkScheduleDispatchFunctions);

#if OS(WINDOWS)
#if OS(UNIX)
mainThread = pthread_self();
#elif OS(WINDOWS)
mainThread = Thread::currentID();
RunLoop::registerRunLoopMessageWindowClass();
#endif
}

bool isMainThreadIfInitialized()
#if OS(UNIX)
bool isMainThread()
{
return isMainThread();
return pthread_equal(pthread_self(), mainThread);
}

#elif OS(WINDOWS)
bool isMainThread()
{
AttachThreadAsNonDaemonToJavaEnv autoAttach;
JNIEnv* env = autoAttach.env();
jboolean isMainThread = env->CallStaticBooleanMethod(jMainThreadCls, fwkIsMainThread);
WTF::CheckAndClearException(env);
return isMainThread == JNI_TRUE;
return mainThread == Thread::currentID();
}
#endif

extern "C" {

@@ -271,10 +271,8 @@ struct Thread::ThreadHolder {
// after Windows terminates other threads. If the terminated
// thread was holding a mutex, trying to lock the mutex causes
// deadlock.
#if !PLATFORM(JAVA)
if (isMainThread())
return;
#endif
if (thread) {
thread->specificStorage().destroySlots();
thread->didExit();

1 comment on commit 49d2126

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 49d2126 Apr 20, 2021

Please sign in to comment.