Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@GaryQian
Copy link
Contributor

WIP

@GaryQian GaryQian added the Work in progress (WIP) Not ready (yet) for review! label Sep 15, 2020
@GaryQian GaryQian changed the title [WIP] Android Split AOT DynamicFeatureManager [WIP] Android embedder Split AOT DynamicFeatureManager Sep 15, 2020
@GaryQian GaryQian force-pushed the splitaot branch 2 times, most recently from 8dfbedb to 7b81f6c Compare September 23, 2020 05:21
@GaryQian GaryQian force-pushed the splitaot branch 2 times, most recently from 3950729 to b9255eb Compare September 29, 2020 04:42
embedding "androidx.lifecycle:lifecycle-common:$lifecycle_version"
embedding "androidx.lifecycle:lifecycle-common-java8:$lifecycle_version"

embedding "com.google.android.play:core:1.8.0"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah of course. This makes sense. Though we should try to clarify this high level question early on. Could you take a hello_world app and build it with and without this in release mode (thus R8'ed)? We should compare the APK sizes of the engine with and without this dependency to see if this is an acceptable increase.

We can also drag and drop the old and new APK into Android Studio, introspect the .dex and look at all the new Java classes that's brought in to see if it makes sense or we need to tweak the default R8 rules more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I can tell form the docs, it looks like this package is pretty lightweight. I don't expect it to add much, though I'll also run the experiment to put a number on it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test. One possible case is that that the package itself has very little code but declares other transitive Gradle dependencies.

* {@code io.flutter.embedding.android} since they self-initialize on first use.
*/
public class FlutterApplication extends Application {
public class FlutterApplication extends SplitCompatApplication {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already started asking people to get rid of the FlutterApplication. If this is needed, we might have to add some docs for people to manually add it back or modify their existing Application superclass.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other ways to accomplish this. This was just the simplest, but I can easily move to one of the other two methods that dont reply on this extension. See https://developer.android.com/guide/playcore/dynamic-delivery#enable_splitcompat

import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import com.google.android.play.core.splitinstall.SplitInstallException;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to figure this out now, and you're probably already thinking about this since it implements an interface. But since this is all dead code for devs in China, we should figure out some sort of compile time or R8 time mechanism to let them strip all this out of their engine .so.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preliminary APK size comparisons point to a 30kb gain from play core + split aot code. I expect this number may be able to be reduced further as I realized I did not use a LTO dart for the comparison.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, the above comment probably belongs in the other thread about apk sizes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you check in the apk analyzer where it came from? i.e. from the dex or from the sum of the .so being higher than 1 .so?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just did another measurement, this time 28,935 bytes with a full LTO build. I'll take a look at source.

@GaryQian
Copy link
Contributor Author

I will be splitting this PR into the embedder+shell section and the runtime+dart_isolate section

Begin impl android embedder work

Add success and failure callbacks

Success and failure calls

Additional impl

Begin engine impl

Building

No crash

Additional logging

Switch to int loading unit id

Splits install now

Begin reading libs

Track loadingUnitId as well:

Pass dart handler call through to embedder

One direction works

Move dart complete into platform_view_android

Move loading into runtime

Loading .so data complete

Move dart set handler to dart isolate

Successfully loads dart libs

Filter by ABI

Dynamic abi passing, cleanup

Compile and cleanup

Fix dependencies

Separate handler into own class

Move static vars to handler

Clean imports, comments

USe io.flutter.Log

Fix host unittests

Use temp void*

Switch to override splitcompat

Working asset manager load

Merge with upstream, working again
@GaryQian GaryQian changed the title [WIP] Android embedder Split AOT DynamicFeatureManager [WIP] Split AOT Engine changes master Oct 28, 2020
@GaryQian
Copy link
Contributor Author

#22179 contains the android embedder and shell components of split AOT.

@xster
Copy link
Member

xster commented Jan 12, 2021

You don't need this PR anymore right?

@GaryQian
Copy link
Contributor Author

Ahh, yes. This can be closed!

@GaryQian GaryQian closed this Jan 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants