From 3ec12d4c3f0b9279eb7f28c41a6194f8dad2b8ed Mon Sep 17 00:00:00 2001 From: Jason Simmons Date: Fri, 11 May 2018 11:42:19 -0700 Subject: [PATCH] Detach from JNI before exiting the GPU thread. (#5231) The GPU thread calls into Java via JNI in order to update external textures. Fixes https://github.com/flutter/flutter/issues/17329 --- shell/platform/android/android_shell_holder.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/shell/platform/android/android_shell_holder.cc b/shell/platform/android/android_shell_holder.cc index 1fe085429..15bfdc6ad 100644 --- a/shell/platform/android/android_shell_holder.cc +++ b/shell/platform/android/android_shell_holder.cc @@ -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(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(1)) == 0); + }); + thread_host_.ui_thread->GetTaskRunner()->PostTask(jni_exit_task); + thread_host_.gpu_thread->GetTaskRunner()->PostTask(jni_exit_task); fml::WeakPtr weak_platform_view; Shell::CreateCallback on_create_platform_view = -- GitLab