Skip to content
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

Need to support side-loaded typemap files #1917

Closed
jonpryor opened this issue Jul 3, 2018 · 2 comments
Closed

Need to support side-loaded typemap files #1917

jonpryor opened this issue Jul 3, 2018 · 2 comments
Assignees
Labels
Area: App+Library Build Issues when building Library projects or Application projects. Area: App Runtime Issues in `libmonodroid.so`. Area: Commercial Issues with non-OSS components. enhancement Proposed change to current functionality.

Comments

@jonpryor
Copy link
Member

jonpryor commented Jul 3, 2018

The typemap.jm and typemap.mj files are produced as part of the packaging process by TypeNameMapGenerator and the <GenerateJavaStubs/> task.

In order to help improve app performance (Issues #1443, #1829, #1830, #1831) we would like to require the presence and use of the typemap files, removing support for the Reflection-based fallback path, along with obsoleting Java.Interop.TypeManager.RegisterType(string, Type) and Java.Interop.TypeManager.RegisterPackage() and TypeManager.RegisterPackages().

However, in order to fully use typemap files, we need to support them in Fast Deployment scenarios. The problem is that the typemap files are currently stored as per-.apk data. As such, if a library assembly changes in a manner which requires updating the typemap files, the App.apk must be rebuilt and redeployed, if only to transfer the updated typemap files.

We need to update src/monodroid so that it will look for the typemap files in the .__override__ directories in addition to the .apk files. We can then generate typemap files as per-Assembly data and side-load them along with the corresponding assemblies, ensuring that when a new Assembly is deployed to the device we also deploy updated typemap files.

As a suggestion, we could name the per-assembly files as typemap-$(AssemblyBaseName).{jm,mj}, e.g. typemap-Mono.Android.jm and typemap-Mono.Android.mj.

@jonpryor jonpryor added enhancement Proposed change to current functionality. Area: App+Library Build Issues when building Library projects or Application projects. Area: App Runtime Issues in `libmonodroid.so`. Area: Commercial Issues with non-OSS components. labels Jul 3, 2018
@dellis1972 dellis1972 self-assigned this Jul 20, 2018
jonpryor pushed a commit that referenced this issue Sep 25, 2018
Context: https://developer.xamarin.com/releases/android/xamarin.android_7/xamarin.android_7.0/#Fast_Deployment
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=55050

What do we want?  To fast deploy *all the things*!  Not just
assemblies, as is currently supported, but `.dex` files,
Android resources, Android assets, shared libraries (`.so` files),
the works.  If we can avoid updating and re-installing the `.apk`,
we want to do so.

TODO: Support Fast Deployment of `.jm` and `.mj` files; see
#1917

*How* do we do that?  Previously, we used `StubApplication.java`,
which would "work some magic" to better support loading types from
multiple `.dex` files, allow loading Android Resources from multiple
locations, etc.  The problem with `StubApplication.java` is that it's
"too late" in process startup: certain constructs such as
`ContentProvider`s are created *before* the `andorid.app.Application`
instance is created, meaning those constructs couldn't be handled
like the rest of multidex.

Avoid that special case by "moving" the `StubApplication.java` logic
into the new `MultiDexLoader` types, which are `ContentProvider`s in
the spirit of `MonoRuntimeProvider`, and are thus created *before*
the `Application` is created.  This in turn allows `Application`
subclasses to be located *outside* the default `classes.dex` file
(multidex!), while still allowing the `Application` type to be
resolved and instantiated.

Add a new `ResourcePatcher` ContentProvider which "fixes up" various
Android types to permit looking up Android Resources from their
fast deployment locations.  Previously, resource patching required
that the Application be created, which prevented custom `Application`
types in a multidex environment (it couldn't be found).  Moving
Resource patching into a separate content provider allows separation
of responsibility, and supports custom `Application` subclasses.

Finally, rework `monodroid-glue.c` to copy over any `.so` files which
are found in the `.__override__` directory into the local app
directory, as **dlopen**(3) won't load `.so` files located outside of
the local app directory.  This enables fast deployment of native
libraries.
@dellis1972
Copy link
Contributor

The first part of this is done, the side loading support is in. We now need to look at generating type maps on a per assembly basis.

@grendello
Copy link
Contributor

The second part, typemap generation and runtime support, is implemented in #3992

@ghost ghost locked as resolved and limited conversation to collaborators Jun 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: App+Library Build Issues when building Library projects or Application projects. Area: App Runtime Issues in `libmonodroid.so`. Area: Commercial Issues with non-OSS components. enhancement Proposed change to current functionality.
Projects
None yet
Development

No branches or pull requests

4 participants