Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8263788: JavaFX application freezes completely after some time when using the WebView #461

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,5 @@ private static void fwkScheduleDispatchFunctions() {
});
}

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

private static native void twkScheduleDispatchFunctions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
kevinrushforth marked this conversation as resolved.
Show resolved Hide resolved

void scheduleDispatchFunctionsOnMainThread()
{
AttachThreadAsNonDaemonToJavaEnv autoAttach;
Expand Down Expand Up @@ -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" {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down