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

Use mono_unhandled_exception for NET6 #6104

Merged
merged 1 commit into from
Jul 22, 2021

Conversation

grendello
Copy link
Contributor

@grendello grendello commented Jul 20, 2021

Context: dotnet/runtime#55904 (comment)
Context: #4927 (comment)
Context: #4927 (comment)

Xamarin.Android has been using the AppDomain.DoUnhandledException API
since the dawn of time to propagate uncaught Java exceptions to the
managed world. However, said API (and AppDomains) are gone from the
NET6 MonoVM runtime and we need to switch to something else - the
mono_unhandled_exception native API.

This commit introduces an internal call,
JNIEnv.monodroid_unhandled_exception, which is used instead of the
older mechanism when targetting NET6 and which calls the native API
mentioned above.

Add a device integration test which makes sure the uncaught exceptions
are propagated as required.

@grendello grendello requested a review from jonpryor July 20, 2021 10:15
@grendello grendello force-pushed the mono-unhandled-exception branch from 938a341 to d933d43 Compare July 20, 2021 14:45
@grendello grendello force-pushed the mono-unhandled-exception branch from d933d43 to e012409 Compare July 20, 2021 18:01
@grendello grendello force-pushed the mono-unhandled-exception branch from 254717f to ab2920f Compare July 21, 2021 20:47
Context: dotnet/runtime#55904 (comment)
Context: dotnet#4927 (comment)
Context: dotnet#4927 (comment)

Xamarin.Android has been using the `AppDomain.DoUnhandledException` API
since the dawn of time to propagate uncaught Java exceptions to the
managed world.  However, said API (and AppDomains) are gone from the
NET6 MonoVM runtime and we need to switch to something else - the
`mono_unhandled_exception` native API.

This commit introduces an internal call,
`JNIEnv.monodroid_unhandled_exception`, which is used instead of the
older mechanism when targetting NET6 and which calls the native API
mentioned above.

Add a device integration test which makes sure the uncaught exceptions
are propagated as required.
@grendello grendello force-pushed the mono-unhandled-exception branch from 93beecf to 0f67df4 Compare July 22, 2021 11:45
@grendello grendello changed the title [WIP] Use mono_unhandled_exception for NET6 Use mono_unhandled_exception for NET6 Jul 22, 2021
@grendello grendello marked this pull request as ready for review July 22, 2021 11:45
@jonpryor jonpryor merged commit c1a2ee7 into dotnet:main Jul 22, 2021
jonpryor pushed a commit that referenced this pull request Jul 22, 2021
Context: dotnet/runtime#55904 (comment)
Context: #4927 (comment)
Context: #4927 (comment)
Context: xamarin/monodroid@7d62dec
Context: dotnet/runtime@15ab9f9

Xamarin.Android has been using the `AppDomain.DoUnhandledException()`
internal API since 2015 (xamarin/monodroid@7d62dec1) to propagate
uncaught Java exceptions to the managed world.

However, `AppDomain.DoUnhandledException()` was an internal API which
was *removed* from MonoVM as part of the .NET 6 effort in
dotnet/runtime@15ab9f98.

For .NET 6, instead of calling the no-longer-present
`AppDomain.DoUnhandledException()` method, call the
[`mono_unhandled_exception()` embedding API][0], which in turn raises
the `AppDomain.UnhandledException` event.

Add a new internal call, `JNIEnv.monodroid_unhandled_exception()`,
which is used on .NET 6 to invoke `mono_unhandled_exception()`.

Add an on-device integration test which ensures that the uncaught
exceptions are propagated as required.

[0]: http://docs.go-mono.com/index.aspx?link=xhtml%3adeploy%2fmono-api-exc.html
@grendello grendello deleted the mono-unhandled-exception branch July 22, 2021 19:53
thaystg added a commit to thaystg/xamarin-android that referenced this pull request Jul 23, 2021
…er_unhandled_exception

* origin/main:
  Bump to dotnet/installer@19943da 6.0.100-rc.1.21372.10 (dotnet#6110)
  [xaprepare] don't install microsoft-net-runtime-android workload (dotnet#6114)
  [Mono.Android] Use `mono_unhandled_exception` for NET6 (dotnet#6104)
  Bump to dotnet/installer@9c463710 6.0.100-rc.1.21369 (dotnet#6072)
  Bump to xamarin/xamarin-android-binutils/2.37-XA.1@77618674 v2.37 (dotnet#6096)
  [Mono.Android.Export] Fix DynamicDependency to JavaArray (dotnet#6105)
  [xaprepare] always delete ~/android-toolchain/dotnet (dotnet#6098)
  [CI] Add nuget to msi conversion and VS insert stage (dotnet#6030)
  [build] delete platform-31 folder on test jobs (dotnet#6103)
@github-actions github-actions bot locked and limited conversation to collaborators Jan 25, 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.

3 participants