Skip to content

Conversation

@radekdoulik
Copy link
Member

@radekdoulik radekdoulik commented Jan 21, 2021

Implement JniValueManager.ActivatePeer method
in AndroidValueManager.

Context: #5400

This allows us to remove SLE dependency and save cca 15% of assembly
size for XA simple Hello world app.

Size difference of BuildReleaseArm64False on net6:

Size difference in bytes ([*1] apk1 only, [*2] apk2 only):
  +          96 assemblies/Mono.Android.dll
  -         331 assemblies/System.Collections.Concurrent.dll
  -         907 assemblies/Java.Interop.dll
  -       1,003 assemblies/System.Linq.dll
  -       3,856 assemblies/System.ObjectModel.dll *1
  -       4,496 assemblies/System.Collections.dll *1
  -       7,824 assemblies/System.Private.CoreLib.dll
  -     115,284 assemblies/System.Linq.Expressions.dll *1
Summary:
  -     133,605 Assemblies -15.33% (of 871,776)

@dellis1972
Copy link
Contributor

Err - 907 assemblies/Java.Interop.dll is that right? Should Java.Interop have been removed?

@radekdoulik
Copy link
Member Author

The do-not-merge label is added because merging needs to be done together with dotnet/java-interop#784

@radekdoulik
Copy link
Member Author

Err - 907 assemblies/Java.Interop.dll is that right? Should Java.Interop have been removed?

That means the Java.Interop.dll's size is now smaller by 907 bytes. Only the assemblies with *1 are removed.

Context: #5444

This allows us to remove SLE dependency and save cca 15% of assembly
size.

Size difference of BuildReleaseArm64False on net6:

    Size difference in bytes ([*1] apk1 only, [*2] apk2 only):
      +          96 assemblies/Mono.Android.dll
      -         331 assemblies/System.Collections.Concurrent.dll
      -         907 assemblies/Java.Interop.dll
      -       1,003 assemblies/System.Linq.dll
      -       3,856 assemblies/System.ObjectModel.dll *1
      -       4,496 assemblies/System.Collections.dll *1
      -       7,824 assemblies/System.Private.CoreLib.dll
      -     115,284 assemblies/System.Linq.Expressions.dll *1
    Summary:
      -     133,605 Assemblies -15.33% (of 871,776)
@jonpryor
Copy link
Contributor

The SubscribeToAppDomainUnhandledException failure is https://github.com/xamarin/monodroid/pull/1141.

  /Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.Debugging.targets(595,5):
error XA0010: Could not retireve the Device `Abi`. Please reconnect and try again.

The ListAndMap failure is our "favorite": keytool error: java.lang.Exception.

I don't know what's up with SwitchConfigurationsShouldRedeploy: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4398258&view=ms.vss-test-web.build-test-results-tab&runId=18350334&resultId=100082&paneView=debug
https://discord.com/channels/732297728826277939/732297837953679412/802333233282416683

Which leaves the app crash, e.g. Mono.Android_Tests-Bundle: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=4398258&view=ms.vss-test-web.build-test-results-tab&runId=18348414&resultId=100000&paneView=debug

I don't see a crash in the logcat. I don't know why it failed. :-(

Restarting the failed jobs.

@jonpryor
Copy link
Contributor

Squash-and-merge…

Summary:

Bump to xamarin/Java.Interop/main@cba61370 (#5530)

Body:

Fixes: https://github.com/xamarin/xamarin-android/issues/5400

Changes: https://github.com/xamarin/Java.Interop/compare/a8f68e562827e9ae6b2e12edf7445b1a3112d6fd...cba613703e100e99ba005344da60d51448ecaf2a

  * xamarin/Java.Interop@cba61370: [Java.Interop] Add JniRuntime.JniValueManager.ActivatePeer() (#784)
  * xamarin/Java.Interop@8c7194fd: [AzDO] Switch default branch from master to main. (#786)
  * xamarin/Java.Interop@b0d170c1: [generator] Only apply ConstSugar to Mono.Android.dll (#780)

xamarin/Java.Interop@cba61370 removed the the previously required use
of System.Linq.Expressions from the internal `ManagedPeer` class,
replacing with a call to `JniRuntime.JniValueManager.ActivatePeer()`.

Override `JniRuntime.JniValueManager.ActivatePeer()` within
`Android.Runtime.AndroidRuntime`, implementing
`AndroidRuntime.ActivatePeer()` in terms of
`Java.Interop.TypeManager.Activate()`, thus avoiding the need for
System.Linq.Expressions.

This saves us ~15% in assembly size; size difference of
BuildReleaseArm64False on net6:

	Size difference in bytes ([*1] apk1 only, [*2] apk2 only):
	  +          96 assemblies/Mono.Android.dll
	  -         331 assemblies/System.Collections.Concurrent.dll
	  -         907 assemblies/Java.Interop.dll
	  -       1,003 assemblies/System.Linq.dll
	  -       3,856 assemblies/System.ObjectModel.dll *1
	  -       4,496 assemblies/System.Collections.dll *1
	  -       7,824 assemblies/System.Private.CoreLib.dll
	  -     115,284 assemblies/System.Linq.Expressions.dll *1
	Summary:
	  -     133,605 Assemblies -15.33% (of 871,776)

@jonpryor jonpryor merged commit c33f557 into master Jan 29, 2021
@jonpryor jonpryor deleted the pr-add-ActivatePeer branch January 29, 2021 15:28
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

do-not-merge PR should not be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants