Open Bug 1909511 Opened 1 year ago Updated 10 days ago

Re-enable the R8 fullMode optimization

Categories

(Firefox for Android :: Performance, enhancement)

All
Android
enhancement

Tracking

()

REOPENED

People

(Reporter: RyanVM, Assigned: RyanVM)

References

(Depends on 2 open bugs, Blocks 3 open bugs)

Details

(Keywords: perf-alert, Whiteboard: [fxdroid][group3])

Attachments

(1 file, 3 obsolete files)

Back when R8 fullMode was enabled by default in AGP, we had to disable it due to CI problems. I recently ran a fresh Try push and found that the Fenix and Focus Nightly robo startup tests still crash on startup with this optimization enabled, with similar-looking stacks.

Fenix

System.err: java.lang.RuntimeException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{org.mozilla.fenix/kotlin.ExceptionsKt$tab0}
System.err: 	at org.mozilla.gecko.process.ServiceAllocator$InstanceInfo.<init>(SourceFile:84)
System.err: 	at org.mozilla.gecko.process.GeckoProcessManager$ChildConnection.<init>(SourceFile:1)
System.err: 	at org.mozilla.gecko.process.GeckoProcessManager$ConnectionManager.getNewContentConnection(SourceFile:7)
System.err: 	at org.mozilla.gecko.process.GeckoProcessManager$ConnectionManager.getConnectionForPreload(SourceFile:7)
System.err: 	at org.mozilla.gecko.process.GeckoProcessManager$$ExternalSyntheticLambda3.run(SourceFile:102)
System.err: 	at org.mozilla.gecko.util.XPCOMEventTarget$JNIRunnable.run(SourceFile:3)
System.err: Caused by: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{org.mozilla.fenix/kotlin.ExceptionsKt$tab0}
System.err: 	at android.app.ApplicationPackageManager.getServiceInfo(ApplicationPackageManager.java:501)
System.err: 	at org.mozilla.gecko.process.ServiceAllocator$InstanceInfo.<init>(SourceFile:62)
System.err: 	... 5 more

Focus

System.err: java.lang.RuntimeException: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{org.mozilla.focus.nightly/kotlin.text.CharsKt$tab0}
System.err: 	at org.mozilla.gecko.process.ServiceAllocator$InstanceInfo.<init>(SourceFile:85)
System.err: 	at org.mozilla.gecko.process.GeckoProcessManager$ChildConnection.<init>(SourceFile:1)
System.err: 	at org.mozilla.gecko.process.GeckoProcessManager$ConnectionManager.getNewContentConnection(SourceFile:7)
System.err: 	at org.mozilla.gecko.process.GeckoProcessManager$ConnectionManager.getConnectionForPreload(SourceFile:7)
System.err: 	at org.mozilla.gecko.process.GeckoProcessManager$$ExternalSyntheticLambda3.run(SourceFile:102)
System.err: 	at org.mozilla.gecko.util.XPCOMEventTarget$JNIRunnable.run(SourceFile:3)
System.err: Caused by: android.content.pm.PackageManager$NameNotFoundException: ComponentInfo{org.mozilla.focus.nightly/kotlin.text.CharsKt$tab0}
System.err: 	at android.app.ApplicationPackageManager.getServiceInfo(ApplicationPackageManager.java:501)
System.err: 	at org.mozilla.gecko.process.ServiceAllocator$InstanceInfo.<init>(SourceFile:62)
System.err: 	... 5 more

Reading the upstream docs on R8 fullMode, it sounds like we may just need to adjust our ProGuard rules a bit?
https://r8.googlesource.com/r8/+/refs/heads/master/compatibility-faq.md#r8-full-mode

Severity: -- → N/A
Component: Tooling → Performance
Assignee: nobody → adhingra
Status: NEW → ASSIGNED
Whiteboard: [fxdroid][group3]

Without this, Focus Nightly androidTest builds hit the below error:
ERROR: R8: Missing class androidx.concurrent.futures.SuspendToFutureAdapter (referenced from: com.google.common.util.concurrent.ListenableFuture androidx.test.core.view.ViewCapture.captureToBitmapAsync(android.view.View, android.graphics.Rect) and 1 other context)

Don't ask me why Fenix doesn't also hit this. Something, something, ProGuard maybe?

This is similar to what we already do for UI test builds.
R8 apparently likes to over-optimize things to the point where it ends up breaking the profiling run:
org.mozilla.fenix.benchmark.baselineprofile.NormalBrowsingBaselineProfileGenerator#generateBaselineProfile[composableToolbar=false] | java.lang.IllegalStateException: Unable to confirm activity launch completion [] Please report a bug with the output of adb shell dumpsys gfxinfo org.mozilla.fenix framestats

Fixes for various crashes encountered in CI with release builds caused by R8 over-optimizing things.

One last Try push for sanity, but I'm very confident it'll be green.
https://treeherder.mozilla.org/jobs?repo=try&revision=d3b2769600af00b0b1f0942476f3be83769eaa59

Assignee: aadityadhingra305 → ryanvm

Looks like it's about a 4% reduction in nightly APK and AAB size. Not sure what that'll translate to for Play Store downloads, but seems like a pretty nice win anyway!

Assignee: ryanvm → nobody
Status: ASSIGNED → NEW
Blocks: 1987616
Assignee: nobody → ryanvm
Status: NEW → ASSIGNED
Depends on: 1987713

Comment on attachment 9511884 [details]
Bug 1909511 - Add an explicit AndroidX Concurrency dependency for Focus UI tests. r=#android-reviewers

Revision D264010 was moved to bug 1987713. Setting attachment 9511884 [details] to obsolete.

Attachment #9511884 - Attachment is obsolete: true

Comment on attachment 9511885 [details]
Bug 1909511 - Disable optimizations for Fenix profile generation builds. r=#android-reviewers

Revision D264011 was moved to bug 1987713. Setting attachment 9511885 [details] to obsolete.

Attachment #9511885 - Attachment is obsolete: true

Comment on attachment 9511886 [details]
Bug 1909511 - Update ProGuard rules. r=#android-reviewers

Revision D264012 was moved to bug 1987713. Setting attachment 9511886 [details] to obsolete.

Attachment #9511886 - Attachment is obsolete: true
Status: ASSIGNED → RESOLVED
Closed: 8 months ago
Resolution: --- → FIXED
Target Milestone: --- → 146 Branch
Regressions: 1995743
No longer regressions: 1995743
Regressions: 1995743

(In reply to Pulsebot from comment #10)

Pushed by rvandermeulen@mozilla.com:
https://github.com/mozilla-firefox/firefox/commit/277a161da99f
https://hg.mozilla.org/integration/autoland/rev/1383ca2b8c0e
Re-enable R8 fullMode for Fenix and Focus. r=android-reviewers,sfamisa

Perfherder has detected a mozperftest performance change from push 1383ca2b8c0e1d1c604c27037220911244b82e29.

If you have any questions, please reach out to a performance sheriff. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.

Improvements:

Ratio Test Platform Options Absolute values (old vs new)
17% background-resource pss-crashhelper-start android-hw-a55-14-0-aarch64-shippable 24,679.50 -> 20,444.58
17% foreground-resource pss-crashhelper-10% android-hw-a55-14-0-aarch64-shippable 24,823.92 -> 20,565.25
17% foreground-resource pss-crashhelper-start android-hw-a55-14-0-aarch64-shippable 24,718.75 -> 20,518.83
17% foreground-resource pss-crashhelper-50% android-hw-a55-14-0-aarch64-shippable 24,874.50 -> 20,668.58
17% background-resource pss-crashhelper-10% android-hw-a55-14-0-aarch64-shippable 24,689.25 -> 20,513.58
... ... ... ... ...
8% foreground-resource pss-gpu-50% android-hw-a55-14-0-aarch64-shippable 52,079.25 -> 47,726.33

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a performance sheriff to do that for you.

You can run all of these tests on try with ./mach try perf --alert 47196

The following documentation link provides more information about this command.

Keywords: perf-alert
See Also: → 1996527
Pushed by sstanca@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/a8a7aa881515 https://hg.mozilla.org/integration/autoland/rev/94ab490a658b Revert "Bug 1909511 - Re-enable R8 fullMode for Fenix and Focus. r=android-reviewers,sfamisa" as requested by RyanVm for causing bug 1995743.

Reverted this as requested by RyanVm for causing bug 1995743.

Status: RESOLVED → REOPENED
Flags: needinfo?(ryanvm)
Resolution: FIXED → ---
Target Milestone: 146 Branch → ---
Flags: needinfo?(ryanvm)

(In reply to Serban Stanca [:SerbanS] from comment #14)

Reverted this as requested by RyanVm for causing bug 1995743.

Perfherder has detected a mozperftest performance change from push 2bc48cc453df653afe1a8666e091a8eedfe949b7.

This comment is for informational purposes only; no further action from the author is required.

If you have any questions or need any help with the investigation, please reach out to a performance sheriff. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.

Regressions:

Ratio Test Platform Options Absolute values (old vs new)
23% background-resource pss-crashhelper-50% android-hw-a55-14-0-aarch64-shippable 20,467.33 -> 25,252.17
23% background-resource pss-crashhelper-10% android-hw-a55-14-0-aarch64-shippable 20,416.50 -> 25,175.58
23% background-resource pss-crashhelper-end android-hw-a55-14-0-aarch64-shippable 20,488.17 -> 25,260.83
23% background-resource pss-crashhelper-start android-hw-a55-14-0-aarch64-shippable 20,350.58 -> 25,042.92
21% foreground-resource pss-crashhelper-start android-hw-a55-14-0-aarch64-shippable 20,665.58 -> 25,051.00
21% foreground-resource pss-crashhelper-10% android-hw-a55-14-0-aarch64-shippable 20,770.17 -> 25,137.17
21% foreground-resource pss-crashhelper-50% android-hw-a55-14-0-aarch64-shippable 20,829.50 -> 25,199.42
21% foreground-resource pss-crashhelper-end android-hw-a55-14-0-aarch64-shippable 20,932.83 -> 25,270.75
20% newssite-applink-startup org.mozilla.fenix:crashhelper-cpu-time android-hw-a55-14-0-aarch64-shippable 106.83 -> 128.67
10% foreground-resource pss-gpu-50% android-hw-a55-14-0-aarch64-shippable 47,175.08 -> 51,871.58
10% foreground-resource pss-gpu-start android-hw-a55-14-0-aarch64-shippable 47,062.08 -> 51,731.75
10% foreground-resource pss-gpu-10% android-hw-a55-14-0-aarch64-shippable 47,169.25 -> 51,809.17
9% background-resource pss-gpu-10% android-hw-a55-14-0-aarch64-shippable 47,240.12 -> 51,467.58
9% background-resource pss-gpu-start android-hw-a55-14-0-aarch64-shippable 47,172.25 -> 51,338.17

Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.

If you need the profiling jobs you can trigger them yourself from treeherder job view or ask a performance sheriff to do that for you.

You can run all of these tests on try with ./mach try perf --alert 47330

The following documentation link provides more information about this command.

Depends on: 1923142, 1923139
See Also: 1996527

FWIW, AGP 9 has a new warning that fullMode will be the default in AGP 10 and the option to disable it will be removed.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: