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

Support Fast Deployment of @(AndroidEnvironment) #9194

Open
2 tasks
jonpryor opened this issue Aug 12, 2024 · 0 comments
Open
2 tasks

Support Fast Deployment of @(AndroidEnvironment) #9194

jonpryor opened this issue Aug 12, 2024 · 0 comments
Assignees
Labels
Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned.

Comments

@jonpryor
Copy link
Member

Android framework version

net9.0-android

Affected platform version

.NET 9

Description

Feature Request: support fast deployment of @(AndroidEnvironment) entries. This is primarily to assist Aspire, which like environment variables which constantly change, so our thinking is that if we supported fast deployment of @(AndroidEnvironment), then Aspire could just use an @(AndroidEnvironment) file(s) and the Install target, and we'd make things performant by not constantly rebuilding the .apk.

  • Update xamarin/monodroid to fast deploy @(AndroidEnvironment) to e.g. files/.__override__/env/*.txt
  • Update dotnet/android to read files/.__override__/env/*.txt during app startup.

Unspecified is where the env/*.txt files should be read. libmono-android*.so is an obvious place, but increases the amount of C++ code we have hanging around. I'm partial to JNIEnvInit.Initialize():

[UnmanagedCallersOnly]
internal static unsafe void Initialize (JnienvInitializeArgs* args)
{
IntPtr total_timing_sequence = IntPtr.Zero;
IntPtr partial_timing_sequence = IntPtr.Zero;
LogAssemblyCategory = (args->logCategories & (uint)LogCategories.Assembly) != 0;
gref_gc_threshold = args->grefGcThreshold;
jniRemappingInUse = args->jniRemappingInUse;
MarshalMethodsEnabled = args->marshalMethodsEnabled;
java_class_loader = args->grefLoader;
mid_Class_forName = new JniMethodInfo (args->Class_forName, isStatic: true);
bool androidNewerThan10 = args->androidSdkVersion > 10;
BoundExceptionType = (BoundExceptionType)args->ioExceptionType;
androidRuntime = new AndroidRuntime (args->env, args->javaVm, androidNewerThan10, args->grefLoader, args->Loader_loadClass, args->jniAddNativeMethodRegistrationAttributePresent != 0);
AndroidValueManager = (AndroidValueManager) androidRuntime.ValueManager;
AllocObjectSupported = androidNewerThan10;
IsRunningOnDesktop = args->isRunningOnDesktop == 1;
grefIGCUserPeer_class = args->grefIGCUserPeer;
PropagateExceptions = args->brokenExceptionTransitions == 0;
JavaNativeTypeManager.PackageNamingPolicy = (PackageNamingPolicy)args->packageNamingPolicy;
if (IsRunningOnDesktop) {
var packageNamingPolicy = Environment.GetEnvironmentVariable ("__XA_PACKAGE_NAMING_POLICY__");
if (Enum.TryParse (packageNamingPolicy, out PackageNamingPolicy pnp)) {
JavaNativeTypeManager.PackageNamingPolicy = pnp;
}
}
SetSynchronizationContext ();
}

Steps to Reproduce

Did you find any workaround?

No response

Relevant log output

No response

@jonpryor jonpryor added Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned. labels Aug 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: App Runtime Issues in `libmonodroid.so`. needs-triage Issues that need to be assigned.
Projects
None yet
Development

No branches or pull requests

3 participants