algolia / algoliasearch-client-android

Algolia Search API Client for Android
MIT License
99 stars 29 forks source link

Crash in production - dlopen failed - Permission denied #576

Closed benvonhandorf closed 5 years ago

benvonhandorf commented 5 years ago

We have seen this crash in production for some time but with a recent release of our application the rate seems to have spiked.

When creating the OfflineClient object, we're seeing a spike in crashes.

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: couldn't map "/mnt/asec/com.alltrails.alltrails-1/split_config.armeabi_v7a.apk!/lib/armeabi-v7a/libalgoliasearchofflinecore.so" segment 2: Permission denied
       at java.lang.Runtime.loadLibrary0(Runtime.java:1016)
       at java.lang.System.loadLibrary(System.java:1657)
       at com.algolia.search.offline.core.Sdk.(Sdk.java:35)
       at com.algolia.search.offline.core.Sdk.getInstance(Sdk.java:50)
       at com.algolia.search.saas.OfflineClient.(OfflineClient.java:128)
       at com.algolia.search.saas.OfflineClient.(OfflineClient.java:92)
       at com.algolia.search.saas.OfflineClient.(OfflineClient.java:92)

Note: segment number in exception varies: 0 seems most common. We also see different ABI versions in the logs including arm64_v8a.

Dependency versions:

    implementation 'com.algolia:algoliasearch-offline-android:3.26.1'

    implementation 'com.algolia:algoliasearch-offline-core-android:1.2.2'

I'm working on upgrading the offline-android version to 3.27.0 but there was nothing relevant listed in the release notes so I presume we will still see the issue.

To Reproduce: We have not yet replicated the crash internally but have seen a large spike through our production crash reporting.

Environment: The crash seems to primarily show up on Android 8 devices (82%) and seems unusually weighted to LGE (39%) and OnePlus (20%) devices, far exceeding the proportions of those manufacturers in our install base.

Application is a mix of Kotlin and Java. The class immediately leading into this is Kotlin. Target SDK is 28. Application is being deployed as an App Bundle, which is new with this version. As previously stated, this crash existed on previous versions of the app but has seen a large uptick with the new release: we're at 5% rollout of the new version and saw 54 crashes yesterday, with the highest previous day for this crash being 16.

robertmogos commented 5 years ago

Hey @benvonhandorf . I will bootstrap a Kotlin app to with offline to test it out

robertmogos commented 5 years ago

Hu @benvonhandorf . Did you find any way to reproduce it locally? We bootstrapped a kotlin app with offline and for now seems to work. Do you know if the crash is when opening the app or when doing some specific operation ?

robertmogos commented 5 years ago

Seems that someone referenced our issue on android-ndk https://github.com/android-ndk/ndk/issues/979

benvonhandorf commented 5 years ago

@robertmogos Agreed, I saw that and I've started posting in that thread. We haven't been able to replicate the crash internally and we have not heard any error reports from users so there is a possibility this is either occurring in the background or not happening on every launch.

This does seem to occur mostly on LGE devices and almost exclusively on Android 8.X devices.

The crash is happening for us as part of the application start up code when we attempt to create the OfflineClient object which would be our first call into the sdk.

benvonhandorf commented 5 years ago

Based on the Android bug linked through that NDK issue, we added android.bundle.enableUncompressedNativeLibs=false to our gradle.properties and it appears to have resolved the issue for us.

Closing the issue as it is not Algolia related.

PLNech commented 5 years ago

Hi @benvonhandorf, thanks for sharing your investigation and the solution you found. Hopefully it will help others should they face the same issue.

Let us know if you have any further issue or feedback related to this library!

deepak786 commented 5 years ago

Hi @benvonhandorf I'm also facing the issue with the library https://github.com/barteksc/AndroidPdfViewer. So I tried to add android.bundle.enableUncompressedNativeLibs=false in the gradle.properties file. But I have the following warning WARNING: The option setting 'android.bundle.enableUncompressedNativeLibs=false' is experimental and unsupported. The current default is 'true'.

What should I do?

PLNech commented 5 years ago

Hi @deepak786, thanks for reaching out. I'll let @benvonhandorf reply to your question, as there might be a difference between your setups (e.g. Gradle version). This being said, what experimental and unsupported means for Gradle is still an open question: it's unclear from Gradle docs if it means the setting is ignored.

benvonhandorf commented 5 years ago

@deepak786 There was a comment in the google issuetracker thread here: https://issuetracker.google.com/issues/127691101 that they are planning on removing the warning. The work item for removing the warning is here: https://issuetracker.google.com/issues/132721337 and apparently it is in 3.6 canary at this point.

Based on that we have been ignoring the warning and the issue has been entirely resolved for us with no detected follow-on issues.

deepak786 commented 5 years ago

@benvonhandorf So I can ignore this warning and can create a bundle to upload it on Play Store with Studio Version 3.4 or should I use the 3.6 canary version.

This is important. I need to update the app.