Detach from JNI before exiting the GPU thread. (flutter/engine#5231)

The GPU thread calls into Java via JNI in order to update external textures.

Fixes https://github.com/flutter/flutter/issues/17329
This commit is contained in:
Jason Simmons
2018-05-11 11:42:19 -07:00
committed by GitHub
parent a911ad0a97
commit 6431f174d4

View File

@@ -34,11 +34,12 @@ AndroidShellHolder::AndroidShellHolder(
thread_host_ = {thread_label, ThreadHost::Type::UI | ThreadHost::Type::GPU |
ThreadHost::Type::IO};
// Detach from JNI when the UI thread exits.
thread_host_.ui_thread->GetTaskRunner()->PostTask(
[key = thread_destruct_key_]() {
FXL_CHECK(pthread_setspecific(key, reinterpret_cast<void*>(1)) == 0);
});
// Detach from JNI when the UI and GPU threads exit.
auto jni_exit_task([key = thread_destruct_key_]() {
FXL_CHECK(pthread_setspecific(key, reinterpret_cast<void*>(1)) == 0);
});
thread_host_.ui_thread->GetTaskRunner()->PostTask(jni_exit_task);
thread_host_.gpu_thread->GetTaskRunner()->PostTask(jni_exit_task);
fml::WeakPtr<PlatformViewAndroid> weak_platform_view;
Shell::CreateCallback<PlatformView> on_create_platform_view =