-
Notifications
You must be signed in to change notification settings - Fork 529
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[monodroid] Work around Android 9+ bug with extractNativeLibs flag (#…
…4993) Fixes: #4983 Context: https://developer.android.com/reference/android/content/pm/ApplicationInfo.html#FLAG_EXTRACT_NATIVE_LIBS Android API-23 added support for [`//application/@android:extractNativeLibs`][0], which allows an app to state that native libs within the `.apk` should *not* be extracted as part of app installation, to save on overall installation size. Support for `extractNativeLibs` was added in 95ca102 and feb9ea2. Unfortunately, we have determined that on some Android 9 devices and Android 10 devices & emulators, the [`FLAG_EXTRACT_NATIVE_LIBS`][1] check used in commit feb9ea2 doesn't work as intended or expected: boolean embeddedDSOsEnabled = (runtimePackage.flags & ApplicationInfo.FLAG_EXTRACT_NATIVE_LIBS) == 0; What we observe on the offending devices is that `embeddedDSOsEnabled` is False when `//application/@extractNativeLibs` is false, which is the *opposite* of what we expect. Consequently, when we *should* be looking for native libs within the `.apk`, we don't! The result is that we can't find `libmonodroid.so` ('cause it's in the `.apk`, not on disk): DllImport error loading library '__Internal': 'Could not load library: Library '/system/lib/libmonodroid.so' not found.'. Note the *path* that is being checked: `/system/lib/libmonodroid.so`, because we aren't checking within the `.apk`, so we "fallback" to various other paths, including `/system/lib`, none of which have `libmonodroid.so`. The result is that, eventually, the app crashes during startup: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x6f63736d in tid 7607 (…), pid 7607 (…) It is possible that other Android versions are affected as well, which means we can no longer trust the flag value and need to implement another way of checking whether the libraries are on the filesystem or in the `.apk`. Work around this Android issue by checking for the presence of a known library in a filesystem location, regardless of the API level. Specifically, check for the presence of `libmonodroid.so`. If `libmonodroid.so` is not found, assume that all libraries should be loaded from the `.apk`, as if `//application/@extractNativeLibs`=false. The check is performed once on application startup, thus minimizing the performance impact. [0]: https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs [1]: https://developer.android.com/reference/android/content/pm/ApplicationInfo#FLAG_EXTRACT_NATIVE_LIBS Co-Authored by: Jonathan Peppers (@jonathanpeppers)
- Loading branch information
Showing
11 changed files
with
57 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters