WIP: Android R8 fixes to enable optimizations #2727

Closed
biodranik wants to merge 3 commits from android/R8 into master
biodranik commented 2022-06-12 23:37:59 +00:00 (Migrated from github.com)

@pastk Надо допилить этот PR, хорошо его тестируя на ./gradlew runFDroidBeta

@pastk Надо допилить этот PR, хорошо его тестируя на `./gradlew runFDroidBeta`
pastk reviewed 2022-06-13 12:00:23 +00:00
Please link to https://developer.android.com/studio/build/shrink-code#keep-code for more details.

our current code style is to wrap method annotations always, i.e. keep each annotation on its own line

our current code style is to wrap method annotations always, i.e. keep each annotation on its own line
@ -9,3 +10,3 @@
*/
@Keep
public final class ParsedSearchRequest

Maybe add //Called from JNI. for all these cases?
Its a very important annotation and an extra reminder why is it there will be very good I think.

Maybe add `//Called from JNI.` for all these cases? Its a very important annotation and an extra reminder why is it there will be very good I think.
biodranik (Migrated from github.com) reviewed 2022-06-13 21:47:45 +00:00
biodranik (Migrated from github.com) commented 2022-06-13 21:47:45 +00:00

I don't like it, but ok. Can you help?

I don't like it, but ok. Can you help?
biodranik (Migrated from github.com) reviewed 2022-06-13 21:47:54 +00:00
biodranik (Migrated from github.com) commented 2022-06-13 21:47:54 +00:00

Can you please help?

Can you please help?
biodranik (Migrated from github.com) reviewed 2022-06-13 21:48:32 +00:00
@ -9,3 +10,3 @@
*/
@Keep
public final class ParsedSearchRequest
biodranik (Migrated from github.com) commented 2022-06-13 21:48:32 +00:00

We don't use reflection, so @Keep is the obvious way to mark all JNI calls. The KISS principle.

We don't use reflection, so `@Keep` is the obvious way to mark all JNI calls. The KISS principle.
pastk reviewed 2022-06-14 09:16:30 +00:00

You can use "Reformat file" - "Only VCS changed lines" in AS.

You can use "Reformat file" - "Only VCS changed lines" in AS.
pastk reviewed 2022-06-14 09:19:58 +00:00
# being manually added as -keep in this file, for details see https://developer.android.com/studio/build/shrink-code#keep-code
```suggestion # being manually added as -keep in this file, for details see https://developer.android.com/studio/build/shrink-code#keep-code ```
Owner

We need to add -dontobfuscate
otherwise logs look like this

2022-06-15 00:25:07.740 I/t9.b0: Begin scanning storages
2022-06-15 00:25:07.759 I/t9.b0: Accepted /storage/sdcard/Android/data/app.organicmaps.beta/files/ - currently configured, external, 372037632 available of 534761472 bytes, state=mounted
2022-06-15 00:25:07.760 I/t9.b0: Accepted /data/data/app.organicmaps.beta/files/ - internal, 466739200 available of 1023303680 bytes
2022-06-15 00:25:07.760 I/t9.b0: End scanning storages
2022-06-15 00:25:07.764 E/t9.b0: IOException: 
    java.io.IOException: Test
        at t9.b0.n(SourceFile:92)
        at t9.b0.g(SourceFile)
        at com.mapswithme.maps.MwmApplication.m(SourceFile)
        at com.mapswithme.maps.MwmApplication.j(SourceFile)
        at com.mapswithme.maps.SplashActivity.K0(SourceFile:4)
        at com.mapswithme.maps.SplashActivity.t1(SourceFile)
        at com.mapswithme.maps.SplashActivity$a.run(SourceFile)
        at android.os.Handler.handleCallback(Handler.java:739)
        at android.os.Handler.dispatchMessage(Handler.java:95)
...

But it could be used to find methods and classes which are called from JNI :)
(with obfuscation jni can't find them anymore because their names had been changed)

We need to add `-dontobfuscate` otherwise logs look like this ``` 2022-06-15 00:25:07.740 I/t9.b0: Begin scanning storages 2022-06-15 00:25:07.759 I/t9.b0: Accepted /storage/sdcard/Android/data/app.organicmaps.beta/files/ - currently configured, external, 372037632 available of 534761472 bytes, state=mounted 2022-06-15 00:25:07.760 I/t9.b0: Accepted /data/data/app.organicmaps.beta/files/ - internal, 466739200 available of 1023303680 bytes 2022-06-15 00:25:07.760 I/t9.b0: End scanning storages 2022-06-15 00:25:07.764 E/t9.b0: IOException: java.io.IOException: Test at t9.b0.n(SourceFile:92) at t9.b0.g(SourceFile) at com.mapswithme.maps.MwmApplication.m(SourceFile) at com.mapswithme.maps.MwmApplication.j(SourceFile) at com.mapswithme.maps.SplashActivity.K0(SourceFile:4) at com.mapswithme.maps.SplashActivity.t1(SourceFile) at com.mapswithme.maps.SplashActivity$a.run(SourceFile) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) ... ``` But it could be used to find methods and classes which are called from JNI :) (with obfuscation jni can't find them anymore because their names had been changed)
Owner

The app starts now, but needs more testing to fix more crashes (I tested it very briefly so far).

Fdroid beta x86_64 apk is reduced by 1.7Mb :)

The app starts now, but needs more testing to fix more crashes (I tested it very briefly so far). Fdroid beta x86_64 apk is reduced by 1.7Mb :)
biodranik commented 2022-06-19 21:23:58 +00:00 (Migrated from github.com)

Do you have actions access to run the android beta on your branch?

Do you have actions access to run the android beta on your branch?
rtsisyk reviewed 2022-07-17 09:39:18 +00:00
@ -36,3 +8,1 @@
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
# TODO: ATM leads to a build failure with an ERROR:R8: java.lang.NullPointerException

What is the purpose of this patch?

What is the purpose of this patch?
biodranik (Migrated from github.com) reviewed 2022-07-18 22:45:38 +00:00
@ -36,3 +8,1 @@
-dontwarn androidx.**
-keep class androidx.** { *; }
-keep interface androidx.** { *; }
# TODO: ATM leads to a build failure with an ERROR:R8: java.lang.NullPointerException
biodranik (Migrated from github.com) commented 2022-07-18 22:45:38 +00:00

To enable Java code optimizations and shrinking.

To enable Java code optimizations and shrinking.
rtsisyk reviewed 2022-10-16 14:07:51 +00:00
@ -24,1 +24,4 @@
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-copy"

Why is this warning suppressed? Is it related to this patch?

Why is this warning suppressed? Is it related to this patch?
@ -11,2 +5,3 @@
-keep class * implements com.mapswithme.util.Gsonable
# Don't obfuscate to keep logs readable
-dontobfuscate

This was an old support library we don't use anymore.

This was an old support library we don't use anymore.

Are you sure here? This namespace is still used by app.

Are you sure here? This namespace is still used by app.

Are you sure here? This namespace is still used by app.

Are you sure here? This namespace is still used by app.

Could you please keep annotations on new lines to follow existing convention in the code?

Could you please keep annotations on new lines to follow existing convention in the code?

keep annotations on a separate line

keep annotations on a separate line
This repo is archived. You cannot comment on pull requests.
No reviewers
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
3 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: organicmaps/organicmaps-tmp#2727
No description provided.