Skip to content

Search the installed ABI first in DirectApkSoSource - #155

Open
nico-gonzalez wants to merge 1 commit into
meta:mainfrom
nico-gonzalez:fix/direct-apk-installed-abi-first
Open

nico-gonzalez wants to merge 1 commit into
meta:mainfrom
nico-gonzalez:fix/direct-apk-installed-abi-first

Conversation

@nico-gonzalez

Copy link
Copy Markdown
Contributor

Fixes #154.

Summary

DirectApkSoSource builds its APK search paths from SysUtil.getSupportedAbis(). On x86_64 hosts that also run ARM code, the ABI the package manager installed the app for may not come first. It may not be in the list at all. Then SoLoader looks in the wrong lib/<abi> folder and throws SoLoaderDSONotFoundError. See the issue for the trace and a reproducer.

This change searches ApplicationInfo.primaryCpuAbi first, read through the existing SysUtil.getPrimaryAbi helper (also used for SoLoader.sPrimaryAbi). The supported ABIs follow in their current order, and LinkedHashSet removes the duplicate.

When primaryCpuAbi can't be read, getPrimaryAbi falls back to getSupportedAbis()[0], so the order is the same as today. On normal devices the installed ABI is already SUPPORTED_ABIS[0], so nothing changes there.

Test Plan

  • Every source under java/ compiles with javac against android-36/android.jar and jsr305.
  • Not run: the internal SoLoaderDirectApkTest. The OSS tree has no tests. A case next to testPreferredAbiOrder() should check that getDirectApkLdPaths starts with <apk>!/lib/<primaryCpuAbi> when it differs from SUPPORTED_ABIS[0].
  • On-device: the reproducer in the issue crashes on 0.12.1. The same lookup order, added by the app before SoLoader.init, launches normally on an API 34 x86_64 emulator. This patched SoLoader build has not been run on a device.

DirectApkSoSource built its APK search paths from SysUtil.getSupportedAbis(),
so on x86_64 hosts that also run ARM code it could search an ABI the package
manager did not install the app for. Put ApplicationInfo.primaryCpuAbi (via
SysUtil.getPrimaryAbi) first; the supported ABIs follow as before.
@meta-cla

meta-cla Bot commented Oct 26, 2026

Copy link
Copy Markdown

Hi @nico-gonzalez!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Oct 26, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the CLA Signed label Oct 26, 2026
@meta-codesync

meta-codesync Bot commented Oct 26, 2026

Copy link
Copy Markdown

@cortinico has imported this pull request. If you are a Meta employee, you can view this in D127601450.

@shamilovtim

Copy link
Copy Markdown

Hi @cortinico sorry for the direct tag, any chance of a release soon on some of these PRs looking to address these Android startup crashes?

meta-codesync Bot pushed a commit that referenced this pull request Oct 29, 2026
Summary:
Fixes #154.

`DirectApkSoSource` builds its APK search paths from `SysUtil.getSupportedAbis()`. On x86_64 hosts that also run ARM code, the ABI the package manager installed the app for may not come first. It may not be in the list at all. Then SoLoader looks in the wrong `lib/<abi>` folder and throws `SoLoaderDSONotFoundError`. See the issue for the trace and a reproducer.

This change searches `ApplicationInfo.primaryCpuAbi` first, read through the existing `SysUtil.getPrimaryAbi` helper (also used for `SoLoader.sPrimaryAbi`). The supported ABIs follow in their current order, and `LinkedHashSet` removes the duplicate.

When `primaryCpuAbi` can't be read, `getPrimaryAbi` falls back to `getSupportedAbis()[0]`, so the order is the same as today. On normal devices the installed ABI is already `SUPPORTED_ABIS[0]`, so nothing changes there.

X-link: #155

Reviewed By: danjin250

Differential Revision: D127601450

Pulled By: cortinico

fbshipit-source-id: 767d05054a5934f3360faa0f574648836fe191a5
@cortinico

Copy link
Copy Markdown
Contributor

This has landed in main here 9e8a25c so I'm closing it.

@shamilovtim I will try to create a new release in the near future but I don't have a timeline right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DirectApkSoSource searches SUPPORTED_ABIS instead of the ABI the app was installed for

3 participants