Commit 67bf7d8
committed
[Mono.Android] fix crash on startup with EnableLLVM
`dotnet new android` apps would crash on startup when built with
`-c Release -p:EnableLLVM=true`:
07-20 08:55:44.642 2983 2983 F monodroid-assembly: Internal p/invoke symbol 'java-interop @ java_interop_jvm_list' (hash: 0x58c48fc8b89cb484) not found in compile-time map.
...
07-20 08:55:44.834 3004 3004 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
07-20 08:55:44.834 3004 3004 F DEBUG : Abort message: 'Internal p/invoke symbol 'java-interop @ java_interop_jvm_list' (hash: 0x58c48fc8b89cb484) not found in compile-time map.'
`java_interop_jvm_list` should *never* be called on Android, it is the
result of `new AndroidRuntime()` having not been called yet?
The problem being that the static `Android.App.Application.cctor` was
somehow running *before* `JNIEnv.Initialize()` was complete? And this
only happens with LLVM?
Reviewing the code:
[UnmanagedCallersOnly]
internal static unsafe void Initialize (JnienvInitializeArgs* args)
{
//...
SynchronizationContext.SetSynchronizationContext (Android.App.Application.SynchronizationContext);
}
We do indeed access `Android.App.Application`...
To fix this, we can move this to a new method decorated with
`MethodImplOptions.NoInlining`. Apps built with LLVM now launch for
me.
We can also enable the LLVM `Mono.Android-Tests` again.1 parent 3e4686c commit 67bf7d8
2 files changed
Lines changed: 9 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
691 | 691 | | |
692 | 692 | | |
693 | 693 | | |
694 | | - | |
695 | | - | |
696 | 694 | | |
697 | 695 | | |
698 | 696 | | |
699 | 697 | | |
700 | | - | |
| 698 | + | |
701 | 699 | | |
702 | 700 | | |
703 | 701 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
203 | 210 | | |
204 | 211 | | |
205 | 212 | | |
| |||
0 commit comments