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

[libmonodroid] Enable GC bridge on desktop Java. #31

Merged
merged 4 commits into from
May 25, 2016

Conversation

garuma
Copy link
Contributor

@garuma garuma commented May 10, 2016

There is still some weird GC behavior that happens only on desktop. It seems like calling System.gc() there doesn't properly collect as much references as it could which mean that Java/managed peer pairs are kept around longer than they should be.

Nonetheless, having this in still means we have a much better story for the designer and XF Previewer memory wise.

There is still some weird GC behavior that happens only on desktop. It seems like
calling `System.gc()` there doesn't properly collect as much references as it could
which mean that Java/managed peer pairs are kept around longer than they should be.

Nonetheless, having this in still means we have a much better story for the designer
and XF Previewer memory wise.
@dnfclas
Copy link

dnfclas commented May 10, 2016

Hi @garuma, I'm your friendly neighborhood .NET Foundation Pull Request Bot (You can call me DNFBOT). Thanks for your contribution!

In order for us to evaluate and accept your PR, we ask that you sign a contribution license agreement. It's all electronic and will take just minutes. I promise there's no faxing. https://cla2.dotnetfoundation.org.

TTYL, DNFBOT;

@jonpryor
Copy link
Member

This is where we have too many moving parts. :-)

The goal, slightly delayed by open-sourcing, was to delete the xamarin-android GC bridge processing logic and replace it with the ~same logic from Java.Interop, which, coincidentally, already has (partial?) support for AppDomains.

The problem is twofold:

  1. The integration hasn't occurred yet, and
  2. I don't know if the above existing Java.Interop support is sufficient for your purposes.

Would you mind seeing if the Java.Interop approach works for you? (And maybe start that integration work? ;-)

@garuma
Copy link
Contributor Author

garuma commented May 10, 2016

Seems to me like it's about the same thing, just a slightly different way to iterate over domains when doing bridging.

Up to you if you feel like this part of Java.Interop can be productized faster than reviewing+merging this PR. Alternatively this can provide a baseline that Java.Interop can compare to once it's ready to be productized.

Also of importance, is the designer custom control support code already fully mirrored in Java.Interop? I know some of it is there but maybe not all.

mono.mono_field_static_set_value (jnienv_vtable, android_runtime_jnienv_bridge_processing_field, &true_value);

ref_val = 1;
/* add java refs for items on the list which reference each other */
for (i = 0; i < num_sccs; i++) {
scc = sccs [i];

/* only handle objects part of our current domain */
Copy link
Member

@jonpryor jonpryor May 13, 2016

Choose a reason for hiding this comment

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

Why only handle objects in the current domain?

@jonpryor
Copy link
Member

Up to you if you feel like this part of Java.Interop can be productized faster than reviewing+merging this PR

In retrospect, it's unlikely I'll be able to merge Java.Interop faster than reviewing+merging this PR, in part because this PR requires Windows build support, which Java.Interop/src/java-interop currently lacks...in that it's untested. Consequently, any such merge will regress Windows build support.

Would it be possible for you to update this PR to remove the AppDomain-specific collection code -- as discussed on Slack, there doesn't appear to be an actual use case for AppDomain-specific collections -- and then we can merge this PR?

Additionally, "someone" (volunteers? ;-) is going to need to ensure that Java.Interop/src/java-interop builds on Windows, so that we can merge without regressing in the future.

@garuma
Copy link
Contributor Author

garuma commented May 23, 2016

👍

Instead of having a top level loop on domains and process references per-domain
we instead use the same technique than Java.Interop and instead set the static
bridge_processing field across all domains and then process all references in one go.

This is safe as manipulating MonoObjet fields (mono_field_set_value/mono_field_get_value/...)
don't seem to need to be invoked in a specific appdomain context. Only the bridge_processing
field, being static, needs to be set across domains.
@garuma
Copy link
Contributor Author

garuma commented May 24, 2016

@jonpryor Updated as per discussion. It should now be closer in spirit to Java.Interop

android_runtime_jnienv = runtime;
android_runtime_jnienv_bridge_processing_field = mono.mono_class_get_field_from_name (runtime, "BridgeProcessing");
MonoClass *android_runtime_jnienv = runtime;
MonoClassField *android_runtime_jnienv_bridge_processing_field = mono.mono_class_get_field_from_name (runtime, "BridgeProcessing");
Copy link
Member

Choose a reason for hiding this comment

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

Can we shorten this name so that the =s aren't screwed up? :-D

@garuma
Copy link
Contributor Author

garuma commented May 25, 2016

@jonpryor done

@jonpryor jonpryor merged commit c3811e8 into master May 25, 2016
@garuma garuma deleted the enable-gcbridge-desktop branch May 25, 2016 15:56
radical pushed a commit that referenced this pull request May 8, 2018
The XAIntegrationDebug configuration build was broken, for two
reasons:

 1. `make xa-all` wasn't restoring nuget packages:

		repl.cs(43,24): error CS0234: The type or namespace name `Terminal'
		does not exist in the namespace `Mono'.
		Are you missing an assembly reference?

 2. `generator-Tests` was part of the XAIntegrationDebug
    configuration, but `generator` was not. This meant that
    `generator-Tests` project couldn't build.

		BaseGeneratorTest.cs(7,23): error CS0234: The type or namespace
		name `Binder' does not exist in the namespace `Xamarin.Android'.
		Are you missing an assembly reference?

Fix the XAIntegrationDebug and XAIntegrationRelease
configuration mappings.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants