-
Notifications
You must be signed in to change notification settings - Fork 52
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
Remove JNINativeWrapper.CreateDelegate() Usage From Marshal Methods #1258
Comments
In order for this approach to be viable, MonoVM needs to implement support for Hopefully we can get that support for .NET 10. |
We should also make this "only use blittable types" change as part of this as well: #1027 |
Question: should there be any "extensibility" in here, to reduce the need to change (implicit) ABI after this? I'm thinking something along the lines of: partial class JniRuntime {
public virtual void OnUnhandledException (ref JniTransition transition, Exception e)
{
transition.SetPendingException (e);
Debugger.BreakForUserUnhandledException (e);
}
}
catch (Exception __e) {
JniEnvironment.Runtime.OnUnhandledException(ref __envp, __e);
} The downside is that |
The We already set this by default in One thing we could do, is solve this issue for Release mode by using this trimmer flag, MSBuild property, etc.? We could avoid System.Reflection.Emit for |
@jonathanpeppers: I don't immediately understand your previous comment.
This issue #1258 would remove the call to This would not impact |
Context: dotnet/runtime#108211
Context: dotnet/android#9306
Context: dotnet/android#9309
Context: https://github.com/xamarin/monodroid/commit/3e9de5a51bd46263b08365ef18bed1ae472122d8
Consider this marshal method and related infrastructure::
Why do we have
JNINativeWrapper.CreateDelegate()
? (Closely related: why isn't there atry
/catch
block inn_Accept_I()
? Though part of that is "we didn't think of it.")The answer is around the "unhandled exception" experience when a debugger is attached: the debugger breaks at the "active"
throw
site. If the type will be caught by acatch
block, then you won't get an "unhandled exception" notification, which made customers sad.Which means that for a good debugger experience, we can't have
catch
blocks catching exceptions; if we did, then the exceptions would be handled!Meanwhile, we must catch and marshal exceptions back to Java, otherwise we'll corrupt the JVM during stack unwind!
Where we wound up was a terrible middle:
JNINativeWrapper.CreateDelegate()
usedSystem.Reflection.Emit
to bridge these two worlds.However, .NET 9 introduces
System.Diagnostics.DebuggerDisableUserUnhandledExceptionsAttribute
:Thus, the proposal: update the above marshal method related infrastructure to instead be:
This entirely removes
JNINativeWrapper.CreateDelegate()
and in turnSystem.Reflection.Emit
from the marshal method codepath, which should improve app startup.The text was updated successfully, but these errors were encountered: