-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strip unused code and resources from pwa-template.apk #7
Strip unused code and resources from pwa-template.apk #7
Conversation
@JudahGabriel PTAL. 😉 |
Wow, awesome Alexey! @amrutha95 have a look? |
Also, @phosiaz can you have a look at this? |
Hey Alexey! This looks great! Thanks a bunch for suggestions, but we want to keep this tool aligned with that found at https://developer.oculus.com/documentation/web/pwa-packaging/ for the purposes of consistency and a standardized testing suite — as this hasn’t gone through all of our tests. However, you’ll note that the current version of pwa-template.apk is actually 8kB, not 1.2MB! This is because we’ve made the same changes to the classes.dex :) |
Could you please share more details, what exactly tests? Have you tested only
The only changes are in two files: Here's the change in the - exec java $javaOpts -Djava.awt.headless=true -jar "$jarpath" "$@"
+ exec java $javaOpts -Djava.awt.headless=true -jar "$jarpath" -s "$@" BTW, where did you find
Yes, I noticed it at the very last moment, only when I started doing a pull request, i.e. much later I started working on it independently. But my Also I've found some issues in the current
package com.oculus.pwa.templateapplication;
public class R {
public static class string {
public static final int app_name = 2130837504;
}
} Also it contains some interesting string: {
"compilation-mode": "debug",
"min-api": 16,
"sha-1": "engineering",
"version": "1.5.20-dev"
} My The only downside of my But what is the point of disassembling and assembling back the code, if it's not used anyway? This just slows down rebuilding the APK.
Why the following was removed? Isn't that being used? <meta-data
android:name="com.oculus.vrshell.supports_free_resizing"
android:value="true"
maxSizeX="1280"
maxSizeY="1000"
minSizeX="400"
minSizeY="400" /> Why the following was changed? <manifest
- android:compileSdkVersion="23"
+ android:compileSdkVersion="31"
- android:compileSdkVersionCodename="6.0-2438415"
+ android:compileSdkVersionCodename="12"
- platformBuildVersionCode="29"
+ platformBuildVersionCode="31"
- platformBuildVersionName="10">
+ platformBuildVersionName="12">
<uses-sdk
- android:minSdkVersion="23"
+ android:minSdkVersion="28" My I tried to keep So please give my pull request another chance. 😉 @davehill00 @jacobrossi @cabanier cc. P.S. I'm anyway working on a pull request for Bubblewrap, which adds a flag for generating universal APKs compatible with Quest that open Trusted Web Activity (TWA) on regular Android devices and Meta Quest Browser on Quest devices. This will allow to abandon |
Hey @FluorescentHallucinogen!! I just wanted to let you know this hasn't slipped through the cracks, thanks for the detailed (and really useful) set of notes -- just looking into how best to approach integration and I'll comment here once I have an update! |
Hey @FluorescentHallucinogen ! Thanks a bunch for the improvements made here 😊 we were able to verify tests passed so going to merge this PR now! |
@phosiaz 🎉 The good news is that soon all this will no longer be needed. See https://twitter.com/alexey_rodionov/status/1544374516767285249, pwa-builder/PWABuilder#3162 and pwa-builder/CloudAPK#98. 😉 |
I've reduced the size of
pwa-template.apk
by 1000x, from 1.2 MB to 1.2 kB! 🤯In fact, the only file in the APK that is used is
AndroidManifest.xml
.Since
AndroidManifest.xml
doesn't contain any activities, all code can be deleted.But to be installable, the APK must contain
classes.dex
file.So I've prepared the minimal possible
classes.dex
file that the ART class loader loads without complaining (https://source.android.com/devices/tech/dalvik/dex-format). It defines 0 classes with 0 methods, and references 0 methods. It's only 116 bytes in size (uncompressed)!Also I've removed from
AndroidManifest.xml
things that are not used or added later byovr-platform-util
:This reduces the size of compiled uncompressed
AndroidManifest.xml
to just 2 564 bytes!After that all resources (
resources.arsc
file andres
folder) can be deleted from the APK as unused.Also I've added an
-s
option toapktool
:This helps to bypass an
ovr-platform-util
's error when trying to disassembly theclasses.dex
with no code and speeds up APK rebuilding.