From 6566536c89a9e8646404bd2e671e3e081c181b4a Mon Sep 17 00:00:00 2001 From: Eino-Ville Talvala Date: Fri, 24 Feb 2017 13:07:56 -0800 Subject: [PATCH] Cameraserver: Use multiple hwbinder threads Some interactions between camera service and hwservicemanager require multiple threads to execute without deadlocks, such as calling getService() from within an onRegistered() callback. Increase thread count to 3 to accomodate. Also switch the order of listener registration and legacy provider addition back to what it was originally. Test: No deadlock when camera service is restarted Bug: 35096594 Change-Id: I6def961d5765958fef284c0a1820e903abc851ef --- camera/cameraserver/Android.mk | 1 + camera/cameraserver/main_cameraserver.cpp | 5 ++++- .../libcameraservice/common/CameraProviderManager.cpp | 6 +++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/camera/cameraserver/Android.mk b/camera/cameraserver/Android.mk index 1548e64940..f0a0db0644 100644 --- a/camera/cameraserver/Android.mk +++ b/camera/cameraserver/Android.mk @@ -25,6 +25,7 @@ LOCAL_SHARED_LIBRARIES := \ libutils \ libui \ libbinder \ + libhidltransport \ android.hardware.camera.common@1.0 \ android.hardware.camera.provider@2.4 \ android.hardware.camera.device@1.0 \ diff --git a/camera/cameraserver/main_cameraserver.cpp b/camera/cameraserver/main_cameraserver.cpp index f4be468e4e..3972436a76 100644 --- a/camera/cameraserver/main_cameraserver.cpp +++ b/camera/cameraserver/main_cameraserver.cpp @@ -17,8 +17,8 @@ #define LOG_TAG "cameraserver" //#define LOG_NDEBUG 0 -// from LOCAL_C_INCLUDES #include "CameraService.h" +#include using namespace android; @@ -26,6 +26,9 @@ int main(int argc __unused, char** argv __unused) { signal(SIGPIPE, SIG_IGN); + // Set 3 threads for HIDL calls + hardware::configureRpcThreadpool(3, /*willjoin*/ false); + sp proc(ProcessState::self()); sp sm = defaultServiceManager(); ALOGI("ServiceManager: %p", sm.get()); diff --git a/services/camera/libcameraservice/common/CameraProviderManager.cpp b/services/camera/libcameraservice/common/CameraProviderManager.cpp index c40809f368..f6ad7d7e57 100644 --- a/services/camera/libcameraservice/common/CameraProviderManager.cpp +++ b/services/camera/libcameraservice/common/CameraProviderManager.cpp @@ -54,9 +54,6 @@ status_t CameraProviderManager::initialize(wpregisterForNotifications( /* instance name, empty means no filter */ "", @@ -67,6 +64,9 @@ status_t CameraProviderManager::initialize(wp