Closed Bug 1529082 Opened 5 years ago Closed 3 years ago

Support dynamic delivery / Android App Bundle

Categories

(GeckoView :: General, enhancement, P1)

Unspecified
Android

Tracking

(firefox96 fixed)

RESOLVED FIXED
96 Branch
Tracking Status
firefox96 --- fixed

People

(Reporter: cnevinchen, Assigned: agi)

References

(Blocks 1 open bug)

Details

(Whiteboard: [geckoview:rocket] [geckoview:m93][geckoview:m94][geckoview:m95][geckoview:m96], [wptsync upstream])

Attachments

(9 files, 2 obsolete files)

48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review
48 bytes, text/x-phabricator-request
Details | Review

Dynamic delivery empowers the users to have a smaller first install APK size, and then install the dynamic features as extra APKs if they want to use that feature. see AAB and Dynamic delivery

The user will first get the base.apk, then download splits_feature_module_name.apk from Play Store

Our current GeckoView code (e.g. NSSBridge / GeckoThread / GeckoJarReader) will need the apk path to load related libraries, but this won't work dynamic delivery world cause the APK name will change according to abi/laguage/density splits.

Here's one example of only splits the abi with one dynamic feature

"/data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/base.apk"
"/data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/split_geckopower.apk"
"/data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/split_geckopower.config.x86.apk"

I suggest to replace context.getPackageResourcePath() to context.applicationInfo.splitSourceDirs and context.applicationInfo.publicSourceDir to get both base and split APKs.

Every Java class has it's ClassLoader(Android's PathClassLoader) and has its DexPathList contains all the dex files, but I can't find an api to get them

DexPathList[[zip file "/data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/base.apk", zip file "/data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/split_geckopower.apk", zip file "/data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/split_geckopower.config.x86.apk"],nativeLibraryDirectories=[/data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/lib/x86, /data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/base.apk!/lib/x86, /data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/split_geckopower.apk!/lib/x86, /data/app/org.mozilla.rocket.debug.firebase-n8F5hLsnz5J5dNOuixTgDQ==/split_geckopower.config.x86.apk!/lib/x86, /system/lib]]

Currently if we really want to work around this, we need to have a our own NSSBridge/GeckoThread/GeckoJarReader implementation and use it like this . But this approach isn't maintanable.

It'll be great to have dynamic delivery support in GeckoView.

Priority: -- → P3

App Bundles might be a good solution for bug 1548679.

Blocks: 1550291
OS: All → Android
No longer blocks: 1550291
No longer blocks: 1548679
Flags: needinfo?(dbolter)

Resetting priority so we can re-prioritize this. This is the only blocker for shipping GV as an app bundle.

Priority: P3 → --

Needs a priority. NI'ing Andreas to help.

Flags: needinfo?(dbolter) → needinfo?(abovens)

Firefox Lite would like this feature.

Priority: -- → P2
Whiteboard: [geckoview:fxlite]
Whiteboard: [geckoview:fxlite] → [geckoview:rocket]

How soon is Firefox Lite wanting to have this? None of our other consumers (FxR, Fenix) are asking for this yet, and it would be good to know so that we can properly prioritise.

Flags: needinfo?(jcheng)

Hi Emily, the Firefox Lite team would like to have this feature available from your team in Q4 so we can work on it and deliver features based on it in Q1 2020. Thanks

Flags: needinfo?(jcheng)

I'm editing a bunch of GeckoView bugs. If you'd like to filter all this bugmail, search and destroy emails containing this UUID:

e88a5094-0fc0-4b7c-b7c5-aef00a11dbc9

Priority: P2 → P3

Hey Joe, can you create a 1-pager with justification and rationale? That will help us with prioritization.

Flags: needinfo?(abovens) → needinfo?(jcheng)
Rank: 1

Still not working in 80.0.20200903001900 stable version

This issue makes it impossible for Geckoview to be used in new projects since App Bundles are now (August 2021) required for new Android Apps (see https://android-developers.googleblog.com/2021/06/the-future-of-android-app-bundles-is.html). Meaning the projects using Geckoview can only decrease from here.

Whiteboard: [geckoview:rocket] → [geckoview:rocket] [geckoview:m93?]
Severity: normal → S3
Priority: P3 → P2

When using App Bundles, the so files will be in the APK splits, instead of
being in the folder specified by the native lib.

dlopen and dlsym do the right thing on Android and automatically figure out
where the library is.

I'm not sure if this is a good approach (e.g. is it safe? could another app
potentially hijack our libraries?). If it isn't we could find the right path
using some code that chromium has.

Assignee: nobody → agi
Status: NEW → ASSIGNED
Whiteboard: [geckoview:rocket] [geckoview:m93?] → [geckoview:rocket] [geckoview:m93]
Priority: P2 → P1
Whiteboard: [geckoview:rocket] [geckoview:m93] → [geckoview:rocket] [geckoview:m93][geckoview:m94]

Before this patch, we would load mozglue using the unqualified
System.loadLibrary("mozglue") and then we would try to load all the other
native libraries from the path returned from nativeLibraryDir.

Note that since the path is unqualified, we might end up loading a library
that's not inside the APK, potentially a malicious one.

Android App Bundles (or AAB) is a new feature of Android where apps can be
split in multiple APKs (called "splits"). Each APK split contains a functinal
part of the app, e.g. a specific resolution asset folder, all the native
libraries for one CPU architecture etc.

For AAB, nativeLibraryDir returns an empty folder as the libraries are
stored, uncompressed, inside one of the APK splits, so GeckoView fails to load
libxul and other libraries when starting up.

The current code also doesn't work for any case where System.loadLibrary
fails to load mozglue (we do have code that accounts for that, but I'm not sure
how much of it is funcitonal).

To fix that, we locate the mozglue using code ported from Chromium and use that
to locate all the other native libraries.

Note this still doesn't fix the problem of loading an unqualified mozglue
library, but there's not a lot we can do about that right now (and that's not a
new problem, so we can address it in a separate patch).

Attachment #9236737 - Attachment description: Bug 1529082 - Don't specify path when loading dynamic libraries on Android → Bug 1529082 - Locate lib folder within the APK.
Attachment #9240101 - Attachment is obsolete: true
Whiteboard: [geckoview:rocket] [geckoview:m93][geckoview:m94] → [geckoview:rocket] [geckoview:m93][geckoview:m94][geckoview:m95]

This tool is used to install AAB packages to devices.

AAB is the new package format for Android Apps and will supersede APK.

The fact that the test runner app is defined inside the geckoview test package
has always felt like a hack to me. I've mistakenly thought that
TestRunnerActivity was used in GeckoView's junit tests many times (even though
that's not the case).

From what I can see, there's no way to generate an AAB package for androidTest,
so to be able to run Gecko tests as AAB we finally need to define the
TestRunner as an ordinary package instead.

This allows variants to override targets.

This patch adds a new command line argument --aab which allows users to install
GVE as an AAB.

This will also be used in a future patch to install the test runner as AAB.

This patch adds a new Mochitest variant which installs the test runner app as
AAB.

Depends on: 1736433

Is there any production-ready solution for uploading GeckoView based .aab android app to Google PlayStore without getting the following crash?

021-10-26 22:09:37.959 32298-3601/? E/AndroidRuntime: FATAL EXCEPTION: Gecko
    Process: com.example.geckoviewapp, PID: 32298
    java.lang.Exception: Error loading sqlite libraries

Since other variants of Mozilla Browser also use GeckoView and they update the Google Playstore App regularly without getting this crash.
How can we build .aab in a way that it is distributable through Google Playstore without Crash?

This may be a serious concern for developers who used GeckoView in their App and now are unable to publish the app to Google Playstore.
Your help and guidance will be appreciated.

(In reply to Rahul Shyokand from comment #23)

Is there any production-ready solution for uploading GeckoView based .aab android app to Google PlayStore without getting the following crash?

021-10-26 22:09:37.959 32298-3601/? E/AndroidRuntime: FATAL EXCEPTION: Gecko
    Process: com.example.geckoviewapp, PID: 32298
    java.lang.Exception: Error loading sqlite libraries

Since other variants of Mozilla Browser also use GeckoView and they update the Google Playstore App regularly without getting this crash.
How can we build .aab in a way that it is distributable through Google Playstore without Crash?

This may be a serious concern for developers who used GeckoView in their App and now are unable to publish the app to Google Playstore.
Your help and guidance will be appreciated.

Hi there, the fix will be available in GeckoView 96. Meanwhile you should be able to set extractNativeLibs = true in AndroidManifest.xml and android.bundle.enableUncompressedNativeLibs = false in gradle.properties, see the following:

https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs
https://developer.android.com/studio/releases/gradle-plugin#behavior-changes

Whiteboard: [geckoview:rocket] [geckoview:m93][geckoview:m94][geckoview:m95] → [geckoview:rocket] [geckoview:m93][geckoview:m94][geckoview:m95][geckoview:m96]
Attachment #9244013 - Attachment is obsolete: true

./mach lint --outgoing --fix keeps changing this for me.

Pushed by asferro@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/94012b2abf6f
Locate lib folder within the APK. r=owlish
https://hg.mozilla.org/integration/autoland/rev/67001525a262
Add bundletool to Android's bootstrap r=jmaher
https://hg.mozilla.org/integration/autoland/rev/28475cfdf30b
Add device.install_app_bundle r=jmaher
https://hg.mozilla.org/integration/autoland/rev/c03034fa7d47
Move TestRunnerActivity to test_runner. r=ahal,owlish
https://hg.mozilla.org/integration/autoland/rev/86c4c2070378
Resolve keyed target in get_mobile_project. r=jmaher
https://hg.mozilla.org/integration/autoland/rev/69bd7293edb8
Use bundletool in CI to install AAB targets. r=ahal
https://hg.mozilla.org/integration/autoland/rev/f7888063e67e
Use bundletool to install apps as aab packages. r=ahal,owlish
https://hg.mozilla.org/integration/autoland/rev/44a00ee73528
Add mochitest variant that runs using AAB test_runner. r=gbrown
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/31475 for changes under testing/web-platform/tests
Whiteboard: [geckoview:rocket] [geckoview:m93][geckoview:m94][geckoview:m95][geckoview:m96] → [geckoview:rocket] [geckoview:m93][geckoview:m94][geckoview:m95][geckoview:m96], [wptsync upstream]
Pushed by asferro@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/18607955e8b2
Fix formatting in wpt/run.py. r=jmaher

(In reply to Agi Sferro | :agi | ni? for questions | ⏰ PST | he/him from comment #24)

(In reply to Rahul Shyokand from comment #23)

Is there any production-ready solution for uploading GeckoView based .aab android app to Google PlayStore without getting the following crash?

021-10-26 22:09:37.959 32298-3601/? E/AndroidRuntime: FATAL EXCEPTION: Gecko
    Process: com.example.geckoviewapp, PID: 32298
    java.lang.Exception: Error loading sqlite libraries

Since other variants of Mozilla Browser also use GeckoView and they update the Google Playstore App regularly without getting this crash.
How can we build .aab in a way that it is distributable through Google Playstore without Crash?

This may be a serious concern for developers who used GeckoView in their App and now are unable to publish the app to Google Playstore.
Your help and guidance will be appreciated.

Hi there, the fix will be available in GeckoView 96. Meanwhile you should be able to set extractNativeLibs = true in AndroidManifest.xml and android.bundle.enableUncompressedNativeLibs = false in gradle.properties, see the following:

https://developer.android.com/guide/topics/manifest/application-element#extractNativeLibs
https://developer.android.com/studio/releases/gradle-plugin#behavior-changes

Thank you very much.
This worked when I added android.bundle.enableUncompressedNativeLibs = false in gradle.properties.
Now Gecko Libs are able to load with a .aab bundle distributed through Google Playstore.

Upstream PR merged by moz-wptsync-bot
Regressions: 1739312
Regressions: 1739422
Regressions: 1798617
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: