Using NP SDK 1.36, Android Studio 3.6 in August 2020, I was able to build and execute machine learning code using NDK with a custom-written JNI, by setting ADSP_LIBRARY_PATH exactly as per the instructions at https://developer.qualcomm.com/docs/snpe/dsp_runtime.html (section "For Android APKs").
Using NP SDK 1.36, Android Studio 4.0 today, testing on a Samsung A70 and a Samsung S8, it seems that the DSP .so libs expect to be able to spawn command shells and such, and it fails. My hypothesis is that as per https://developer.android.com/about/versions/10/behavior-changes-10, untrusted apps can no longer execute code out of the native library dir (that is only my best guess at this point).
In my JNI layer, I can execute zdl::SNPE::SNPEFactory::getLibraryVersion() no problem, which means libSNPE.so is loaded and aceessible. However, even after setting ADSP_LIBRARY_PATH as per the Qualcomm recommended method, the call to zdl::SNPE::SNPEFactory::isRuntimeAvailable(zdl::DlSystem::Runtime_t::DSP) creates a litany of logcat spew in my unit tests (and returns false) (see below)
I do not use the snpe-release.aar package because our application is native code, we expose our native APIs to Java via JNI.
Is there a way to have our native libXYZ.so depend on libSNPE.so and all the SNPE DSP libs, while using snpe-release.aar and platform-validator.aar to deliver the SNPE so files, or is that a recipe for disaster?
Any concrete guidance welcome.
Logcat when running on Samsung A70 with Android 10 (Snapdragon 675):
22 02:44:26.019 9122 9251 D ai.wrnch.api.CJniLayerSnpeInstrumentedTest: In doThisBefore...
01-22 02:44:26.022 9122 9251 D ai.wrnch.api.CJniLayerSnpeInstrumentedTest: Files found in nativeLibraryDir:
01-22 02:44:26.022 9122 9251 D ai.wrnch.api.CJniLayerSnpeInstrumentedTest: Files size: 13
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_dsp_domains.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_dsp_domains_skel.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_dsp_skel.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libwrAPI.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_dsp_domains_system.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libc++_shared.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libwrnchJni.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_dsp_domains_v2.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_dsp_v65_domains_v2_skel.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_dsp_v66_domains_v2_skel.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_adsp.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libSNPE.so
01-22 02:44:26.022 9122 9251 D Files : FileName:libsnpe_dsp_domains_v2_system.so
01-22 02:44:26.064 9122 9251 D ai.wrnch.api.CJniLayerSnpeInstrumentedTest: SNPE Library version is 1.36.0.746
01-22 02:44:26.066 9122 9251 W ai.wrnch.api.test: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:749: Warning: fopen returned 0xd for file fastrpc_shell_3. (Permission denied)
01-22 02:44:26.066 9122 9251 E ai.wrnch.api.test: Error 0xd: open_shell failed for domain 3
01-22 02:44:26.095 9122 9251 I ai.wrnch.api.test: Successfully created user PD on domain 3 (attrs 0x1, debug_trace 0x1)
01-22 02:44:26.095 9122 9251 I ai.wrnch.api.test: fastrpc_perf_init: enabled RPC traces (kernel 0, dsp 0) with frequency 1000
01-22 02:44:26.106 9122 9336 W ai.wrnch.api.test: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:749: Warning: fopen returned 0xd for file testsig-0xa4e23076.so. (Permission denied)
01-22 02:44:26.107 9122 9336 W ai.wrnch.api.test: vendor/qcom/proprietary/commonsys-intf/adsprpc/src/apps_std_imp.c:749: Warning: fopen returned 0xd for file testsig.so. (Permission denied)
01-22 02:44:26.112 9122 9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle_open_domain: dynamic loading failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3 (dlerror segment 0 failed signature verification (0xF4 B) for libsnpe_dsp_v66_domains_v2_skel.so)
01-22 02:44:26.112 9122 9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle64_open failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp
01-22 02:44:26.112 9122 9251 E ai.wrnch.api.test: Error 0x1d: verify_local_handle failed. handle 0x0
01-22 02:44:26.112 9122 9251 E ai.wrnch.api.test: Error 0x1d: get_domain_from_handle failed. handle 0x0
01-22 02:44:26.112 9122 9251 E ai.wrnch.api.test: Error 0x1d: remote_handle64_invoke failed for handle 0x0, method 7 on domain 3 (sc 0x7020200)
01-22 02:44:26.118 9122 9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle_open_domain: dynamic loading failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3 (dlerror segment 0 failed signature verification (0xF4 B) for libsnpe_dsp_v66_domains_v2_skel.so)
01-22 02:44:26.118 9122 9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle64_open failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp
01-22 02:44:26.118 9122 9251 E ai.wrnch.api.test: Error 0x1d: verify_local_handle failed. handle 0x0
01-22 02:44:26.118 9122 9251 E ai.wrnch.api.test: Error 0x1d: get_domain_from_handle failed. handle 0x0
01-22 02:44:26.118 9122 9251 E ai.wrnch.api.test: Error 0x1d: remote_handle64_invoke failed for handle 0x0, method 7 on domain 3 (sc 0x7020200)
01-22 02:44:26.123 9122 9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle_open_domain: dynamic loading failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp on domain 3 (dlerror segment 0 failed signature verification (0xF4 B) for libsnpe_dsp_v66_domains_v2_skel.so)
01-22 02:44:26.123 9122 9251 E ai.wrnch.api.test: Error 0x80000406: remote_handle64_open failed for file:///libsnpe_dsp_v66_domains_v2_skel.so?snpe_dsp_domains_v2_skel_handle_invoke&_modver=1.0&_dom=cdsp
01-22 02:44:26.123 9122 9251 E ai.wrnch.api.test: Error 0x1d: verify_local_handle failed. handle 0x0
01-22 02:44:26.123 9122 9251 E ai.wrnch.api.test: Error 0x1d: get_domain_from_handle failed. handle 0x0
01-22 02:44:26.123 9122 9251 E ai.wrnch.api.test: Error 0x1d: remote_handle64_invoke failed for handle 0x0, method 7 on domain 3 (sc 0x7020200)
any update about this one?
Dear developer,
You might need to add permission of libcdsprpc.so to your Mainifest.xml to recoginze by SELinux.
BR.
Wei
Thank you for your reply.
Can you further explain your answer?
i linked to libcdsprpc.so from native cmake, but still getting